// Handle explosions
moves.forEach(m => {
+ // NOTE: if vanish.length==2 and appear.length==2, this is castle
if (m.vanish.length > 1 && m.appear.length <= 1) {
- //avoid castles
- // Explosion! OPTION (TODO?): drop moves which explode our king here
+ // Explosion! (TODO?: drop moves which explode our king here)
let steps = [
[-1, -1],
[-1, 0],
updateVariables(move) {
super.updateVariables(move);
if (move.appear.length == 0) {
- //capture
+ // Capture
const firstRank = { w: 7, b: 0 };
for (let c of ["w", "b"]) {
// Did we explode king of color c ? (TODO: remove move earlier)
const color = this.turn;
const kp = this.kingPos[color];
if (kp[0] < 0)
- //king disappeared
+ // King disappeared
return color == "w" ? "0-1" : "1-0";
if (this.atLeastOneMove())
- // game not over
return "*";
if (!this.isAttacked(kp, [V.GetOppCol(color)])) return "1/2";
return color == "w" ? "0-1" : "1-0"; //checkmate