I am trying to figure out an algorithm to extract the number of each piece that both black and white have from a PGN file.
Right now I have all of the moves tokenized(i.e. c("e4", "d6", "Nc3", "f5", "exf5", "Bxf5", "Qh5", "g6"...), but I'm not sure where to proceed next. So far I know that identifying the "x" characters is necessary, but I am not sure what to do as the notation only identifies the capture square, and not what type of piece is captured.