TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Everything you ever wanted to know about hexagonal grids

462 pointsby fivedogitover 10 years ago

17 comments

acidburnNSAover 10 years ago
That's neat. I spend my work days simulating advanced nuclear reactors that have hexagonal fuel assemblies. In my codes I've used a lot of this info. This is an excellent resource that I'll be referring people who come from the more traditional square lattice world.
jordighover 10 years ago
Tangentially related, I have heard of modelling forest fires with cellular automata.<p><a href="http://en.wikipedia.org/wiki/Forest-fire_model" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Forest-fire_model</a><p>The grid is usually rectangular, and I&#x27;ve always found this a bit odd: hexagons represent 2-d sphere packing, so they always seemed more natural to me. I once asked researchers in the field about this, around 2006, and they responded that rectangular grids serve just as well. I just found this paper from 2007 where apparently hexagonal grids fare better:<p><a href="http://www.sciencedirect.com/science/article/pii/S0307904X06000916" rel="nofollow">http:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;pii&#x2F;S0307904X06...</a><p>This makes me wonder, for realistic models that are meant to model a notion of neighbour cells, why aren&#x27;t we always using hexagonal grids in 2d or higher-dimensional analogues? With rectangular grids, you&#x27;re always faced with the choice of defining whether touching on edges and corners count as neighbours or not, which seems like an unnatural choice. Why, then, does this not seem to matter in the end?
评论 #8942257 未加载
评论 #8942091 未加载
评论 #8942901 未加载
评论 #8942839 未加载
评论 #8941865 未加载
评论 #8945706 未加载
akanetover 10 years ago
Fascinating! One of Affirm&#x27;s old job application puzzles was about a hexagonal grid. I did a write-up[1] of how I solved it, unaware that I was reinventing the wheel. The cube coordinates abstraction would have been <i>killer</i> for being able to explain things to myself.<p>[1]: <a href="http://vincentwoo.com/2013/03/08/above-and-beyond-the-affirm-job-puzzle/" rel="nofollow">http:&#x2F;&#x2F;vincentwoo.com&#x2F;2013&#x2F;03&#x2F;08&#x2F;above-and-beyond-the-affirm...</a>
评论 #8942166 未加载
jxfover 10 years ago
This was a fantastic article -- examples were concise and clear, and everything was well-written.<p>Tangentially, I&#x27;d love to know the best way to create the visuals for this kind of content. I assume no one&#x27;s writing all those SVGs by hand, right?
评论 #8942004 未加载
antichaosover 10 years ago
20 fun facts about hex grids: <a href="http://gamasutra.com/blogs/HermanTulleken/20140912/225495/20_Fun_Grid_Facts_Hex_Grids.php" rel="nofollow">http:&#x2F;&#x2F;gamasutra.com&#x2F;blogs&#x2F;HermanTulleken&#x2F;20140912&#x2F;225495&#x2F;20...</a>
novaleafover 10 years ago
I&#x27;ve never seen hex described this way, but here&#x27;s how I envision simplifying their logic in games:<p>a regular 2d array, but with every-other row logically offset by 50% of the cells width, thus you end up with:<p><pre><code> [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ] </code></pre> super simple data structure (normal 2d array), and pathfinding isn&#x27;t difficult (use hex algos). I wonder why nobody ever writes about this....<p>Edit: ahh, the article kind-of describes this in the &quot;Offset coordinates&quot; section, just no explicit mention of able to use an array for storage.
评论 #8943320 未加载
评论 #8943146 未加载
gameshot911over 10 years ago
Wow. The interactive examples make for one of the most impressive tutorials I&#x27;ve ever come across. Great job, amitp!
leni536over 10 years ago
I would like to see a game on a Penrose tiling. Obviously you couldn&#x27;t make it wrap though.<p><a href="http://en.wikipedia.org/wiki/Penrose_tiling" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Penrose_tiling</a>
评论 #8948419 未加载
MarkHarmonover 10 years ago
That is an amazing resource and I used it when developing my hex game library for PixiJS.<p><a href="https://github.com/mark-harmon/HexPixiJs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mark-harmon&#x2F;HexPixiJs</a>
评论 #8942672 未加载
prestonbriggsover 10 years ago
I&#x27;ve explored similar questions using a grid of equilateral triangles. Obviously they are very close in spirit. I wonder though, if the triangles are somehow more basic.
评论 #8942136 未加载
lloekiover 10 years ago
I wonder what a non-cubic polyhedron-based voxel system would look like, without going all the way to marching cubes&#x2F;tetrahedrons (where the cubes&#x2F;tetrahedrons are only part of the algorithm that helps in rendering basically arbitrary voxels).<p>To wit: <a href="http://mathworld.wolfram.com/Space-FillingPolyhedron.html" rel="nofollow">http:&#x2F;&#x2F;mathworld.wolfram.com&#x2F;Space-FillingPolyhedron.html</a>
fit2ruleover 10 years ago
If you want to get into grid programming, the MOAI framework has pretty good support, and the samples are pretty easy to grok: <a href="https://github.com/moai/moai-dev/blob/develop/samples/grid-hex/main.lua" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moai&#x2F;moai-dev&#x2F;blob&#x2F;develop&#x2F;samples&#x2F;grid-h...</a>
maccardover 10 years ago
For anyone who hasn&#x27;t read it, (and is interested ofc.) this website has one of the best explanations of A* I&#x27;ve ever read.<p><a href="http://www.redblobgames.com/pathfinding/a-star/introduction.html" rel="nofollow">http:&#x2F;&#x2F;www.redblobgames.com&#x2F;pathfinding&#x2F;a-star&#x2F;introduction....</a>
terichoover 10 years ago
Wow, I&#x27;ve been trying to make a Settlers of Catan game for fun and the thing I struggle most with is the board algorithms. This a fantastic resource to help with that, thanks.
nnessover 10 years ago
Very comprehensive. Enjoyed the interactive examples.
bhhaskinover 10 years ago
This is such a good resource!
ofcapl_over 10 years ago
brilliant article!