What would be a good data structure to represent the status of the game Dots and Boxes?
I came up with using 2 matrices of boolean, for horizontal and vertical lines, but maybe there’s a more elegant way of doing this (and the operations: add line, check line, check square).
Using a pair of two-dimensional arrays of booleans called
linesXandlinesYmakes sense to me. Each array would have one more row/column than the total number of squares on the board in that given X/Y direction. Here’s a code sample of check square with that solution: