npm i go-sim -S
There are many more undocumented functions, but they will probably be less useful for creating a UI around the simulation.
Go is played in a series of phases. A new game starts in the Play phase. While in each phase, certain functions will be available.
// play at the designated (row, col) // the turn automatically advances to the next player // any invalid move is ignored game.play(2, 3) // pass the current turn to the next player // game advances to the Mark phase on consecutive passes game.pass()
// mark the cluster of pieces attached to (row, col) as dead game.mark(2, 3) // propose the marked clusters to the next player // next player may mark/unmark clusters and counter propose game.propose() // reject the proposal and return to the Play phase to resolve disputes game.reject() // accept the proposal and advance to the End phase game.accept()
// retrieve the final calculated score // komi is included at 6.5 game.score