From 0b4535d6deebeac8c173930c7b0034321a5ecf49 Mon Sep 17 00:00:00 2001 From: ishii-norimi Date: Sat, 30 Sep 2023 11:14:00 +0900 Subject: [PATCH] Fix toString of draughts board --- lib/rl/draughts.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/rl/draughts.js b/lib/rl/draughts.js index 0ebb56361..e3ad515c7 100644 --- a/lib/rl/draughts.js +++ b/lib/rl/draughts.js @@ -284,9 +284,9 @@ class DraughtsBoard { if (j > 0) { buf += ' ' } - if (this._board[i][j] === RED) { + if (this._board[i][j] & RED) { buf += 'x' - } else if (this._board[i][j] === WHITE) { + } else if (this._board[i][j] & WHITE) { buf += 'o' } else { buf += '-' @@ -298,19 +298,13 @@ class DraughtsBoard { } nextTurn(turn) { - if (turn === WHITE) { - return RED - } else { - return WHITE - } + return turn === WHITE ? RED : WHITE } copy() { const cp = new DraughtsBoard(this._size, this._evaluator) for (let i = 0; i < this._size[0]; i++) { - for (let j = 0; j < this._size[1]; j++) { - cp._board[i][j] = this._board[i][j] - } + cp._board[i] = this._board[i].concat() } return cp }