Back in the middle ages, there were several different renditions of pawn promotion. Originally, the pawn would promote to the queen piece, but back then the queen could only move one space, like the king. Then there was the rule that the pawn could promote only to a captured piece. So if there were no captured pieces, the pawn would sit there on the end row until one was captured, which would immediately replace the pawn.

Perhaps the most interesting rule, though, was that of the pawn being promoted to the piece on which it’s rank was. E.g, the queen’s bishop’s pawn (c2) would promote to a bishop, a knights pawn a knight, and a king or queens pawn, to that of a queen. This would definitely change the face of a chess match as we know it!

The two player functionality of my chess app, in pass and play mode, is getting closer and closer to completion! Today I had a few minutes and I still had several obstacles to fix, so I decided to tackle one of them.

if (myMove.contains("P48")||myMove.contains("P49")||myMove.contains("P50")||
        myMove.contains("P51")||myMove.contains("P52")||myMove.contains("P53")||
        myMove.contains("P54")||myMove.contains("P55")) {
    if ( minusNum == 8) {
        myMove = "Pu" + promoteToW + played + String.valueOf(theBoard[number]);
    } else if (minusNum == 9) {
        myMove = "Pr" + promoteToW + played + String.valueOf(theBoard[number]);
    } else if (minusNum == 7) {
        myMove = "Pl" + promoteToW + played + String.valueOf(theBoard[number]);
    }
}

if (myMove.contains("p08")||myMove.contains("p09")||myMove.contains("p10")||
        myMove.contains("p11")||myMove.contains("p12")||myMove.contains("p13")||
        myMove.contains("p14")||myMove.contains("p15")) {
    if ( plusNum == 8) {
        myMove = "pu" + getPromoteToB + played + String.valueOf(theBoard[number]);
    } else if (plusNum == 7) {
        myMove = "pr" + getPromoteToB + played + String.valueOf(theBoard[number]);
    } else if (plusNum == 9) {
        myMove = "pl" + getPromoteToB + played + String.valueOf(theBoard[number]);
    }
}

pawn_promote

Essentially, I just added a check to see if it was a pawn promotion when you choose what you are trying to do. Fortunately, there is only one row for black, and one row for white where this maneuver can be done. Be sure to check out the commit for the comparison of the changes.

Linux – keep it simple.

Leave a Reply

Your email address will not be published.