Grid definition, shape #2467
Closed
andretchen0
started this conversation in
Ideas
Replies: 1 comment
-
|
Considered this type of stuff big time back in the day. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The way grids are defined and implemented requires more care than would otherwise be necessary. They look like this:
But this definition is a "lie" in the sense that not every row has
numColshexes. Only "full" rows do. Because the resulting grid currently looks like this:Every
2*mrow hasnumColshexes. Every2*m+1havenumCols-1. Or vice versa, depending onisFirstRowFull.A more straight-forward definition might be this, courtesy of the great Hex resource compiled at Red Blob Games:
With this result:
All rows have the same number of hexes.
That makes storage simpler:
itox, yand back with straight forward modulo/division or addition/multiplication.It also makes bounds checking simpler:
x < numCols? It's in bounds. Otherwise it's out of bounds.It makes the code more understandable:
numColsis the number of columns. Just like it says on the tin.I'm taking a wild guess, but is the reason for the short/long rows to make the grid symmetrical and "fair" for each player? If that's the case, then this setup is one of many symmetrical start states, with a constant number of rows.
So ...
I'd like to switch to use
numColsfor all rows. Thoughts?Beta Was this translation helpful? Give feedback.
All reactions