Bishop Strategies

Details

Author:Mark
Rating:
Difficulty:Beginner
Date:3rd February 2021
Description:Basic strategies using bishops, how they can be used to dominate the board on long diagonals and paired with the queen.

Code

let steps = [];
let targetMove = "";

steps.push(function() {
    fromFen("rnbq1rk1/p4npp/1p2p3/2p2pN1/1bpP1P2/2N1P3/PP2B1PP/R1BQK2R w KQq - 0 1");
    info("Bishops work well on long diagonals.\
    <br>Play <b>Bf3</b> to continue;");

    targetMove = "Bf3";
});

steps.push(function() {
    info("Correct!\
    <br>We now control the center and threaten the rook!");
    showNextButton(true);
});

steps.push(function() {
    fromFen("r5rk/ppp2ppp/bq1p4/n2P4/2P5/2BB2P1/PP3P1P/R3QRK1 w Qq - 0 1");
    info("If bishops on diagonals are strong, then a queen and a bishop on the same diagonal is devastating.\
    <br>See if you can find checkmate in 4 moves");

    targetMove = "Qe4";
});

steps.push(function() {
    setTimeout(function() {
        performMove("f5");
        nextDelayed(true);
    }, 100);
});

steps.push(function() {
    targetMove = "Qxf5";
});

steps.push(function() {
    setTimeout(function() {
        performMove("Qxf2+");
        nextDelayed(true);
    }, 100);
});

steps.push(function() {
    targetMove = "Rxf2";
});

steps.push(function() {
    setTimeout(function() {
        performMove("b6");
        nextDelayed(true);
    }, 100);
});

steps.push(function() {
    targetMove = "Qxh7#";
});

onPieceClicked(function (squareName) {
    if (typeof targetMove == "string") {
        if (squareName == sourceOfSan(targetMove)) {
            return true;
        }
    } else if (Array.isArray(targetMove)) {
        for (let temp of targetMove) {
            if (squareName == sourceOfSan(temp)) {
                return true;
            }
        }
    } else {
        throw new Error();
    }
    if (targetMove == "") {
        return false;
    }

    if (squareName == sourceOfSan(targetMove)) {
        return true;
    }

    highlightSquareRed(squareName);
    return false;
});

onMoveAttempted(function (san) {
    if (typeof targetMove == "string") {
        if (san == targetMove) {
            setTimeout(next, 50);
            return true;
        }
    } else if (Array.isArray(targetMove)) {
        for (let temp of targetMove) {
            if (san == temp) {
                setTimeout(next, 50);
                return true;
            }
        }
    } else {
        throw new Error();
    }

    return false;
});

onNextClicked(function () {
    showNextButton(false);
    next();
});

function nextDelayed() {
    setTimeout(next, 400);
}

function next() {
    if (steps.length > 0) {
        //remove the first function from the array and call it
        steps.shift()();
    }
}

next();