cheeplay

chess PGN replay in the terminal
git clone git://git.alexkarle.com.com/cheeplay
Log | Files | Refs | README | LICENSE

commit af74637ad8fed9a3e7b4d1a72e3014d01cd23290 (patch)
parent 676eb183016517e0ebf4e11ab530c13172b68604
Author: Alex Karle <alex@studio.com>
Date:   Mon, 30 May 2022 14:23:21 -0400

Add Go implementation

Diffstat:
Ago/cheeplay.go | 30++++++++++++++++++++++++++++++
Ago/go.mod | 5+++++
Ago/go.sum | 3+++
3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/go/cheeplay.go b/go/cheeplay.go @@ -0,0 +1,30 @@ +package main + +import ( + "os" + "fmt" + "github.com/notnil/chess" +) + +func main() { + fmt.Println("Hello World") + f, err := os.Open("examples/Byrne_vs_Fischer_1956.pgn") + if err != nil { + panic(err) + } + defer f.Close() + + pgn, err := chess.PGN(f) + if err != nil { + panic(err) + } + replay := chess.NewGame() + game := chess.NewGame(pgn) + for _, mh := range game.MoveHistory() { + fmt.Println(replay.Position().Board().Draw()) + replay.Move(mh.Move) + fmt.Println(mh.Move) + + } + fmt.Println(replay.Position().Board().Draw()) +} diff --git a/go/go.mod b/go/go.mod @@ -0,0 +1,5 @@ +module git.sr.ht/~akarle/cheeplay + +go 1.18 + +require github.com/notnil/chess v1.8.0 diff --git a/go/go.sum b/go/go.sum @@ -0,0 +1,3 @@ +github.com/ajstarks/svgo v0.0.0-20200320125537-f189e35d30ca/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= +github.com/notnil/chess v1.8.0 h1:wU50vrPpH3kiT0WRC/6EN9kJpb7EBxFLCRf05TwXys8= +github.com/notnil/chess v1.8.0/go.mod h1:cRuJUIBFq9Xki05TWHJxHYkC+fFpq45IWwk94DdlCrA=