Documentation
¶
Index ¶
- Constants
- Variables
- func GetTimeMs() int64
- func MoveToString(move Move) string
- func UnmarshalAction(bytes []byte) (*inputEvent, error)
- func UpdateClient(c *Client, update Output)
- type Bitboard
- type Board
- type Client
- type Engine
- type Game
- type Manager
- func (m *Manager) GetGame(gameID string) *Game
- func (m *Manager) GetUserGameID(userID string) string
- func (m *Manager) HandleGame(w http.ResponseWriter, r *http.Request)
- func (m *Manager) HandlePlay(w http.ResponseWriter, r *http.Request)
- func (m *Manager) MakeGame(whiteID, blackID string)
- func (m *Manager) RemoveGame(game *Game, winnerID string)
- func (m *Manager) UpdateRating(winnerID, loserID string, isDraw bool)
- type Move
- type Moves
- type Output
- type Searcher
- type Side
- type TimeController
Constants ¶
View Source
const ( PAWN = 0 KNIGHT = 1 BISHOP = 2 ROOK = 3 QUEEN = 4 KING = 5 )
piece types
View Source
const ( INFINITY = 50000 MATE_VALUE = 49000 MATE_SCORE = 48000 MAX_PLY = 64 )
View Source
const ( P piece = iota N B R Q K )
encode pieces
Variables ¶
View Source
var ( UCI = []byte("uci") ISREADY = []byte("isready") UCINEWGAME = []byte("ucinewgame") POSITION = []byte("position") GO = []byte("go") STARTPOS = []byte("startpos") FEN = []byte("fen") STARTPOS_FEN = []byte(start_position) MOVES = []byte("moves") DEPTH = []byte("depth") WINC = []byte("winc") BINC = []byte("binc") WTIME = []byte("wtime") BTIME = []byte("btime") MOVETIME = []byte("movetime") MOVESTOGO = []byte("movestogo") )
View Source
var StringToSquare = map[string]int{
"a1": 56, "a2": 48, "a3": 40, "a4": 32, "a5": 24, "a6": 16, "a7": 8, "a8": 0,
"b1": 57, "b2": 49, "b3": 41, "b4": 33, "b5": 25, "b6": 17, "b7": 9, "b8": 1,
"c1": 58, "c2": 50, "c3": 42, "c4": 34, "c5": 26, "c6": 18, "c7": 10, "c8": 2,
"d1": 59, "d2": 51, "d3": 43, "d4": 35, "d5": 27, "d6": 19, "d7": 11, "d8": 3,
"e1": 60, "e2": 52, "e3": 44, "e4": 36, "e5": 28, "e6": 20, "e7": 12, "e8": 4,
"f1": 61, "f2": 53, "f3": 45, "f4": 37, "f5": 29, "f6": 21, "f7": 13, "f8": 5,
"g1": 62, "g2": 54, "g3": 46, "g4": 38, "g5": 30, "g6": 22, "g7": 14, "g8": 6,
"h1": 63, "h2": 55, "h3": 47, "h4": 39, "h5": 31, "h6": 23, "h7": 15, "h8": 7,
}
Functions ¶
func UnmarshalAction ¶
func UpdateClient ¶
Types ¶
type Bitboard ¶
type Bitboard uint64
func (Bitboard) GetLs1bIndex ¶
get least significant 1st bit index
type Board ¶
type Board struct {
Bitboards [12]Bitboard
Occupancies [3]Bitboard
Side Side
Enpassant square
Castle castle
HashKey Bitboard
Fifty int
}
func (*Board) GetLegalMoves ¶
type Client ¶
type Client struct {
Side Side
// contains filtered or unexported fields
}
func (*Client) ListenInput ¶
func (c *Client) ListenInput()
func (*Client) ListenOutput ¶
func (c *Client) ListenOutput()
type Engine ¶
type Engine struct {
Board
TimeController
Searcher
RepetitionTable []Bitboard
// contains filtered or unexported fields
}
func (*Engine) ReceiveCommand ¶
type Game ¶
type Game struct {
Manager *Manager
GameID string
Moves pq.Int32Array
Messages []models.Message
// contains filtered or unexported fields
}
func (*Game) InputEvent ¶
func (g *Game) InputEvent(ie *inputEvent)
type Manager ¶
type Manager struct {
// Lock when reading or writing
sync.RWMutex
Storage db.Storage
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) GetUserGameID ¶
func (*Manager) HandleGame ¶
func (m *Manager) HandleGame(w http.ResponseWriter, r *http.Request)
func (*Manager) HandlePlay ¶
func (m *Manager) HandlePlay(w http.ResponseWriter, r *http.Request)
func (*Manager) RemoveGame ¶
func (*Manager) UpdateRating ¶
type Moves ¶
type Moves struct {
// contains filtered or unexported fields
}
func (*Moves) FilterSelected ¶
type TimeController ¶
type TimeController struct {
// exit from engine flag
Quit int
// UCI "movestogo" command moves counter
MovesToGo int
// UCI "movetime" command time counter
MoveTime int
// UCI "time" command holder (ms)
Time int
// UCI "inc" command's time increment holder
Inc int
// UCI "starttime" command time holder
StartTime int64
// UCI "stoptime" command time holder
StopTime int64
// variable to flag time control availability
Timeset int
// variable to flag when the time is up
Stopped int
}
func NewTimeController ¶
func NewTimeController() TimeController
Click to show internal directories.
Click to hide internal directories.