Mate In Four
Details
Author: | Mark |
Rating: | |
Difficulty: | Beginner |
Date: | 6th December 2020 |
Description: | It's white's turn and they can achieve checkmate in a four moves. |
Code
//Please feel welcome to copy this code for your own creations.
fromFen("r1k2Br1/1pp2p1p/p4n2/5q2/8/Q6P/PPP3P1/3RR1K1 w - - 0 1");
info("It's white's turn, and they can win in four moves.<br>Can you find them?");
let steps = [{
square: "e1",
move: "Re8+",
counterMove: "Nxe8"
}, {
square: "d1",
move: "Rd8+",
counterMove: "Kxd8"
}, {
square: "a3",
move: "Qe7+",
counterMove: "Kc8"
}, {
square: "e7",
move: "Qxe8#",
counterMove: null
},
];
onPieceClicked(function(squareName) {
unhighlightAll();
if(squareName == steps[0].square) {
return true;
} else {
highlightSquareRed(squareName);
return false;
}
});
onMoveAttempted(function(san) {
if(san == steps[0].move) {
if(steps[0].counterMove != null) {
setTimeout(function() {
performMove(steps[0].counterMove);
steps.shift();
}, 500);
} else {
complete();
info(" ");
}
return true;
} else {
return false;
}
});