BitBully 0.0.59-a2
Loading...
Searching...
No Matches
bitbully.py
1"""This module provides the Connect Four AI agent "BitBully" with opening book support."""
2
3# from importlib.resources.abc import Traversable
4from typing import Literal
5
6from bitbully import bitbully_core
7
8from .board import Board
9
10
12 """A Connect Four AI agent with opening book support."""
13
14 def __init__(self, opening_book: Literal["default", "8-ply", "12-ply", "12-ply-dist"] | None = "default") -> None:
15 """Initializes the BitBully agent with the specified opening book.
16
17 Args:
18 opening_book (Literal["default", "8-ply", "12-ply", "12-ply-dist"] | None):
19 The type of opening book to use. Options are:
20 - "default": Uses the default 12-ply distance-based opening book.
21 - "8-ply": Uses an 8-ply opening book.
22 - "12-ply": Uses a 12-ply opening book.
23 - "12-ply-dist": Uses a 12-ply distance-based opening book.
24 - None: No opening book will be used.
25 """
26 from pathlib import Path
27
28 import bitbully_databases as bbd
29
30 self.opening_book_type = opening_book
31
32 if opening_book:
33 db_path = bbd.BitBullyDatabases.get_database_path(opening_book)
34 self.bitbully_agent = bitbully_core.BitBullyCore(Path(db_path))
35 else:
36 self.bitbully_agent = bitbully_core.BitBullyCore()
37
38 def score_next_moves(self, board: Board) -> list[int]:
39 """Scores all possible moves for the given board state.
40
41 Args:
42 board (Board):
43 The current board state.
44
45 Returns:
46 list[int]: A list of scores for each column (0-6).
47 """
48 return self.bitbully_agent.scoreMoves(board._board)
None __init__(self, Literal["default", "8-ply", "12-ply", "12-ply-dist"]|None opening_book="default")
Definition bitbully.py:14
list[int] score_next_moves(self, Board board)
Definition bitbully.py:38