Voronoi polygons (map generation)

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Voronoi polygons (map generation)

Post by Lap »

I was toying around with the idea of replacing hand made maps with computer generated ones and so I decided to take a trip over to:

http://www-cs-students.stanford.edu/~am ... eneration/

The first step of the puzzle is using Voronoi tessellation, which looks like:

Image

I ported over an existing script to love and added some controls to play with it.
voronoi.love
Requires Love 8.0 and uses a framebuffer. Take that people with old computers! Fixed
(5.28 KiB) Downloaded 629 times
Keys

-: decrease number of points (fine tune)
=: increase number of points (fine tune)
Numpad -: decrease number of points (hold down)
Numpad +:increase number of points (hold down)
Space: generate new tessellation


I don't know if this is even the route I want to go down so I probably won't be developing this much further. It would be nice to have Lloyd's Relaxation or some other form of quasirandom distribution (not pseudorandom, quasirandom, as in "blue noise"), but I'm afraid most of the math requires way too much time for me to wrap my head around for a simple prototype.
Last edited by Lap on Tue Nov 15, 2011 11:42 pm, edited 2 times in total.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Voronoi polygons (map generation)

Post by Robin »

Your .love is incorrectly packaged. Make sure to zip the contents of your project folder, not the project folder itself. Also, you forgot to include inspect.lua.
Help us help you: attach a .love.
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: Voronoi polygons (map generation)

Post by Lap »

Whoops, fixed.

If you don't like the clustering, the easiest way to do it is probably just to make a hex grid and add a random number to each coordinate.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Voronoi polygons (map generation)

Post by kikito »

I like the idea a lot but... why did it have to use canvas and framebuffers?
When I write def I mean function.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Voronoi polygons (map generation)

Post by bartbes »

kikito wrote:canvas and framebuffers?
Oh no, not the same thing twice!
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Voronoi polygons (map generation)

Post by coffee »

It's really fixed and re-uploaded? I'm getting NewCanvas nil errors.
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: Voronoi polygons (map generation)

Post by Lap »

kikito wrote:I like the idea a lot but... why did it have to use canvas and framebuffers?
Was it required for me to do? No. Was it the laziest and most efficient way from a coding and computational standpoint: Yes it was.

Since almost all the hard stuff isn't the actual drawing you can easily mod it to not use framebuffers by just storing the lines and points as tables and then drawing them all individually each frame *shudders*.


I also had to remove that terrible inspect.lua. WORST LIBRARY EVER ;).
coffee wrote:It's really fixed and re-uploaded? I getting NewCanvas nil errors.
It requires Love 8.0 if you aren't using that.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Voronoi polygons (map generation)

Post by coffee »

Lap wrote:It requires Love 8.0 if you aren't using that.
Oh sorry. Thank you, I really didn't noticed the warning. Well, actually I still waiting to find a 8.0 OSX compatible build, so I will have to skip give feedback on this one for now. Since you post the amitp link I also got interested in reading some articles. I'm finding very useful the ones about finding paths in maps.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Voronoi polygons (map generation)

Post by kikito »

ok, now I feel like a fool. please ignore me.
When I write def I mean function.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Voronoi polygons (map generation)

Post by josefnpat »

This is very nice :)
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests