From: Dylan Lloyd Date: Tue, 16 Jun 2015 22:53:13 +0000 (-0700) Subject: fix full board shortcircuit X-Git-Url: https://disinclined.org/git/?a=commitdiff_plain;h=e51172ddcde05238924b6929937f68fb98f6dd15;p=minimax.git fix full board shortcircuit --- diff --git a/ai.js b/ai.js index 782d04c..92cd6f8 100644 --- a/ai.js +++ b/ai.js @@ -166,11 +166,6 @@ $(document).ready(function(){ tictactoe.cells[i][iii].play(horizontalPlayer, 'green'); eog = horizontalPlayer; } - if (state[i][ii] !== 0) { - fullCells++; - if (fullCells == size*size) - eog = 'tie'; - } } } for (var i = 0; i < size && !eog; i++) { @@ -211,10 +206,13 @@ $(document).ready(function(){ if (antiDiagonalTally == size) { eog = antiDiagonalPlayer; if (paint) - for (var i = 0; i < size; i++) - tictactoe.cells[i][(size-1)-i].play(eog, 'green'); + for (var iii = 0; iii < size; iii++) + tictactoe.cells[iii][(size-1)-iii].play(eog, 'green'); eog = antiDiagonalPlayer; } + if (state[i][ii] !== 0) + if (!eog && ++fullCells == size*size) + eog = 'tie'; } } if (eog && paint) {