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.

Hexagonal Grids (2013)

368 pointsby siliconmountainover 4 years ago

30 comments

amitpover 4 years ago
A surprise to be on HN!<p>Tech notes for the curious:<p>I started the page in 2013 based on notes I had been collecting for ~20 years before that. I update this reference page as I come up with better visualizations and explanations. The last major update was in 2018 when I rewrote it from using d3.js to using vue.js. It greatly reduced the amount of code I was writing, and also let me make the page more interactive. I then added lots more (doubled coordinates, links to papers, axes legends, diagonal directions, side by side comparisons) and improved most of the existing sections. In 2019 the changes were minor, rewriting the map storage section and improving performance. In 2020 I improved the cube&#x2F;hex animation, the pixel-to-hex section, and added Rust sample code. There&#x27;s lots more I could add to the page[1] but I don&#x27;t have any specific plans for when I&#x27;ll get around to it.<p>The page is svg- and js-heavy. I prerender the diagrams on the server (try loading it without js!). Then using IntersectionObserver on each section of the page, I swap the static diagrams and text with interactive versions. This improves load times somewhat, because almost no JS has to run on page load.<p>For printability I process the page with xsltproc, extract all the links, and turn them into footnotes. Try print preview on the page to see these. Unfortunately the diagrams are broken when printing in Chrome (it works in Firefox) so I need to investigate.<p>[1]: <a href="https:&#x2F;&#x2F;www.notion.so&#x2F;redblobgames&#x2F;f8bc2f44fba94607afa9c06711d23245?v=0766432cb1534ce582ce35b33cbbef7e&amp;p=7d2d4d624bc5483dafbe615d75ab3902" rel="nofollow">https:&#x2F;&#x2F;www.notion.so&#x2F;redblobgames&#x2F;f8bc2f44fba94607afa9c0671...</a>
评论 #25344093 未加载
评论 #25345556 未加载
评论 #25346243 未加载
评论 #25342746 未加载
评论 #25344495 未加载
评论 #25343686 未加载
评论 #25343840 未加载
评论 #25343341 未加载
评论 #25343041 未加载
评论 #25344064 未加载
评论 #25344206 未加载
furyofantaresover 4 years ago
I love this page. I&#x27;ve used this page as a reference, it saved me a lot of time and left me with a stronger understanding as well.<p>It reminds me of old school web. When google first came on the scene I was amazed at how many informational pages from either hobbyists or professionals existed (but which I wasn&#x27;t finding with older search engines), where someone just decided to put everything they know about some topic into a page in glorious detail.
评论 #25345861 未加载
评论 #25341131 未加载
aidenn0over 4 years ago
FWIW, I strongly prefer square grids for tabletop games.<p>Hexagonal grids give you precise measurements in exactly 6 directions.<p>If you approximate sqrt(2) as 1.5 then square grids give you pretty darn accurate measurements in 8 directions, including 2 pairs of directions that are orthogonal, which is good for rectangular features like buildings.<p>Furthermore the distance between two points can be quickly calculated with (long-side + 1&#x2F;2 short-side), which is doable in your head, unlike the distance calculation on a hex grid.<p>Lastly, if you divide the circle into a large number of slices and calculate the average error for path distance using hex or squares, among those slices, the average error (compared to pythogorean) is smaller with squares (obviously for small multiples of 6 and small multiples of 8 respectively, one or the other will be preferred).
评论 #25341475 未加载
评论 #25341586 未加载
评论 #25343187 未加载
评论 #25341080 未加载
评论 #25341387 未加载
评论 #25341345 未加载
yudlejozaover 4 years ago
For a semi-goofy take (CGPGrey) on hexagons:<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;thOifuHs6eY" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;thOifuHs6eY</a>
评论 #25343544 未加载
评论 #25342238 未加载
评论 #25340991 未加载
mrtnmccover 4 years ago
In case anyone is doing signal processing on a hexagonal grid, the <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Hexagonal_fast_Fourier_transform" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Hexagonal_fast_Fourier_transfo...</a> is pretty useful. I work on consumer phased arrays with hexagonal grids, so the HFFT is useful for computing the far-field beam pattern.
jsjohnstover 4 years ago
Surprised they didn’t cover hexagonal ring data structures. Here[0] is a visualization along with the calculations needed to find nearest neighbors.<p>[0] <a href="https:&#x2F;&#x2F;www.flickr.com&#x2F;photos&#x2F;jeremyjohnstone&#x2F;3979747216&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.flickr.com&#x2F;photos&#x2F;jeremyjohnstone&#x2F;3979747216&#x2F;</a>
elihuover 4 years ago
CGP Grey did a video about hexagons recently. I mean, there&#x27;s only so much you can say about hexagons really, but he manages to cover a lot of ground.<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=thOifuHs6eY" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=thOifuHs6eY</a>
dangover 4 years ago
If curious see also<p>2019 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19184412" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19184412</a><p>2017 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14627711" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14627711</a><p>2015 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9537009" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9537009</a><p>2015 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8941588" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8941588</a><p>Discussed at the time: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5809724" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=5809724</a>
type_enthusiastover 4 years ago
This is from 2013, so I guess it comes up every so often (2019: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19184412" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19184412</a>). But, I&#x27;ve had it bookmarked since the first time I saw it come up. It&#x27;s a great article for anyone who&#x27;s ever played a hexagonal game or has thought about making a hexagonal game.<p>The source site also has a lot of great stuff on applications of computer science to less-thought-of aspects of game development (by which I mean people usually think of pixel-blasting 3D engines as &quot;game development&quot;, but there&#x27;s a lot more to it)
keyleover 4 years ago
The guides on that website are fantastic. I wrote multiple games using them as reference. Well written, explained clearly and a wealth of information.
Timotheeover 4 years ago
Ah, I wish I had come across this two weeks ago!<p>I&#x27;ve been doodling with Processing and was working on hexagonal Truchet tiles. (basically random tiles that have paths connecting to any random tiles next to it, with hexagons as tiles instead of squares)<p>I ended up having to figure out some of that stuff again, in particular the coordinate system inside each tile so that I could deal with integer coordinates and translate them into the right fraction of the radius.<p>It was fun to figure out what I needed, so I don&#x27;t regret it :)<p>And I am also planning on doing something with cubes, so this page will come in handy.<p>Thanks for sharing! I love how it covers all aspects of the problem.<p>Result of the tiling: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;_timothee&#x2F;status&#x2F;1330315929641570304" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;_timothee&#x2F;status&#x2F;1330315929641570304</a><p>Diagram of my coordinate system: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;_timothee&#x2F;status&#x2F;1327859098642046976" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;_timothee&#x2F;status&#x2F;1327859098642046976</a>
评论 #25341018 未加载
rgovostesover 4 years ago
See also several past discussions, though none recent:<p><a href="https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=true&amp;query=redblobgames.com%20hexagons&amp;sort=byPopularity&amp;type=story" rel="nofollow">https:&#x2F;&#x2F;hn.algolia.com&#x2F;?dateRange=all&amp;page=0&amp;prefix=true&amp;que...</a>
cookiengineerover 4 years ago
Every time I see a post of redblobgames, I realize what a treasure this website is.<p>I&#x27;ve been on this website so often, and pointed other people so many times to it... I hope this never gets lost and is archived.<p>If Amit would write a book about gamedev, I&#x27;d definitely buy it and add it to my collection.
taywrobelover 4 years ago
I almost never use bookmarks any more, but I’ve had this page bookmarked for the better part of a decade now and still refer to it at least once a year, and I don’t even work in game development.
michaericalriboover 4 years ago
An added challenge is to efficiently construct hex grids by hand——quickly, at the expense of accuracy. I didn’t have access to a printer early in the pandemic, but wanted to put together maps for a tabletop rpg. This is a clever solution: <a href="http:&#x2F;&#x2F;www.rdwarf.com&#x2F;users&#x2F;wwonko&#x2F;hex&#x2F;irregular&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.rdwarf.com&#x2F;users&#x2F;wwonko&#x2F;hex&#x2F;irregular&#x2F;</a> It has the added benefit of being easy to remember
neilfrndesover 4 years ago
Uber&#x27;s H3 geospatial library uses a lot of these concepts. <a href="https:&#x2F;&#x2F;eng.uber.com&#x2F;h3&#x2F;" rel="nofollow">https:&#x2F;&#x2F;eng.uber.com&#x2F;h3&#x2F;</a>
goldenkeyover 4 years ago
In case you want to make a hexagonal cellular automata:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;churchofthought&#x2F;HexagonalComplexAutomata" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;churchofthought&#x2F;HexagonalComplexAutomata</a><p>Or in WebGL:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;churchofthought&#x2F;Grautamaton&#x2F;tree&#x2F;complex" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;churchofthought&#x2F;Grautamaton&#x2F;tree&#x2F;complex</a>
xiphoover 4 years ago
This just came up a bit ago in another thread. RBG is so good. Like I did a while back I&#x27;ll mention that that work is the reason I could write this Ruby svg viz library <a href="https:&#x2F;&#x2F;github.com&#x2F;SpeciesFileGroup&#x2F;waxy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;SpeciesFileGroup&#x2F;waxy</a> and it be a fun, rather than painful process.
Groxxover 4 years ago
Red Blob Games has quite a few <i>excellent</i> blog posts. I highly recommend checking out the rest of their blog :)
bransonfover 4 years ago
And if you want something cool to do with this, try implementing Gliński&#x27;s variant of chess.<p>It’s something I’m dabbling in, but no doubt an order of magnitude more difficult to implement than orthodox chess.<p>The idea of indexing by cubes is so obvious once you discover it, but maybe not as easy to intuit. Same goes for the data structures.
shwestrickover 4 years ago
Such an invaluable resource! I spent many hours here while helping develop <a href="https:&#x2F;&#x2F;hexiconapp.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hexiconapp.com&#x2F;</a>. The axial coordinate system, in particular, makes working with hexagons much simpler.
swayvilover 4 years ago
Are you familiar with the kisrhombille grid?<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Truncated_trihexagonal_tiling#Kisrhombille_tiling" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Truncated_trihexagonal_tiling#...</a><p>Scaleable like a square grid.<p>12 directions.
swsieberover 4 years ago
I remember this page. I used it almost a decade ago when implementing a settlers of catan clone for that was going to be the main project for a class curriculum. I was a TA&#x2F;RA at the time.<p>It&#x27;s a great page. It was invaluable to me.
评论 #25340774 未加载
rcarmoover 4 years ago
This is an awesome resource I keep going back to now and again for the sheer fun of it. Glad to see it on HN again (it’s well worth reposting occasionally for folk who haven’t seen it yet).
willis936over 4 years ago
Good stuff. I’m surprised that I have not seen a voxel-based game that leverages a purely 2D render and expects the player to switch between projections to work with the area.
ChrisMarshallNYover 4 years ago
That’s useful!<p>Thanks for posting it.<p>I don’t need to do this too often, but I like having choices.
devsquidover 4 years ago
This is cool. I recently wrote an A* pathfinding system for a hex based game. Choosing a good coordinate system 100% makes this easier.
评论 #25343203 未加载
wycyover 4 years ago
This guide was incredibly helpful a few years ago for one of the Advent of Code challenges.
joshuover 4 years ago
i&#x27;ve used this guide several times. hooray!
darkwinxover 4 years ago
this web site is amazing!!