From dfa1c9a5e5c5ed75decca4042c2fa567ab7c0edf Mon Sep 17 00:00:00 2001 From: yukirij Date: Tue, 20 Aug 2024 19:12:19 -0700 Subject: [PATCH] Fix checkmate detection. --- www/js/game.js | 6 ++++-- www/js/interface.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/www/js/game.js b/www/js/game.js index d62b098..27daf23 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -263,6 +263,8 @@ GAME.Game = class { this.state.check = 0; this.state.checkmate = false; + let player = this.turn & 1; + // Determine threaten, check, and blocking for each piece let checking_pieces = 0; for(let piece of this.board.pieces) { @@ -316,8 +318,8 @@ GAME.Game = class { } // Search for valid pool placements. - for(let i = 0; i < this.pools[0].length; ++i) { - for(let move of this.placement_tiles(i, (this.turn & 1))) { + for(let i = 0; i < this.pools[player].pieces.length; ++i) { + for(let move of this.placement_tiles(i, player)) { if(move.valid) { moves += 1; } } } diff --git a/www/js/interface.js b/www/js/interface.js index a6500bb..ea56834 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -1085,7 +1085,7 @@ const INTERFACE = { // Select random from ties. let selection = 0; for(let i = 1; i < moves.length; ++i) { - if(moves[i].score + 6 >= moves[i-1].score) { + if(moves[i].score + 5 >= moves[i-1].score) { selection++; } else { break;