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

67 lines
2.2 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 req
import (
"encoding/json"
"git.noahlan.cn/noahlan/ntool/nsys/cmdn"
)
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 json.Marshal(ret)
}
var _ cmdn.ICommand = (*AnalQueryReq)(nil)
type AnalQueryReq 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 *AnalQueryReq) MessageID() string {
return r.ID
}
func (r *AnalQueryReq) AddMove(player, location string) {
r.Moves = append(r.Moves, Stone{Player: player, Location: location})
}
func (r *AnalQueryReq) AddInitialStone(player, location string) {
r.InitialStones = append(r.InitialStones, Stone{Player: player, Location: location})
}
var _ cmdn.ICommand = (*AnalQueryActionReq)(nil)
const (
AnalActionQueryVersion = "query_version"
AnalActionClearCache = "clear_cache"
AnalActionTerminate = "terminate"
AnalActionTerminateAll = "terminate_all"
)
type AnalQueryActionReq 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 *AnalQueryActionReq) MessageID() string {
return r.ID
}