X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=ef07742cf6ebbc3588c8b75684bd96ae07db4752;hb=c322a84434326dff1291a57e82dbd995817a5423;hp=d5849f3bfbd0a2af05378d05917b7403540468de;hpb=71ef1664983cd58db3c3bbfdf6cb7c362474e9a5;p=vchess.git diff --git a/client/src/base_rules.js b/client/src/base_rules.js index d5849f3b..ef07742c 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -467,7 +467,7 @@ export const ChessRules = class ChessRules { return { x: 8, y: 8 }; } - // Color of thing on suqare (i,j). 'undefined' if square is empty + // Color of thing on square (i,j). 'undefined' if square is empty getColor(i, j) { return this.board[i][j].charAt(0); } @@ -543,7 +543,7 @@ export const ChessRules = class ChessRules { //////////////////// // MOVES GENERATION - // All possible moves from selected square (assumption: color is OK) + // All possible moves from selected square getPotentialMovesFrom([x, y]) { switch (this.getPiece(x, y)) { case V.PAWN: @@ -1121,6 +1121,7 @@ export const ChessRules = class ChessRules { // Some variants may show a bigger moves list to the human (Switching), // thus the argument "computer" below (which is generally ignored) let moves1 = this.getAllValidMoves("computer"); + if (moves1.length == 0) //TODO: this situation should not happen return null; @@ -1209,7 +1210,7 @@ export const ChessRules = class ChessRules { return (color == "w" ? 1 : -1) * (b.eval - a.eval); }); } else return currentBest; - // console.log(moves1.map(m => { return [this.getNotation(m), m.eval]; })); + console.log(moves1.map(m => { return [this.getNotation(m), m.eval]; })); candidates = [0]; for (let j = 1; j < moves1.length && moves1[j].eval == moves1[0].eval; j++) @@ -1254,6 +1255,18 @@ export const ChessRules = class ChessRules { for (let j = 0; j < V.size.y; j++) { if (this.board[i][j] != V.EMPTY) { const sign = this.getColor(i, j) == "w" ? 1 : -1; + + +//TODO: debug in KnightRelay +if (isNaN(V.VALUES[this.getPiece(i, j)])) { + console.log(i + " " + j); + console.log(this.getPiece(i, j)); + console.log(this.board); + console.log("ajout " + sign + " * "+ V.VALUES[this.getPiece(i, j)]); + debugger; +} + + evaluation += sign * V.VALUES[this.getPiece(i, j)]; } }