octad is a set of go packages which provide common octad chess variant utilities such as move generation, turn management, checkmate detection, a basic engine, PGN encoding, image generation, and others.
| Package | Docs Link | Description |
|---|---|---|
| octad | dechristopher/octad | Move generation, serialization / deserialization, turn management, checkmate detection |
| image | dechristopher/octad/image | SVG octad board image generation |
| liad | dechristopher/octad/liad | Li(bre oct)ad test harness and sample self play implementation |
octad can be installed using "go get".
go get -u github.com/dechristopher/octad/v2Octad was conceived by Andrew DeChristopher in 2018. Rules and information about the game can be found below. Octad is thought to be a solved, deterministic game but needs formal verification to prove that. This repository exists as an effort towards that goal.
In the default position, each player begins with four pieces: a knight, their king, and two pawns placed in that order from left to right relative to them. An example of this can be seen in the board diagrams below:
| Octad Board | 1. c2 | 1. c2 b3 | 1. c2 b3 2. cxb3! ... |
|---|---|---|---|
All standard chess rules apply:
- En passant is allowed
- Pawn promotion to any piece
- Stalemates are a draw
The only catch, however, is that castling is possible between the king and any
of its pieces on the starting rank before movement. Castling is
position-relative — the king may castle from whatever home-rank square it
occupies. The king simply switches spaces with the castling piece in all cases
except the far piece, in which case the king travels one space toward it and
that piece lands where the king was before. The three castle types are named
for the king's relationship to its partner: near (an adjacent knight),
center (an adjacent pawn), and far (a pawn two files away, leapt over an
empty gap). An example of white performing a far castle can be expressed as
[ 1. c2 b3 2. O-O-O ... ] with the resulting structure leaving the knight on
a1, a pawn on b1, the king on c1, and the other pawn on c2. Here is what that
would look like on the board:
- Near castle: O
- Center castle: O-O
- Far castle: O-O-O
OFEN is a derivation of FEN to support the features of Octad. Read more here.
1.O-O a3
2.Nc2 a2
3.b3+ Nxb3+
4.Kb2 a1=Q+
5.Nxa1 Nxa1
6.Kxa1 Kc3
7.Ka2 b3+
8.Ka1 b2+
9.Kb1 Kb3
10.d3 Kc3
11.d4=Q+ Kxd4
12.Kxb2 1/2-1/2
Drawn by Insufficient Material
1.c2 b3
2.Kb2 O-O-O
3.cxb3 cxb3
4.d2 Nc2
5.d3 Nxa1
6.d4=Q# 1-0
White wins by Checkmate
octad has been performance tuned, using pprof, with the goal of being fast enough for use by octad bots and engines. This implementation relies heavily on the use of bitboards, resulting in very solid computational performance.
The benchmarks can be run with the following command:
go test -bench=.
Results from the baseline 2019 16" MBP:
BenchmarkBitboardReverse-12 1000000000 0.000016 ns/op
BenchmarkStalemateStatus-12 971688 1220 ns/op
BenchmarkInvalidStalemateStatus-12 1387780 857 ns/op
BenchmarkPositionHash-12 1429471 841 ns/op
BenchmarkValidMoves-12 235640 4992 ns/op