Chego implements chessboard state management, legal move generation, and move
compression.
Piece positions are stored as bitboards.
Move generation is implemented using the Magic Bitboards method.
Compression is implemented using the Huffman coding method.
It is assigned to use in the web-servers (for example, justchess.org), hence it doesn't
provide any GUI or CLI.
To install chego, run go get:
go get github.com/treepeck/chego
Here is a simple example:
package main
import (
"fmt"
"github.com/treepeck/chego"
)
func main() {
g := chego.NewGame()
// Scholar's mate.
g.PushMove(chego.NewMove(chego.SF3, chego.SF2, chego.MoveNormal))
g.PushMove(chego.NewMove(chego.SE5, chego.SE7, chego.MoveNormal))
g.PushMove(chego.NewMove(chego.SG4, chego.SG2, chego.MoveNormal))
g.PushMove(chego.NewMove(chego.SH4, chego.SD8, chego.MoveNormal))
// Prints "Is checkmate: true"
fmt.Printf("Is checkmate: %t\n", g.IsCheckmate())
}First install the Go compiler version 1.24.1 or newer (see https://go.dev/dl).
Once the compiler is installed, clone this repository:
git clone https://github.com/treepeck/chego
cd chego
To execute the performance test, run this command in the chego folder:
go run ./internal/perft/perft.go -depth {IntValue}
Chego generates 119060324 moves at depth 6 in approximately 6 seconds on an
Intel i7-10750H CPU.
Chego allows to generate Huffman codes for legal moves, which helps to compress
the completed move storage and drastically reduce the size of database.
-
Download the PGN file containing one or more games (https://database.lichess.org/).
-
Prepare the file to code generation by executing this command in the chego folder:
go run ./internal/codegen/codegen.go -input {Filename.pgn} -output {Clean.txt} -task clean
- Generate Huffman codes after cleaning:
go run ./internal/codegen/codegen.go -input {Clean.txt} -output {Codes.txt} -task generate -workers {IntValue}
The workers flag defines how many concurrent goroutines will perform Huffman
code generation. Higher values reduce execution time, but increase CPU usage.
Copyright (c) 2025 Artem Bielikov
This project is available under the Mozilla Public License, v. 2.0.
See the LICENSE file for details.