HNHacker News
TopNewBestAskShowJobs

edwardc

86 karma · joined October 25, 2012

submissionscomments
edwardc··on Show HN: Random Roads
Thanks for the feedback. Yes, I have been imagining the same thing too!

Just need to track down a e-ink display for this sort of fun project. Anyone know of any good ones that would make this easy?

edwardc··on Show HN: Random Roads
Yes, there's nothing to prevent very small maps like what you saw - even ones that terminate with a dead-end before a road has been drawn (eg. https://random-roads--edwardcunningh2.repl.co/#1592758760947).

I considered adding logic to prevent this, but have decided to embrace it as a feature rather than a bug.

I quite like some of the small-ish maps, like this: https://random-roads--edwardcunningh2.repl.co/#1592759118928

edwardc··on Show HN: Random Roads
Good one! Yes, you've hit the bottom there.

It is artificially limited to a 1001 x 1001 grid - just to stop it from growing forever (which could get quite slow on lower end devices). In practice I rarely encounter maps that go that far.

edwardc··on Show HN: Random Roads
Thanks for the feedback - the minimal look is pleasing to my eye too!

I wrote a brief description in this comment: https://news.ycombinator.com/item?id=23592538

Initially I had envisaged something a bit cleverer, but for an art project keeping it simple seemed to do the trick.

edwardc··on Show HN: Random Roads
Thanks. It's plain JavaScript, rendering with an HTML canvas.

I did investigate JS 2D graphics libraries but decided in the end that this was sufficiently simple to not warrant one. It was harder than I expected to get the drag & zoom to work!

edwardc··on Show HN: Random Roads
Thanks! You can see the code here: https://repl.it/@EdwardCunningh2/Random-Roads

It's not especially clever:

1. I define a set of possible moves (eg. straight ahead, left turn, junction, etc). One possible move is a dead-end, which looks a bit like a house in my interpretation.

2. Each move is assigned a relative weight (eg. continuing straight ahead 10x more likely than turning left).

3. Each iteration, for each of the roads under construction, a random move is selected. Some moves are impossible (based on other roads already drawn on the map) and so it will ensure not to select one that would result in a collision. At worst, it will terminate the road with a dead-end.

4. Repeat forever, until every road has terminated in a dead-end.

Most of the script itself is dealing with the rendering logic. To avoid collisions I maintain a 2D array of all visited points.

edwardc··on Show HN: Random Roads
Well spotted!

I enjoy the large ones (eg. https://random-roads--edwardcunningh2.repl.co/#1589058113269) where I imagine the gaps left in the middle to be parks.

edwardc··on Indian PSLV successfully lofts multiple satellites
The Scream in Space 'experiment' uses screams uploaded to YouTube as part of a competition last year: http://www.screaminspace.com/ (and since this is HN, https://github.com/cuspaceflight/SpaceScream).