Skip to content

Commit 09bd78f

Browse files
authored
Fix toString of draughts board (#670)
1 parent 0f0f4d0 commit 09bd78f

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/rl/draughts.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ class DraughtsBoard {
284284
if (j > 0) {
285285
buf += ' '
286286
}
287-
if (this._board[i][j] === RED) {
287+
if (this._board[i][j] & RED) {
288288
buf += 'x'
289-
} else if (this._board[i][j] === WHITE) {
289+
} else if (this._board[i][j] & WHITE) {
290290
buf += 'o'
291291
} else {
292292
buf += '-'
@@ -298,19 +298,13 @@ class DraughtsBoard {
298298
}
299299

300300
nextTurn(turn) {
301-
if (turn === WHITE) {
302-
return RED
303-
} else {
304-
return WHITE
305-
}
301+
return turn === WHITE ? RED : WHITE
306302
}
307303

308304
copy() {
309305
const cp = new DraughtsBoard(this._size, this._evaluator)
310306
for (let i = 0; i < this._size[0]; i++) {
311-
for (let j = 0; j < this._size[1]; j++) {
312-
cp._board[i][j] = this._board[i][j]
313-
}
307+
cp._board[i] = this._board[i].concat()
314308
}
315309
return cp
316310
}

0 commit comments

Comments
 (0)