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,omitempty,optional"` // 贴目,中国规则一般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 }