DEV Community

Adam Crockett πŸŒ€
Adam Crockett πŸŒ€

Posted on

Do you know the board game risk? 🌍

I have been wondering lately about the potential of making a fun little game inspired by risk.

How would I go about procedurally generate continents and countries with wobbly lined borders? I'm leaning towards SVGs btw.

Top comments (8)

Collapse
 
ben profile image
Collapse
 
mateiadrielrafael profile image
Matei Adriel

P5 has pretty bad performance and it encourafges bad practices - coming from a guy who used to love p5

Collapse
 
ben profile image
Ben Halpern

Yeah I've never used it, it just came to mind as a possible fit for the solution based on what I've read about it. Do you have any alternative ideas?

Thread Thread
 
mateiadrielrafael profile image
Matei Adriel

Pixi looks cool, but I havent tried it

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

Yeah, I watched the coding train videos, and I saw some strangeness with P5, It treats canvas as something a bit different to normal webdev.

I was asking more about the algorithm used to generate 2d terrain that looks like a map.

Collapse
 
joshgrib profile image
Josh Gribbon

I'd try something along the lines of:

  • Pick some points to be the centers of continents
  • Place some random points clustered around each continent center
  • Use something like a Voronoi diagram to create the borders for the counts
  • Make the borders a little more wavy
Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

Welcome Josh!

I think this sounds about right yes.

Architecturally I'm going to use this:

The actor model with the, and maybe challenge myself with pick.js

I will use typescript and xstate as per the video.

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

So more on the algorithm side, voronoi or centroids.