Chesscode - a way of encoding messages using a chess board and the starting set of chess pieces

chesscode

ChessCode Image

Are you a spy that needs to leave an urgent top secret message for an incoming foreign diplomat but the only thing in the consulate's parlor is a chessboard? Chesscode has you covered.

Chesscode is a way of encoding messages using a chess board and the starting set of chess pieces. The message can be up to 23 alphanumeric characters also allowing spaces and periods.

Demo Video

ChessCode Demo

Web Encoder / Decoder

The web encoder / decoder is hosted with Github Pages using the static assets in the /docs directory. Notably this library is converted to WebAssembly using Go's compiler support and includes the notnil/chess package.

Live Demo: https://notnil.github.io/chesscode/

Methodology

Chesscode has a few primary objectives:

  • Use a subset of the starting pieces (so it can be used in person)
  • Encode as much alphanumeric text as possible
  • Disallow ambiguous encodings and decodings

Encoding

Since the set of possible pieces is fixed as a subset of the starting position, this infinitely limits the theoretical possibilities of 13^64 configurations. Another issue is piece distribution, there is one white king and eight white pawns for example. Because of these constraints, pieces signify the order of data and squares hold the data itself.

Piece Order

  • White King
  • Black King
  • White Queen
  • Black Queen
  • White Rooks
  • Black Rooks
  • White Bishops
  • Black Bishops
  • White Knights
  • Black Knights
  • White Pawns
  • Black Pawns

This pattern is easiest to see with the white king. The first example with the king in the A1 square encodes 0, while the king in the C2 encodes A. The square simply indexes a character in the charset. This gets us one character.

Charset (space at end):

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ. 

ChessCode Image ChessCode Image

Once a square is used, it can't be used again. For the black king, white queen, and black queen characters are encoded in the index of the remain squares. This gets us four characters total.

ChessCode Image

Continuing the pattern of simply using square indexes for pieces with multiple copies would result in ambiguous results (which white rook is first). To combat this, piece combinations are indexed. White rooks, black rooks, white bishops, and black bishops encode to two characters using their combination index. Because these pieces must encode two characters in combination, input strings are filled to spaces to appropriate size. This gets us twelve characters total.

ChessCode Image

Knights, due to diminishing squares, don't have enough combinations to encode two characters per color. Knights are therefore combined and encode three characters. This gets us fifteen characters total.

ChessCode Image

The number of combinations of eight pawns into the forty eight squares remaining is too large to calculate and index in a reasonable time frame. Therefore pawns of the same color are split up into two groups, left and right, occupying the A-D and E-H files respectively. Four pawns on half the board can encode two characters each. With white and black pawns on the left and right side get us to twenty three characters total.

ChessCode Image

Decoding

Decoding simply reverses the encoding process, but there is a few caveats:

  • Not every board with the starting pieces can be decoded
  • It is ambiguous if the message intended to leave white space at the end of the message

Both of these caveats are acceptable. Firstly the only positions of use are ones previous encoded, so positions which can not be decoded just reflect the fact that there are unused positions which is a better trade off than not being able to represent all input text. Secondly white space at the end of the message rarely conveys semantic meaning and can be safely ignored.

Similar Resources

A cli to play chess against an an UCI engine of your choice, written in go

A cli to play chess against an an UCI engine of your choice, written in go

chess-cli chess-cli is a cli for playing chess against an UCI compatible engine written in go Note: Chess pieces are in unicode, so the color may seem

Mar 1, 2022

A cli to play chess against an an UCI engine of your choice, written in go

A cli to play chess against an an UCI engine of your choice, written in go

chess-cli chess-cli is a cli for playing chess against an UCI compatible engine written in go Note: Chess pieces are in unicode, so the color may seem

Dec 24, 2021

A simple chess engine for experiment, made in Golang

chess-engine A simple chess engine for experiment, made in Golang Build the engine Run the command make or make build Run the engine Run the command f

Dec 26, 2021

chess.com api wrapper for go

Chessdotcom-go An unofficial, simple, lighweight API wrapper for chess.com written in go Usage go get -u "github.com/ATTron/chessdotcom-go" im

