BitBully 0.0.74
Loading...
Searching...
No Matches
bitbully.agent_interface.Connect4Agent Class Reference
Inheritance diagram for bitbully.agent_interface.Connect4Agent:
[legend]
Collaboration diagram for bitbully.agent_interface.Connect4Agent:
[legend]

Public Member Functions

dict[int, int] score_all_moves (self, Board board)
int best_move (self, Board board)
int score_move (self, Board board, int column, int first_guess=0)

Detailed Description

Minimal interface a Connect-4 agent must implement to work with ``GuiC4``.

This interface is intentionally aligned with the public ``BitBully`` API,
but excludes BitBully-specific engine features such as opening-book handling,
node counters, transposition tables, and specialized search entry points.

Required methods:
    - ``score_all_moves``: Provide integer evaluations for all *legal* moves.
    - ``best_move``: Select one legal move using BitBully-compatible
      tie-breaking semantics.

Notes on scoring:
    - Scores are integers where **larger values are better** for the side to move.
    - The absolute scale is agent-defined.
    - The GUI only relies on *relative ordering* and legality.

Definition at line 18 of file agent_interface.py.

Member Function Documentation

◆ best_move()

int bitbully.agent_interface.Connect4Agent.best_move ( self,
Board board )
Return the best legal move (column index) for the side to move.

Args:
    board (Board):
        Current Connect-4 board position.

Returns:
    int:
        Selected column index in the range ``0..6``.

Definition at line 54 of file agent_interface.py.

◆ score_all_moves()

dict[int, int] bitbully.agent_interface.Connect4Agent.score_all_moves ( self,
Board board )
Score all legal moves for the given board state.

Args:
    board (Board):
        Current Connect-4 board position.

Returns:
    dict[int, int]:
        Mapping ``{column: score}`` for all *legal* columns (0..6).
        Columns that are full or illegal **must not** appear in the mapping.

Notes:
    - Higher scores indicate better moves.
    - The returned dictionary may contain between 0 and 7 entries.

Definition at line 36 of file agent_interface.py.

◆ score_move()

int bitbully.agent_interface.Connect4Agent.score_move ( self,
Board board,
int column,
int first_guess = 0 )
Evaluate a single legal move for the given board state.

This method is optional and not required by the GUI, but can be useful
for agents that support fine-grained move evaluation.

Args:
    board (Board):
        Current Connect-4 board position.
    column (int):
        Column index (0..6) of the move to evaluate.
    first_guess (int):
        Optional initial guess for iterative or search-based agents.
        Implementations may safely ignore this parameter.

Returns:
    int:
        Evaluation score for the given move.

Definition at line 70 of file agent_interface.py.


The documentation for this class was generated from the following file: