mochi/main.go

71 lines
1.2 KiB
Go

/*
MOCHI - MinOr CHess engIne
(C) 2022-2023 Chris Mair <chris@1006.org>
see LICENSE for license information
*/
package main
import (
"fmt"
"mochi/test"
"mochi/uci"
"os"
"strconv"
)
func main() {
if len(os.Args) == 2 && os.Args[1] == "-v" {
fmt.Println(uci.GetMOCHIDetailedName())
return
}
fmt.Printf("%s by %s (see LICENSE file)\n", uci.GetMOCHIName(), uci.GetMOCHIAuthor())
if len(os.Args) == 1 {
// no args
// -> go into UCI mode
uci.Parse()
fmt.Println("bye")
} else if len(os.Args) == 4 && os.Args[1] == "perft" && os.Args[2] == "cpw" {
// perft cpw {maxDepth}
// -> compute PERFT on CPW test positions
var maxDepth int
var err error
maxDepth, err = strconv.Atoi(os.Args[3])
if err == nil {
test.TestCPWPositions(maxDepth)
}
} else if len(os.Args) == 5 && os.Args[1] == "perft" && os.Args[2] == "fen" {
// perft fen {fen} {maxDepth}
// -> compute PERFT from given position
var fen string = os.Args[3]
var maxDepth int
var err error
maxDepth, err = strconv.Atoi(os.Args[4])
if err == nil {
test.TestPosition(fen, maxDepth)
}
} else {
// error
fmt.Printf("cannot understand args\n")
}
}