Beta

Chess Overview

This is vanilla chess in blitz format: 5 minute chess clock with no time increment. Our engine implements all standard stalemate rules:

  • Insufficient Material
  • Repetition
  • Fifty Move Rule

Ranking

Todo: write a general elo based doc page and reference it here

Details

Your algo’s on_my_turn() function gets called with each new chess gamestate that is your turn to move, or you can define on_update() which gets called with each new chess gamestate including states that are not your turn to move. Make your move by calling ChessInterface.make_move() from on_my_turn() or on_update() with one of the moves in ChessGameState.all_valid_moves, written in UCI. If the algo does not call ChessInterface.make_move(), the chess engine waits until your clock runs out and you lose. Playing a move that isn’t valid or moving when it isn’t your turn forfeits the game.

Use ChessInterface.make_pseudo_move() to make a move and receive the new state without commiting to that move.

Your algo’s setup() function is given your pieces’ color, which is either 'w' or 'b'.

See ChessGameState and ChessInterface for API reference.

Sample Algo

import random

from algogames import ChessInterface

my_color = None

def setup(color):
    global my_color
    my_color = color


def on_update(state):
    # Every board, including the one your own move just produced.
    ChessInterface.log(state.board)


def on_my_turn(state):
    # Only the boards it is your move on, which is where a move belongs: the
    # engine plays one move at a time, and moving out of turn forfeits the game.
    ChessInterface.make_move(random.choice(state.all_valid_moves))