Skip to content

treepeck/chego

Repository files navigation

License: MPL 2.0 Go Reference

Chego implements chessboard state management and legal move generation.

Piece positions are stored as bitboards.

Move generation is implemented using the Magic Bitboards method.

It is assigned to use in the web-servers (for example, justchess.org),
hence it does not provide any GUI or CLI.

Usage

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() {
	// It is important to call InitAttackTables as close to the program
	// start as possible, otherwise the move generation won't work.
	chego.InitAttackTables()

	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())
}

Local installation

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

Tests and benchmarks

To execute the performance test, run this command in the chego folder:

go run ./internal/perft.go -depth {IntValue}

Chego generates 119060324 moves at depth 6 in approximately 6 seconds
on an Intel i7-10750H CPU.

License

Copyright (c) 2025 Artem Bielikov

This project is available under the Mozilla Public License, v. 2.0.
See the LICENSE file for details.

About

Chess module with move generation and game state management.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published