go-chess-models, v1.9.0
Posted on

The library that implements checking and generating of chess moves.
Adding the boards.BitBoard structure; adding the go-chess-moves and go-chess-comparator tools.
Change Log
- new features:
- the
boards.BitBoardstructure:- add the
boards.BitBoardstructure; - add the
boards.BitBoardstructure to thego-chess-perfttool;
- add the
- add the
go.modfile; - tools:
- improve the
go-chess-perfttool:- improve the documentation;
- improve the options;
- validate the
deepoption;
- add the
go-chess-movestool; - add the
go-chess-comparatortool;
- improve the
- the
- refactoring:
- fix the code style with the
golangci-linttool;
- fix the code style with the
- unit testing:
- improve the tests of the
ApplyMove()methods;
- improve the tests of the
- examples:
- move the tests of the
boardspackage to the right place.
- move the tests of the
Features
- representing the board:
- as an associative array of pieces with their positions as keys;
- as a plain array of pieces with exact correspondence array indices to piece positions;
- as a set of integers corresponding to a particular combination of piece color and type, and where each bit corresponds to a particular piece position (so-called a bitboard);
- immutable applicating moves to the board via copying the latter;
- checkings of moves:
- universal;
- individual for all types of pieces;
- generating moves via filtering from all possible ones;
- move restrictions (abandoned moves):
- pawn double-move;
- en passant capture;
- promotion;
- castling;
- perft function;
- using an abstraction of a piece;
- Forsyth-Edwards Notation:
- parsing:
- of a position;
- of a move;
- of a piece kind;
- of a piece color;
- of a board;
- serialization:
- of a position;
- of a move;
- of a piece kind;
- of a piece color;
- of a board;
- parsing:
- utilities:
- utility for counting all possible moves (based on the perft function);
- utility for generating all possible chess moves;
- utility for comparing the generation of all possible chess moves by different board representations.
Benchmarks
The chessmodels.Perft() function used the boards.BitBoard structure:
BenchmarkPerft/BitBoard/initial/1Ply-8 284 4036298 ns/op 958048 B/op 35888 allocs/op
BenchmarkPerft/BitBoard/initial/2Ply-8 20 54032966 ns/op 11627104 B/op 433592 allocs/op
BenchmarkPerft/BitBoard/initial/3Ply-8 2 708741154 ns/op 169201536 B/op 6300499 allocs/op
BenchmarkPerft/BitBoard/kiwipete/1Ply-8 74 14372268 ns/op 3546305 B/op 124803 allocs/op
BenchmarkPerft/BitBoard/kiwipete/2Ply-8 2 637371490 ns/op 138270896 B/op 4866744 allocs/op
Installation of the go-chess-moves Tool
$ go install github.com/thewizardplusplus/go-chess-models/cmd/go-chess-moves@latest
Usage of the go-chess-moves Tool
$ go-chess-moves -h | -help | --help
$ go-chess-moves [options]
Options:
-h,-help,--help— show the help message and exit;-storage {map|slice|bits}— piece storage kind (default:slice);-fen STRING— board in Forsyth-Edwards Notation (default:rnbqk/ppppp/5/PPPPP/RNBQK, i.e., Gardner's minichess);-color {black|white}— color that moves first (default:white).
Installation of the go-chess-comparator Tool
$ go install github.com/thewizardplusplus/go-chess-models/cmd/go-chess-comparator@latest
Usage of the go-chess-comparator Tool
$ go-chess-comparator -h | -help | --help
$ go-chess-comparator [options]
Options:
-h,-help,--help— show the help message and exit;-fen STRING— board in Forsyth-Edwards Notation (default:rnbqk/ppppp/5/PPPPP/RNBQK, i.e., Gardner's minichess);-color {black|white}— color that moves first (default:white);-mode {depth-first|breadth-first}— comparing mode (default:depth-first);-deep INTEGER— analysis deep (should be greater than or equal to zero; default:5).
Repository
Link: https://github.com/thewizardplusplus/go-chess-models/tree/v1.9.0.
Content: code.
License: MIT.
Screenshots
Running of the go-chess-moves tool

Running of the go-chess-comparator tool (depth-first comparing mode)

Running of the go-chess-comparator tool (breadth-first comparing mode)
