Skip to content

Instantly share code, notes, and snippets.

@instinctive
Created May 12, 2021 03:02
Show Gist options
  • Save instinctive/24cb47f187021fb49c172f2804998b20 to your computer and use it in GitHub Desktop.
Save instinctive/24cb47f187021fb49c172f2804998b20 to your computer and use it in GitHub Desktop.
Simple chess protocol

Simple Chess Protocol

Existing chess server protocols (UCI) do a lot of things we don't need. Hence this simpler protocol.

Your chess program will read and write lines of input and output. Informally, the first input line will either be black or white, indicating which side your program will play.

Thereafter, your program will read and write moves in succession. Each move will be in long algebraic notation. Specifically, each move will be a 4 or 5 character string with the start and end positions of the moving piece.

Castling will use the king's move. Pawn promotion will add a 5th character indicating the promoted piece. For example:

e2e4
b8c6
f7f8q
e1c1

These moves are, respectively, advancing white's king pawn two squares, moving black's queen knight in front of the bishop pawn, white promoting to a queen on the f-file, and white castling queen-side.

Your program must fight it out. When the game is over, output the single line 1-0 or 0-1 or draw, whichever is correct.

Your program must correctly detect draw by repetition, stalemate, and draw after 50 moves without a capture or pawn move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment