You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ntool-biz/nkatago/test/main.go

76 lines
1.5 KiB
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package main
import (
"fmt"
"git.noahlan.cn/noahlan/ntool-biz/nkatago"
"git.noahlan.cn/noahlan/ntool-biz/nkatago/req"
"git.noahlan.cn/noahlan/ntool-biz/nkatago/resp"
"sync"
)
func testGTPEngine() {
engine, err := nkatago.NewGtpEngine(".\\run.bat")
if err != nil {
panic(err)
}
r, err := engine.BoardSize(1)
if err != nil {
panic(err)
}
fmt.Println(r)
}
func testAnalEngine() {
eng, err := nkatago.NewAnalysisEngine(".\\run_analysis.bat")
if err != nil {
panic(err)
}
var wg sync.WaitGroup
wg.Add(1)
err = eng.QueryVersion(func(versionResp *resp.AnalQueryVersionResp) {
fmt.Println(fmt.Sprintf("查询到版本git_hash:%s version:%s", versionResp.GitHash, versionResp.Version))
wg.Done()
})
if err != nil {
panic(err)
}
queryReq := &req.AnalQueryReq{
Rules: "chinese",
Komi: 6.5,
BoardXSize: 9,
BoardYSize: 9,
AnalyzeTurns: []int32{2},
}
queryReq.AddInitialStone("B", "A1")
queryReq.AddInitialStone("B", "A2")
queryReq.AddMove("W", "B3")
queryReq.AddMove("B", "C5")
wg.Add(1)
err = eng.Query(queryReq, func(queryResp *resp.AnalQueryResp) {
moveInfo := queryResp.MoveInfos[0]
fmt.Println(fmt.Sprintf("当前玩家:%s, 建议移动:%s, 此步移动的建议后续: %v, 胜率:%f, 直觉优先级:%d 预测平均分: %f",
queryResp.RootInfo.CurrentPlayer,
moveInfo.Move,
moveInfo.PV,
moveInfo.WinRate,
moveInfo.Order,
moveInfo.ScoreMean,
))
wg.Done()
})
wg.Wait()
}
func main() {
testGTPEngine()
//testAnalEngine()
}