Comment

Comment by gereleth

I didn't use any special coordinates, just some trigonometry. My code transforms coordinates between (x,y) - for drawing, (row, column) - for finding neighbours and (index into an array of tiles) - for managing state. It sort of grew organically and could probably be cleaned up a lot.

The hardest part was making the board repeat for the wrap variant making sure that all tiles have consistent wrap neighbours. I almost deployed a version that worked fine on odd-sized grids and went completely bananas on even-sized grids. The danger of always testing on a 5x5 board)).

parent gereleth 4 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton