Home

Awesome

chess.cairo

A Cairo contract to play chess, with composability in mind.

How it works

Every game of chess will be deployed in a single contract. Each contract has who plays as white, as black, who is the governor, and the initial fen state.

State of chess

Because of threefold repetition, the full state of chess requires the full history of moves, so that any of the players can force a draw if a board state is reached three times. A board state is what is commonly referred to as the "state" of chess. That is, whatever can be represented with Forsyth–Edwards Notation, except the fullmove clock and the halfmove clock (count of plys since last irreversible action).

Glossary of states

How the state is stored

In chess.cairo, the contract keeps initial_state, an encoded fen state, and moves, the array of moves. That means, the contract effectively holds the full state. You can reach the current fen state by iterating through the move history, advancing move by move.

Installation

This project uses nile. Refer to it if you're lost. You'll also need pyenv, to use python3.7.

Running it

Go to notes/useful_commands.txt to find some stuff. {} means you paste an address or a big hex.

If you got here you can figure out the rest yourself