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/ngochess/katago/req.go

73 lines
2.3 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 katago
import "git.noahlan.cn/noahlan/ntool/njson"
type BaseMsg interface {
SetMessageId(id string)
MessageId() string
}
type Stone struct {
Player string // 玩家 "B" / "W"
Location string // "C4" GTP标准协议或 "CC" 行列协议
}
func (s Stone) MarshalJSON() ([]byte, error) {
ret := []string{s.Player, s.Location}
return njson.Marshal(ret)
}
type QueryReq struct {
Id string `json:"id"` // ID
Moves []Stone `json:"moves"` // moves
InitialStones []Stone `json:"initialStones,omitempty,optional"` // 初始化棋子(让子棋,棋谱等等)
Rules string `json:"rules"` // 规则, chinese / japanese / tromp-taylor .etc...
Komi float32 `json:"komi"` // 贴目中国规则一般7.5目
BoardXSize int64 `json:"boardXSize"` // 棋盘X大小
BoardYSize int64 `json:"boardYSize"` // 棋盘Y大小
AnalyzeTurns []int32 `json:"analyzeTurns,omitempty,optional"` // 需要分析的回合数与moves对应若不指定则分析最后一回合
InitialPlayer string `json:"initialPlayer,omitempty,optional"` // 指定第一手的玩家 "B" / "W"当moves为空时很有用
/// .etc...
}
func (r *QueryReq) SetMessageId(id string) {
r.Id = id
}
func (r *QueryReq) MessageId() string {
return r.Id
}
func (r *QueryReq) AddMove(player, location string) {
r.Moves = append(r.Moves, Stone{Player: player, Location: location})
}
func (r *QueryReq) AddInitialStone(player, location string) {
r.InitialStones = append(r.InitialStones, Stone{Player: player, Location: location})
}
const (
AnalActionQueryVersion = "query_version"
AnalActionClearCache = "clear_cache"
AnalActionTerminate = "terminate"
AnalActionTerminateAll = "terminate_all"
)
type QueryActionReq struct {
Id string `json:"id"` // ID
Action string `json:"action"` // 查询动作
// terminate
TerminateId string `json:"terminateId,omitempty,optional"`
// terminate | terminate_all
TurnNumbers []int32 `json:"turnNumbers,omitempty,optional"`
}
func (r *QueryActionReq) SetMessageId(id string) {
r.Id = id
}
func (r *QueryActionReq) MessageId() string {
return r.Id
}