• 3 Posts
  • 83 Comments
Joined 1 year ago
cake
Cake day: July 5th, 2023

help-circle











  • Ideally, all of these values should be represented in memory exactly the same way:

    That would make the game hard to play, since you’d have to think about where your move would end up since it won’t stay on the cell you click.

    I think you’re wanting to store them that way so that you can easily check for win conditions, maybe? But that’s the wrong approach. Store the cells as they appear to the player, in a 2d Array (or 1d Array with indexing math. That’s how I’d do it).

    Then you can take advantage of symmetries in your win condition code, if you like. But it really couldn’t be much simpler than counting the matching cells in each row, column, and diagonal. That’s just 8 groups of 3.