super.updateVariables(move);
if (move.vanish.length >= 2 && move.vanish[1].p == V.KING)
{
- // We took opponent king !
+ // We took opponent king ! (because if castle vanish[1] is a rook)
this.kingPos[this.turn] = [-1,-1];
}
- // Update moves for both colors:
+ // Update lights for both colors:
this.updateEnlightened();
}
}
}
- // Update moves for both colors:
+ // Update lights for both colors:
this.updateEnlightened();
}
const color = this.turn;
const oppCol = V.GetOppCol(color);
const pawnShift = (color == "w" ? -1 : 1);
- const kp = this.kingPos[color];
// Do not cheat: the current enlightment is all we can see
const myLight = JSON.parse(JSON.stringify(this.enlightened[color]));
// Can a slider on (i,j) apparently take my king?
// NOTE: inaccurate because assume yes if some squares are shadowed
const sliderTake = ([i,j], piece) => {
+ const kp = this.kingPos[color];
let step = undefined;
if (piece == V.BISHOP)
{
// Check for obstacles
let obstacle = false;
for (
- let x=kp[0]+step[0], y=kp[1]+step[1];
- x != i && y != j;
- x += step[0], y+= step[1])
- {
+ let x=kp[0]+step[0], y=kp[1]+step[1];
+ x != i && y != j;
+ x += step[0], y += step[1])
+ {
if (myLight[x][y] && this.board[x][y] != V.EMPTY)
{
obstacle = true;
// Do I see something which can take my king ?
const kingThreats = () => {
+ const kp = this.kingPos[color];
for (let i=0; i<V.size.x; i++)
{
for (let j=0; j<V.size.y; j++)
move.eval = -maxeval;
}
this.undo(move);
- if (!!move.eval)
+
+ if (!!move.eval)
continue;
move.eval = 0; //a priori...