Just because the board appears to your eyes as a two dimensional table
does not mean you are forced to store it as a table.
board coordinates as single text values.
Consider alternate ways to represent the game state internally.
Some might ease the coding considerably.
For example, you start the game with 32 pieces, 16 white and 16 black.
That could be a collection of 32 item lists, each describing a different attribute of that piece:
- its location, i.e. "d2" (""if off the board)
- its type, i.e. "P"
- its color, i.e. "W",
- its image (♙) or codepoint (U+2659) or html (♙),
That set of 32 pieces is fixed through the game, but the states of those pieces will change.
These 4 parallel lists would work well with the list index-of and select blocks,
for all your needs, in one dimension.
It would answer questions like:
- which piece is at d4? (Find the index in location of "d4". If > 0, then select type, color, image at that index.)
ABG