We will have a slightly simpler version of .pgn notation. A description of .pgn
ID: 3626943 • Letter: W
Question
We will have a slightly simpler version of .pgn notation. A description of .pgn can be found here. We will have the following changes:The only tags we will use are Event, Site, Date, White, Black, Result.
There will always be some tags. In particular the players will always be there. However, it is not true that Event, Site and Date will always be there.
All files that we will use are guaranteed to have only one game in them.
None of our games will have alternative lines. This means that each game will only contain a single line of play.
None of our games will have any annotations. This means that we don't need to worry about seeing $ signs in the .pgn files.
None of our games will have any en passant captures.
Our .pgn files will not contain any comments.
All move indicators will be for white. That is, all moves will be denoted by "N. whmv blmv" where N is an integer, whmv is the notation for the white move, and blmv is the notation for the black move. The only exception to this will be if the game ends before blacks move. You will never see anything like "N... blmv".
You do not need to worry about incorrectly formatted files.
Things that you do have to worry about:
There will be checks, captures and checkmates.
There will be pawn promotions.
There will be moves where the piece that is moving is not perfectly specified by the final square and piece type.
A summary of .pgn notation
The first part of a .pgn file is tags. These are written in the format: [tag_name: "tag_information"]
Each tag is on a single line.
The tags occur in the order Event, Site, Date, White, Black, Result
Result is 1-0 for a white win, 0-1 for a black win, 1/2-1/2 for a draw.
Following the tags, the move notation starts.
Each turn has the format: N. whmv blmv
N is the turn number (starts at 1.), whmv is the move notatio for the white mv, and blmv is the notation for the black move
If the move results in a check, the mv ends in +, if it ends in checkmate, the mv ends in #
Kingside castling is indicated by O-O, queenside castling by O-O-O. Note that these are capital os and not 0s.
Generally a move is indicated by Amn, where A is the piece name, and mn is the square that the piece moves to in algebraic notation (for example a1).
pawn moves omit the A, rooks are denoted by R, bishops by B, knights by N, the king by K, the queen by Q.
Captures are denoted by Axmn. Here x represents the character x. For a pawn capture A is replaced with the column in which the pawn started. So a pawn capture from a2 to b3 would be axb3.
Pawn promotions are denoted by mn=A, where mn is the square on which the pawn is promoted, = is the equals sign, and A is the type of piece to which the pawn was promoted.
Sometimes the final square and piece type is not enough information to specify the moving piece. In this case we may additionally specify by adding the letter, number or letter and number combination in that order of preference. So Nge2 means the knight on the g column moves to e2, N3e3 means that the knight on the third row moves to e3 and Ng3e2 means the the knight on g3 moves to e3.
The movetext terminates with the result of the game.
What I need to solve is...
def board_state(chess_game, turn, white):
'''Return a two dimenstional list that represents the board state of the
.pgn file that is specified by the (string) chess_game). The board state
is the state after the move by the colour specified by the (bool) white
during (int) turn. If turn == 0, then the initial state of the board should
be returned. If turn == 1 and white == True the state after the first move
by white should be returned, while if white == False the state after the
first move by black should be returned.'''
return [[]]
Explanation / Answer
You should do your work yourself...
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.