Dec 31, 2021

A chess server built with Temporal.

A chess server built with Temporal.

chesstempo A chess server built with Temporal. Dependencies The activity worker runs Stockfish in the background. In Debian-based distros, you can ins

Nov 21, 2022

A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy!

A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy!

galactic-asteroid-belt Overview A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy! Run To run, you will need Go

Dec 2, 2021

2048 using the fantasy console WASM-4 and TinyGo

2048 using the fantasy console WASM-4 and TinyGo

w4-2048 🎮 Play 🎵 With music 🔉 🎵 With sound and music Game logic initially based on https://github.com/chhabraamit/2048 Controls Arrow keys X Z Res

Jul 9, 2022

A small fantasy game engine in WASM using GoLang

A small fantasy game engine in WASM using GoLang

The GoLang Fantasy Engine (GoLF Engine) is a retro game engine. It draws inspiration from fantasy console projects like pico-8, tic-80, and pyxle. Like those projects it is designed to be a retro-feeling game creation/playing tool. Unlike those projects GoLF is more minimal in scope and only provides an API and a small set of tools to help you create your games. Tools like an image editor and code editor are not built in. Despite this minimalism creating games in GoLF is still easy and should still maintain the retro game feel.

Jul 16, 2022

Arkanoid game in Go using Ebiten game engine with ECS.

Arkanoid game in Go using Ebiten game engine with ECS.

Arkanoid-go Arkanoid game in Go using Ebiten game engine with ECS. You must have Git LFS installed when cloning the repository to download assets. See

Oct 9, 2022
Comments
  • [Feature Request] Guarantee Legal Positions

    [Feature Request] Guarantee Legal Positions

    So is there any way to guarantee a legal position, i.e. a position that could be played on the board including checkmate and stalemate from any encoded or decoded message. It would be suspicious if I left a bonkers position on the board for a secret message.

Online multiplayer board game server written in Go, using WebSockets.

BfH Server The Battle for Hermannia is a board game created as a gift by the father of hermannm, a developer of this project. This digital edition of

Nov 7, 2022
A chess GUI build using the Fyne toolkit.
A chess GUI build using the Fyne toolkit.

Chess The subject of my current live stream series. A simple chess UI built with Fyne. Thanks to: Chess Go library by Logan Spears github.com/notnil/c

Dec 20, 2022
Play chess with Go, HTML5, WebSockets and random strangers!

ChessBuddy Play chess with Go, HTML5, WebSockets and random strangers! Demo: http://chess.tux21b.org:8000/ Hint: Open the page in two different tabs,

Nov 10, 2022
♛♔ Play chess against UCI engines in your terminal.
♛♔ Play chess against UCI engines in your terminal.

uchess ♛♔ Play chess in your terminal. Introduction uchess is an interactive terminal chess client designed to allow gameplay and move analysis in con

Nov 17, 2022
A chess engine written in golang
A chess engine written in golang

Weasel Art graciously provided by Alex Table of Contents: About Installing and Compiling from Source Contributing License About Weasel is an 0x88 and

Dec 30, 2022
Currently in beta testing. A chess engine written in golang
Currently in beta testing. A chess engine written in golang

Weasel Art graciously provided by Alex Table of Contents: About Installing and Compiling from Source Contributing License About Weasel is an 0x88 and

Dec 30, 2022
chess package for go
chess package for go

chess Introduction chess is a set of go packages which provide common chess utilities such as move generation, turn management, checkmate detection, P

Dec 26, 2022
Blunder is an open-source UCI compatible chess engine.

A UCI compatible chess engine written in Golang

Dec 30, 2022
Play chess in your terminal
Play chess in your terminal

Gambit Chess board in your terminal. Warning gambit does not have many features at the moment. I plan on adding a chess engine, mouse support, timers,

Dec 21, 2022
A small go program that solves the Queen's Gambit chess puzzle.

Queen's Gambit Solver This program attempts to solve the Queen's Gambit each time it is run. The Queen's Gambit is a chess-based puzzle where eight qu

Jun 27, 2022