For this challenge we will use a 8×8 2D array to represent the positions of all the black and white pieces on the chessboard.
We will then use Python Turtle to draw the chessboard using the information stored within the 2D array.
Here is the Python code for our 8×8 2D array:
board = [["bR","bN","bB","bQ","bK","bB","bN","bR"], ["bP","bP","bP","bP","bP","bP","bP","bP"], [" "," "," "," "," "," "," "," "], [" "," "," "," "," "," "," "," "], [" "," "," "," "," "," "," "," "], [" "," "," "," "," "," "," "," "], ["wP","wP","wP","wP","wP","wP","wP","wP"], ["wR","wN","wB","wQ","wK","wB","wN","wR"]]
I this challenge you will have to make some changes to the board array to move some pieces on the board and solve five different “Checkmate in one move puzzles”. To do you will have to edit the code provided.
Here is an example of how to move on of the white pawn by two places:
board[6][3] = " " # Remove the white pawn on row 6, column 3 board[4][3] = "wP" # Reposition the white pawn to a new location: row 4, column 3
Checkmate in one move
The code provided below has 5 different puzzles where it is white’s turn to win the game in just one move. Edit the code to implement these moves.