Introduction to e4,e5 openings

Details

Author: Mark
Rating:
Difficulty: Beginner
Date: 6th December 2020
Description: Introduction to openings that start with e4, e5. Covers the Petrov Defence, Scotch Game and Italian Game.

Code

var targetSquare = "";
onPieceClicked(function(squareName) {
    if(squareName == targetSquare) {
        return true;
    } else {
        highlightSquareRed(squareName);
        return false;
    }
});

var steps = [];
steps.push(function() {
    info("e4 is the most highly regarded chess opening of all time. \
        It: <ul> \
        <li>controls two center squares</li> \
        <li>allows the bishop and queen to move</li> \
        </ul> \
        Move the e pawn to e4 to continue.");
    
    targetSquare = "e2";

    onMoveAttempted(function(san) {
       if(san == "e4") {
           setTimeout(function() {
                info("Correct!, click next to continue.");
                showNextButton(true);
           }, 250);
       } else {
           return false;
       }
    });
});

steps.push(function() {
    blackAtTop(false);
    
    info("Now let's play as black when white has opened with e4. \
        Black can mimic this move by playing e5. \
        It: <ul> \
        <li>Also controls two center squares</li> \
        <li>allows the bishop and queen to move</li> \
        <li>prevents white from playing d4, and controlling four squares in the center</li> \
        </ul> \
        Move the e pawn to e5 to continue.");
        
    onMoveAttempted(function(san) {
       if(san == "e5") {
           setTimeout(function() {
                info("Correct!, click next to continue.");
                showNextButton(true);
           }, 250);
           return true;
       } else {
           return false;
       }
    });
    
    targetSquare = "e7";
});

steps.push(function() {
   info("This forms the basis of many chess openings, we will cover: \
    <ul> \
    <li>The Petrov Defense</li> \
    <li>The Scotch Game</li> \
    <li>The Italian Game</li> \
    </ul>");

    showNextButton(true);
});

steps.push(function() {
    blackAtTop(true);
   info("The Petrov defense continues with white playing Nf3, black mirrors this by playing Nf6. \
   <br><br> Move the knight to f3 to continue.");
   
   onMoveAttempted(function(san) {
       if(san == "Nf3") {
           setTimeout(function() {
                performMove("Nf6");
                setTimeout(function() {
                    info("Let's now play from here as black and see a devastating but common mistake.");
                    showNextButton(true);
                }, 250);
           }, 250);
       } else {
           return false;
       }
    });
    
    targetSquare = "g1";
});

steps.push(function() {
    blackAtTop(false);
    
    info("White has taken our e5 pawn, copy this by playing Nxe4.");
    setTimeout(function() {
        performMove("Nxe5");
    }, 250);
    
    onMoveAttempted(function(san) {
       if(san == "Nxe4") {
           setTimeout(next, 10);
           return true;
       } else {
           return false;
       }
    });
    
    targetSquare = "f6";
});

steps.push(function() {
    info("The knight is under attack, move it to the safety of f6.");
    
    setTimeout(function() {
        performMove("Qe2");
   }, 250);
   
   onMoveAttempted(function(san) {
       if(san == "Nf6") {
            setTimeout(next, 10);
            return true;
       }
       
       return false;
    });
    
    targetSquare = "e4";
});

steps.push(function() {
    info("Now our king is under attack, and we lose our queen!");
    setTimeout(function() {
        performMove("Nc6+");
        highlightSquareRed("e8");
        highlightSquareRed("d8");
  
        showNextButton(true);
   }, 250);
});

steps.push(function() {
   fromFen("rnbqkb1r/pppp1ppp/5n2/4N3/4P3/8/PPPP1PPP/RNBQKB1R w KQkq - 0 1");
   whitesTurn(false);
   
   info("Instead of Nxe4, try d6.");
   
   onMoveAttempted(function(san) {
       if(san == "d6") {
           setTimeout(next, 10);
           return true;
       } else {
           return false;
       }
    });
    
    targetSquare = "d7";
});

steps.push(function() {
    info("White moves his knight back to safety, and we are free to play Nxe4.");
    setTimeout(function() {
        performMove("Nf3");
   }, 250);
   
   onMoveAttempted(function(san) {
       if(san == "Nxe4") {
           setTimeout(next, 10);
           return true;
       } else {
           return false;
       }
    });
    
    targetSquare = "f6";
});

