AI

class games.chess.ai.AI(game)

Bases: joueur.base_ai.BaseAI

The AI you add and improve code inside to play Chess.

end(won: bool, reason: str) → None

This is called when the game ends, you can clean up your data and dump files here if need be.

Parameters
  • won (bool) – True means you won, False means you lost.

  • reason (str) – The human readable string explaining why your AI won or lost.

property game

The reference to the Game instance this AI is playing.

Type

games.chess.game.Game

game_updated() → None

This is called every time the game’s state updates, so if you are tracking anything you can update it here.

get_name() → str

This is the name you send to the server so your AI will control the player named this string.

Returns

The name of your Player.

Return type

str

get_setting(key: str) → str

Gets an AI setting passed to the program via the –aiSettings flag. If the flag was set it will be returned as a string value, None otherwise.

Parameters

key (str) – The key of the setting you wish to get the value for

Returns

A string representing the value set via command line, or None if the key was not set

Return type

str

make_move() → str

This is called every time it is this AI.player’s turn to make a move.

Returns

A string in Universal Chess Interface (UCI) or Standard Algebraic Notation (SAN) formatting for the move you want to make. If the move is invalid or not properly formatted you will lose the game.

Return type

str

property player

The reference to the Player this AI controls in the Game.

Type

games.chess.player.Player

start() → None

This is called once the game starts and your AI knows its player and game. You can initialize your AI here.