Chess
Play chess as the black pieces against the computer or a user on chess.com.
- async bobbot.activities.chess_player.check_game_over(page: Page) tuple[str, str] | None [source]
Check if the game is over. Returns None if ongoing. Else, returns white/black/draw/unknown and a description.
- async bobbot.activities.chess_player.close_ending_dialog(page: Page) None [source]
Close the game over dialog (if it’s open).
- bobbot.activities.chess_player.configure_chess(elo: int, against_computer: bool) None [source]
Configures the chess activity.
- Parameters:
elo – Bob’s elo rating. Should be in [200, 1600].
against_computer – Whether Bob is playing against the computer or a user.
- async bobbot.activities.chess_player.get_challenge_link(page: Page) str [source]
Get a challenge link to play against the bot.
- bobbot.activities.chess_player.get_chess_info() str [source]
Get the current chess activity status.
- async bobbot.activities.chess_player.get_move(page: Page, board: Board) tuple[Move, float] [source]
Get a move for the given board. Quality varies based on elo and time left. Simulates thinking time.
- Parameters:
page – The current page.
board – The current board state.
- Returns:
A tuple of the suggested move and the estimated win chance (0-100).
- async bobbot.activities.chess_player.get_move_sunfish(board: Board, elo: int) tuple[Move, float] [source]
Get a move using Sunfish for the target elo.
- Parameters:
board – The current board state.
elo – The target elo.
- Returns:
A tuple of the suggested move and the estimated win chance (0-100).
- async bobbot.activities.chess_player.get_moves_locator(page: Page) tuple[Locator, str] [source]
Get the locator for the move list, along with the selector used.
- async bobbot.activities.chess_player.get_time_left(page: Page) int | None [source]
Get Bob’s clock time left in seconds, if it exists.
- async bobbot.activities.chess_player.login(page: Page, context: BrowserContext) None [source]
Login to chess.com.
- bobbot.activities.chess_player.parse_board(classes: list[str]) Board [source]
Parse the board from a list of classes representing the pieces.
- async bobbot.activities.chess_player.play_chess_activity(cmd_handler: Callable) None [source]
Play chess against the user (or the computer).
- Parameters:
cmd_handler – The callback to send commands directed at Bob. The callback should be an async function that accepts exactly one string argument. If the activity fails to start, it will be called with the reason. Otherwise, it will be called the activity goes on and important things happen.
- async bobbot.activities.chess_player.screenshot_chess_activity() Path | None [source]
Get a Path to a screenshot of the whole page (including the board), or None if no screenshot is available.
- async bobbot.activities.chess_player.start_match_computer(page: Page) None [source]
Start a match against the computer.
- async bobbot.activities.chess_player.start_sunfish_engine() None [source]
Start the Sunfish engine.
- bobbot.activities.chess_player.stop_playing_chess() None [source]
Stops playing chess (when it’s feasible to).