Player

class games.chess.player.Player

Bases: games.chess.game_object.GameObject

The class representing the Player in the Chess game.

A player in this game. Every AI controls one player.

property client_type

What type of client this is, e.g. ‘Python’, ‘JavaScript’, or some other language. For potential data mining purposes.

Type

str

property color

The color (side) of this player. Either ‘white’ or ‘black’, with the ‘white’ player having the first move.

Type

‘black’ or ‘white’

property game_object_name

String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

Type

str

property id

A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

Type

str

log(message: str) → None

Adds a message to this GameObject’s logs. Intended for your own debugging purposes, as strings stored here are saved in the gamelog.

Parameters

message (str) – A string to add to this GameObject’s log. Intended for debugging.

property logs

Any strings logged will be stored here. Intended for debugging.

Type

list[str]

property lost

If the player lost the game or not.

Type

bool

property name

The name of the player.

Type

str

property opponent

This player’s opponent in the game.

Type

games.chess.player.Player

property reason_lost

The reason why the player lost the game.

Type

str

property reason_won

The reason why the player won the game.

Type

str

property time_remaining

The amount of time (in ns) remaining for this AI to send commands.

Type

float

property won

If the player won the game or not.

Type

bool