go-chess-models, v1.8
Posted on

The library that implements checking and generating of chess moves.
Adding the chessmodels.SliceBoard structure; optimization.
Change Log
- new features:
- the
chessmodels.BaseBoardstructure that stores a board size; - the
chessmodels.SliceBoardstructure:- rename the
chessmodels.Boardstructure tochessmodels.MapBoard; - add the
chessmodels.SliceBoardstructure; - add the
chessmodels.SliceBoardstructure to thego-chess-perfttool; - make the
chessmodels.Boardtype redirect to thechessmodels.SliceBoardstructure;
- rename the
- transform the
Pieces()methods of thechessmodels.MapBoardandchessmodels.SliceBoardstructures to an independent function; - the
chessmodels.Sizestructure:- add the
PositionIndex()method; - add the
PositionCount()method; - add the
IteratePositions()method;
- add the
- the
- refactoring:
- optimize memory allocations;
- unit testing:
- slightly improve the tests of the
chessmodels.MapBoardstructure:- of the
Piece()method; - of the
ApplyMove()method;
- of the
- add the benchmarks based on the
chessmodels.Perft()function:- for the
chessmodels.MapBoardstructure; - for the
chessmodels.SliceBoardstructure.
- for the
- slightly improve 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;
- 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;
- 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):
- counting all possible moves:
- parameters:
- position;
- color that moves first;
- analysis deep;
- parameters:
- profiling:
- targets:
- CPU usage;
- memory usage;
- storing the results to a file.
- targets:
- counting all possible moves:
- utility for counting all possible moves (based on the perft function):
Benchmarks
The chessmodels.Perft() function using the chessmodels.MapBoard structure:
BenchmarkPerft/MapBoard/initial/1Ply-8 486 2239365 ns/op 507723 B/op 13638 allocs/op
BenchmarkPerft/MapBoard/initial/2Ply-8 38 27071904 ns/op 6253672 B/op 165159 allocs/op
BenchmarkPerft/MapBoard/initial/3Ply-8 3 394039297 ns/op 91006645 B/op 2399815 allocs/op
BenchmarkPerft/MapBoard/kiwipete/1Ply-8 150 7844416 ns/op 1959120 B/op 47637 allocs/op
BenchmarkPerft/MapBoard/kiwipete/2Ply-8 4 311539966 ns/op 80169034 B/op 1892731 allocs/op
The chessmodels.Perft() function used the chessmodels.SliceBoard structure:
BenchmarkPerft/SliceBoard/initial/1Ply-8 810 1419572 ns/op 684016 B/op 13646 allocs/op
BenchmarkPerft/SliceBoard/initial/2Ply-8 68 17883575 ns/op 8331384 B/op 165074 allocs/op
BenchmarkPerft/SliceBoard/initial/3Ply-8 4 253594389 ns/op 121325578 B/op 2399248 allocs/op
BenchmarkPerft/SliceBoard/kiwipete/1Ply-8 220 5340912 ns/op 2583824 B/op 47672 allocs/op
BenchmarkPerft/SliceBoard/kiwipete/2Ply-8 5 208109435 ns/op 103011680 B/op 1895999 allocs/op
Repository
Link: https://github.com/thewizardplusplus/go-chess-models/tree/v1.8.0.
Content: code.
License: MIT.