MoveResult - 成功時は新しいGameState、失敗時はMoveError
// 石を置く
const game = createGame(19);
const result = playMove(game, { type: "play", position: { x: 3, y: 3 } });
if (result.success) {
console.log(result.state.currentPlayer); // "white"
console.log(result.state.board[3][3]); // "black"
}
// パスする
const game = createGame(19);
const result = playMove(game, { type: "pass" });
if (result.success) {
console.log(result.state.currentPlayer); // "white"
console.log(result.state.moveCount); // 1
}
着手を実行し、新しいゲーム状態を返します。
囲碁の着手(石を置く、パス、投了)を実行します。 着手の有効性を検証し、盤面の状態を更新します。 着手には以下の種類があります:
play: 指定位置に石を置くpass: 手番をパスする(2連続パスで終局)resign: 投了する着手が無効な場合は、エラー情報を含むMoveResultを返します。 エラーの種類についてはMoveErrorを参照してください。