I want to read a PGN file and play those moves on my chess application. For example, the PGN structure that I have to read looks like this:
1. e4 {[%clk 0:01:00]} 1... g6 {[%clk 0:01:00]}
2. e5 {[%clk 0:00:59.2]} 2... Bg7 {[%clk 0:00:59.9]}
3. f4 {[%clk 0:00:58.4]} 3... d6 {[%clk 0:00:59.8]}
So the first move is e4
by white. As human I can look at a chess board and tell that the only piece that can go to e4
is the pawn currently on e2
.
But how do you know this when reading a PGN file?
I need to feed my chess applications moves like e2-e4
. As in, what ever piece is on e2
, move it to e4
. (By the notation I can at least tell that the piece is a pawn)
So basically I need to know the starting position of the piece e2
, and on what square it wants to land, e4
.
Is there a way to get this information from a PGN file? The only way I can think of is brute forcing to identify the only piece that can move to the location.