bitbully_core
Bitbully is a fast Connect-4 solver.
Classes:
| Name | Description |
|---|---|
BitBullyCore |
|
BoardCore |
|
OpeningBookCore |
|
Player |
|
Attributes:
| Name | Type | Description |
|---|---|---|
N_COLUMNS |
int
|
|
N_ROWS |
int
|
|
__all__
module-attribute
__all__: list[str] = ['BitBullyCore', 'BoardCore', 'OpeningBookCore', 'Player', 'N_COLUMNS', 'N_ROWS']
BitBullyCore
-
BitBully API Reference
gui_c4GuiC4bitbully_agent
Methods:
| Name | Description |
|---|---|
getNodeCounter |
Get the current node counter. |
isBookLoaded |
Check, if opening book is loaded |
loadBook |
Load an opening book from a file path. |
mtdf |
MTD(f) algorithm |
negamax |
Negamax search |
nullWindow |
Null-window search |
resetBook |
Unload the currently loaded opening book (if any). |
resetNodeCounter |
Reset the node counter |
resetTranspositionTable |
Reset the transposition table |
scoreMove |
Evaluate a single move. |
scoreMoves |
Evaluate all moves |
getNodeCounter
getNodeCounter() -> int
isBookLoaded
isBookLoaded() -> bool
loadBook
Load an opening book from a file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
PathLike[str] | str
|
Path to the opening book file. If empty or invalid, no book is loaded. |
...
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Source code in src/bitbully/bitbully_core.pyi
mtdf
MTD(f) algorithm Args: board (BoardCore): The current board state. first_guess (int): Initial guess for the score. Returns: int: The minimax score of the position.
negamax
nullWindow
resetBook
resetNodeCounter
resetTranspositionTable
scoreMove
Evaluate a single move.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BoardCore
|
The current board state. |
required |
|
int
|
Column index (0–6) of the move to evaluate. |
required |
|
int
|
Initial guess for the score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The evaluation score of the move. |
-
BitBully API Reference
solverBitBullyscore_move
Source code in src/bitbully/bitbully_core.pyi
BoardCore
-
BitBully API Reference
bitbully_coreBoardCore
-
BitBully API Reference
bitbully_core
Methods:
| Name | Description |
|---|---|
__eq__ |
Check if two boards are equal |
__ne__ |
Check if two boards are not equal |
__repr__ |
Return a developer-oriented string representation of the board. |
__str__ |
Return a human-readable string representation of the board. |
allPositions |
Generate all positions that can be reached from the current board with n tokens. |
copy |
Create a deep copy of the board. |
countTokens |
Get the number of Tokens on the board |
doubleThreat |
Find double threats |
findThreats |
Find threats on the board |
generateNonLosingMoves |
Generate non-losing moves |
hasWin |
Check, if the player who performed the last move has a winning position (4 in a row). |
hash |
Hash the current position and return hash value. |
isLegalMove |
Check if a move is legal |
isValid |
Check, if a board is a valid one. |
legalMoves |
Generate possible moves as a vector of column indices |
legalMovesMask |
Generate possible moves as bitboard |
mirror |
Get the mirrored board (mirror around center column) |
movesLeft |
Get the number of moves left |
playMoveOnCopy |
Play a move on a copy of the board and return the new board |
popCountBoard |
Popcount of all tokens bitboard (number of occupied cells). |
randomBoard |
Create a random board with n tokens and returns the board and the move sequence. |
toArray |
Convert the board to a 2D array representation |
toHuffman |
Encode position into a huffman-code compressed sequence. |
toString |
Return a string representation of the board |
uid |
Get the unique identifier for the board |
Attributes:
| Name | Type | Description |
|---|---|---|
__hash__ |
None
|
|
__eq__
__ne__
__repr__
__repr__() -> str
__str__
__str__() -> str
allPositions
copy
copy() -> BoardCore
countTokens
countTokens() -> int
doubleThreat
findThreats
generateNonLosingMoves
generateNonLosingMoves() -> int
hasWin
hasWin() -> bool
hash
hash() -> int
isLegalMove
isValid
staticmethod
Check, if a board is a valid one.
legalMoves
legalMovesMask
legalMovesMask() -> int
mirror
mirror() -> BoardCore
movesLeft
movesLeft() -> int
playMoveOnCopy
popCountBoard
popCountBoard() -> int
randomBoard
staticmethod
Create a random board with n tokens and returns the board and the move sequence.
toArray
Convert the board to a 2D array representation
toHuffman
toHuffman() -> int
toString
toString() -> str
OpeningBookCore
Methods:
| Name | Description |
|---|---|
convertValue |
Convert a value to the internal scoring system. |
getBoardValue |
Get the value of a given board. |
getBook |
Return the raw book table. |
getBookSize |
Get the size of the book. |
getEntry |
Get an entry from the book by index. |
getNPly |
Get the ply depth of the book. |
init |
Reinitialize the OpeningBook with new settings. |
isInBook |
Check, if the given board is in the opening book. Note, that usually boards are only present in one mirrored variant. |
readBook |
Read a book from a file. |
convertValue
getBoardValue
getBook
getBookSize
getBookSize() -> int
getEntry
getNPly
getNPly() -> int
init
isInBook
Check, if the given board is in the opening book. Note, that usually boards are only present in one mirrored variant.