

Amit’s Thoughts on Grids - kayral
http://www-cs-students.stanford.edu/~amitp/game-programming/grids/

======
ghshephard
Is it it just me, or is the font, clarity of writing, color combination and
diagram presentation extraordinarily clean on that site. There is a small bug
with word wrapping beside some diagrams on my iPad, but everything else pulled
me into about 25 minutes of awesome reading on grids.

~~~
headbiznatch
I agree that it is above average. Subtle little touches (like the highlight
gradients and thoughtfully padded section texts) really add to the
readability. And, of course, the content. It's a good blog in general -
unpretentious and informative.

------
dripton
I don't like the way he does coordinates for triangles and hexagons, having
hexes with the same y-coordinate slope up to the right. I prefer having hexes
with the same y-coordinate stay as close to horizontal as possible, meaning
that even hexes will be shifted up or down by half a hex compared to odd
hexes.

I found that keeping the hex coordinates as close as possible to the square
coordinates that your GUI library uses makes things easier.

------
jamesflorentino
I'm not exactly sure what's new on this page, but his articles about game
design and path finding were huge help to me when I was starting out in game
development.

------
dxbydt
Regarding implementation, he says "All the algorithms are straightforward. How
might you implement them? You’ll first want to choose data structures for each
of the three coordinate systems. I recommend keeping it very simple and
transparent. All the coordinate systems I listed have an integer u and an
integer v, and some of them have an annotation like L or W ; in Java use a
class with public fields; The next step is to implement the algorithms you
need. The simplest thing to do is to write functions (or methods) that take A
and return a list of B. "

Atleast in Java ( and therefore in Scala, Clojure etc), the data-structure of
choice is a general path, and all of those algorithms have built-in
implementations, mostly on Path2D or other concretes. Also, instead of dealing
with squares, hexagons & triangles separately... a square is just 2 isosceles
triangles, and a hex is 6 equilateral triangles. So if you have a Triangle2D
class extending Path2D, you get all of the algorithms and the you can handle
all 3 face types. The transformation between cooordinate systems is handled by
affine transforms

Path2D:
[http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Path2...](http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Path2D.html)

AffineTransform:
[http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Affin...](http://docs.oracle.com/javase/6/docs/api/java/awt/geom/AffineTransform.html)

------
shanelja
Love it, I have had to design 2d and 3d grids before now and the information
you gave on faces for polygonal grids has been really helpful and will help me
to break the square mold, so to speak.

------
ebiester
For some background, Amit Patel is likely best known for an old BBS game
called Solar Realms Elite.

~~~
psykotic
I'd say he's likely best known for this very website on game programming. It's
been around for a long time by Internet reckoning. In the olden days, it was
where you went to learn about A* path finding for games.

~~~
ido
I remember using it ~10 ago.

------
alpb
That's a very nice talk especially if you are interested in 3D mobile games
development (like I was once in the past). I wish I'd knew all these before.
Thanks for the post.