steps.push(function() {
    setTimeout(function() {
        info("This finishes our analysis of the Petrov defense. \
        Click next to continue.");
        showNextButton(true);
    }, 10);
});

steps.push(function() {
    fromFen("rnbqkbnr/pppp1ppp/8/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 0 1");
    blackAtTop(false);
    whitesTurn(false);
    
    info("The Scotch Game continues with black moving their knight to protect their pawn. \
    <br>Play Nc6 to continue.");

    targetSquare = "b8";

    onMoveAttempted(function(san) {
        if(san == "Nc6") {
            setTimeout(function() {
                info("Correct!, click next to continue.");
                showNextButton(true);
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    blackAtTop(true);
    whitesTurn(true);
    info("White can play d4, which opens up their bishop and puts pressure on e5. \
    <br> Play d4 to continue.");

    targetSquare = "d2";
    
    onMoveAttempted(function(san) {
        if(san == "d4") {
            setTimeout(function() {
                info("Correct!, click next to continue.");
                showNextButton(true);
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    blackAtTop(false);
    whitesTurn(false);
    info("Black can take this pawn to remove the threat. \
    <br> Play exd4 to continue.");
    
    targetSquare = "e5";
    
    onMoveAttempted(function(san) {
        if(san == "exd4") {
            setTimeout(function() {
                info("Correct!, click next to continue.");
                showNextButton(true);
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    blackAtTop(true);
    whitesTurn(true);
    info("White is free to take blacks pawn and centralize his knight. \
    <br> Play Nxd4 to continue.");
    
    targetSquare = "f3";
    
    onMoveAttempted(function(san) {
        if(san == "Nxd4") {
            setTimeout(function() {
                next();
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    info("From here a number of options are possible, therefore we will end our analysis of the Scotch Game.");
    showNextButton(true);
});

steps.push(function() {
    fromFen("r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 0 1");
    blackAtTop(true);
    whitesTurn(true);

    info("The Italian Game is identical to the Scotch Game for the first two moves. \
    <br>However white plays bc4 instead of d4. This: \
    <ul> \
    <li>Opens up white to castle on their next turn</li> \
    <li>Prevents black from playing d5</li> \
    <li>Attacks the f7 square</li> \
    </ul> \
    Play bc4 to continue.");

    targetSquare = "f1";
    onMoveAttempted(function(san) {
        if(san == "Bc4") {
            setTimeout(function() {
                info("Correct!, click next to continue.");
                showNextButton(true);
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    blackAtTop(false);
    info("Black has two options here: \
    <ul> \
    <li>Mimic with Bc5</li> \
    <li>Nf6</li> \
    </ul>");

    showNextButton(true);
});

steps.push(function() {
    blackAtTop(false);
    info("Play Bc5 to continue");

    targetSquare = "f8";
    onMoveAttempted(function(san) {
        if(san == "Bc5") {
            setTimeout(function() {
                info("Correct! \
                <br>White has 3 popular responses: \
                <ul> \
                <li>c3 (Giuoco Piano)</li> \
                <li>b4 (Evans Gambit)</li> \
                <li>0-0</li> \
                </ul> \
                <br>Next let's see what happens if black plays Nf6 instead.");
                showNextButton(true);
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    fromFen("r1bqkbnr/pppp1ppp/2n5/4p3/2B1P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 0 1");
    blackAtTop(false);
    whitesTurn(false);
    info("Play Nf6 to continue");

    targetSquare = "g8";
    onMoveAttempted(function(san) {
        if(san == "Nf6") {
            setTimeout(function() {
                info("Correct! \
                <br>This is called the \"two knights defense\".");
                showNextButton(true);
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    info("White moves his knight to threaten f7, which would fork the queen and rook \
    <br>Play d5 to block the bishop");
    setTimeout(function() {
        performMove("Ng5");
    });

    targetSquare = "d7";
    onMoveAttempted(function(san) {
        if(san == "d5") {
            setTimeout(function() {
                next();
           }, 250);
            return true;
        } else {
            return false;
        }
     });
});

steps.push(function() {
    info("White now takes the pawn, black can follow up with either:\
    <ul>\
    <li>Na5</li>\
    <li>Nxd5</li>\
    </ul>");

    performMove("exd5");
    showNextButton(true);
});

steps.push(function() {
    info("This ends our lesson on e4-e5 openings.");
    complete();
})

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

function next() {
    if(steps.length > 0) {
        steps.shift()();
    }
}

next();