go-atari-models, v1.7
Posted on

The library that implements checking and generating of Atari Go moves.
Encoding of positions and boards in Smart Game Format.
Change Log
- encoding in Smart Game Format:
- parsing:
- of a stone color;
- of a coordinate;
- of a position;
- of a board size;
- of a move;
- of a board;
- serialization:
- of a stone color;
- of a coordinate;
- of a position.
- parsing:
Features
- representing the board as an associative array of stones with their positions as keys;
- immutable applicating moves to the board via copying the latter;
- checkings of moves:
- taking into account self-capture;
- generating of moves via filtering from all possible ones:
- pseudolegal moves;
- legal moves (with additional checking for captures);
- encoding in Smart Game Format:
- parsing:
- of a stone color;
- of a coordinate;
- of a position;
- of a board size;
- of a move;
- of a board;
- serialization:
- of a stone color;
- of a coordinate;
- of a position.
- parsing:
Examples
sgf.DecodeBoard():
package main
import (
"fmt"
models "github.com/thewizardplusplus/go-atari-models"
"github.com/thewizardplusplus/go-atari-models/encoding/sgf"
)
func main() {
board, _ := sgf.DecodeBoard("(;FF[4]SZ[7:9]GN[test];B[aa](;W[gi]N[test]))")
var moves []models.Move
for _, point := range board.Size().Points() {
if color, ok := board.Stone(point); ok {
moves = append(moves, models.Move{Color: color, Point: point})
}
}
fmt.Printf("%+v\n", board.Size())
fmt.Printf("%+v\n", moves)
// Output:
// {Width:7 Height:9}
// [{Color:0 Point:{Column:0 Row:0}} {Color:1 Point:{Column:6 Row:8}}]
}
Repository
Link: https://github.com/thewizardplusplus/go-atari-models/tree/v1.7.
Content: code.
License: MIT.