go-chess-minimax, v1.1
Posted on

The library that implements a chess engine based on the minimax algorithm.
Implement the alpha-beta pruning and a tournament between different versions of the move searcher.
Change Log
- optimize move searching via the alpha-beta pruning;
- implement a tournament between the negamax algorithm and it with the alpha-beta pruning.
Features
- move searcher used the negamax algorithm;
- optimizations:
- searching termination:
- by a deep;
- by a time;
- position evaluation only by a material (based on an evaluation function of Claude Shannon);
- architecture features:
- easily extensible and composable architecture of searching;
- composable searching terminators.
Examples
chessminimax.AlphaBetaSearcher.SearchMove():
package main
import (
"fmt"
"log"
minimax "github.com/thewizardplusplus/go-chess-minimax"
"github.com/thewizardplusplus/go-chess-minimax/evaluators"
"github.com/thewizardplusplus/go-chess-minimax/terminators"
models "github.com/thewizardplusplus/go-chess-models"
"github.com/thewizardplusplus/go-chess-models/pieces"
)
func main() {
storage, err := models.ParseBoard("7K/8/7q/8/8/8/8/k7", pieces.NewPiece)
if err != nil {
log.Fatal(err)
}
var generator models.MoveGenerator
var evaluator evaluators.MaterialEvaluator
terminator := terminators.NewDeepTerminator(1)
searcher := minimax.NewAlphaBetaSearcher(generator, terminator, evaluator)
scoredMove, err :=
searcher.SearchMove(storage, models.White, 0, minimax.NewBounds())
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", scoredMove)
// Output: {Move:{Start:{File:7 Rank:7} Finish:{File:6 Rank:7}} Score:-9}
}
Benchmarks
chessminimax.AlphaBetaSearcher:
BenchmarkAlphaBetaSearcher_1Ply-8 1000 2059163 ns/op
BenchmarkAlphaBetaSearcher_2Ply-8 300 5603471 ns/op
BenchmarkAlphaBetaSearcher_3Ply-8 50 36132193 ns/op
Repository
Link: https://github.com/thewizardplusplus/go-chess-minimax/tree/v1.1.
Content: code.
License: MIT.
Screenshots
Tournament between negamax and alpha-beta algorithms
