My attempt at a random map generator

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Dobob
Posts: 123
Joined: October 6th, 2003, 9:21 pm

My attempt at a random map generator

Post by Dobob »

I've tried to do a little random map generator, and here is the first totally working prototype (as : I don't have to modify the result map to play it).

The code is currently a mess (only a few French comments, all class members are public and all parameters are hard coded), but I should be able to clean it up now that I know it is working. Also, the generated map aren't very balanced since there's almost never sand and swamp, the grassland is very scarce and keeps can start in water :roll: .

As for the example map, I had to generate 3 maps to get it. I playtested with Loyalists against Undead AI (supposed to be at my disavantage since the terrain is very rugged in the map) and it was played (and I won).
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

so is the point of this to get a better generator than we currently have?

its probably a good idea, since the current one is not that good. and the example map looks relatively balanced.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

This generator does look pretty cool, and nicely coded. And of course, since it conforms with the map editing interface, it can be pretty easily 'dropped' into the game :)

Although...
turin wrote: since the current one is not that good
Alot of people seem to think this, but I'm not sure what they don't like about the current one that is reasonable to fix :?

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Dave wrote:
turin wrote: since the current one is not that good
Alot of people seem to think this, but I'm not sure what they don't like about the current one that is reasonable to fix :?

David
IMHO when you have it near Inland it has way too many mountains, when you have it on Island it has way too much water, and when you have it in between you basically get mountains right next to water.

maybe there is a way to get better maps, in which case the default settings should probably be changed.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

Also on some settings (size 20X20, everything else default), it does not always generate the correct number of players.
Dobob
Posts: 123
Joined: October 6th, 2003, 9:21 pm

Post by Dobob »

turin wrote:so is the point of this to get a better generator than we currently have?

its probably a good idea, since the current one is not that good. and the example map looks relatively balanced.
It's not meant to be better, just different. I haven't studied the actual RMG, but mine does generate the map one "cluster" at a time. Each cluster can have very different properties. This will allow having archipelago styles map (medium sized island in a bunch of water) or to normalize the density of villages in the area near each player. Its disavantages will the huge amount of config files needed, but since I plan to use WML for this, I could take advantage of macros.
Dave wrote:This generator does look pretty cool, and nicely coded. And of course, since it conforms with the map editing interface, it can be pretty easily 'dropped' into the game :)
Thanks :P . As for nicely coded, there's surely many improvements in that aspect as I'm an autodidact in C++ (I learned Java at University). Also, I would have to remove all those floating-point calculation if you want to put it in the game (that wouldn't be that hard actually).
Dave wrote: Although...
turin wrote: since the current one is not that good
Alot of people seem to think this, but I'm not sure what they don't like about the current one that is reasonable to fix :?

David
The current one is not bad, but he does have some flaws. Two of them are the possibility of having some players favored in number of villages and the possibility of starting in bad (snow) terrain. I plan to avoid those in my generator by guaranting the density of villages and by forbidding snow/deep water in players' clusters. But since it will fall in the config file, it shouldn't be that bad...
Also, I dislike the way the starting positions are decided by putting each player in his favorite terrain (elves in forest,...). My plan about it would be the tell the RMG in advance which faction will be each player and build the cluster accordingly.

Anyway, only time will tell how it will turn out :roll: ...
silene
Posts: 1109
Joined: August 28th, 2004, 10:02 pm

Post by silene »

Dobob wrote:Also, I would have to remove all those floating-point calculation if you want to put it in the game
There is no real need to remove them, unless you are doing really silly things with it. And by the looks of your code, you don't. There already are floating-point computations in the game.
Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Post by Boucman »

Dobob wrote: Also, I dislike the way the starting positions are decided by putting each player in his favorite terrain (elves in forest,...). My plan about it would be the tell the RMG in advance which faction will be each player and build the cluster accordingly.
well, IIRC the map is generated before the players choose their factions... so you can't really tell the RMG in advance what terrain will favor the faction since the faction has not been decided yet
Fight key loggers: write some perl using vim
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

Boucman wrote:the map is generated before the players choose their factions...
yeah... maybe that should be changed, though?
Dobob
Posts: 123
Joined: October 6th, 2003, 9:21 pm

Version 0.1

Post by Dobob »

Here my 0.1 (Baby Step) of the RMG.

All of the hard coded data now reside in a WML config file (ranmap.cfg). The format used is a little bulky, but that's what macros are for :roll: .
The config file in the tar.gz is just an example and could get some improvement, but the format should be clear enough for people to play with it. Also, I didn't test alot, but I've seen that the generator put a lot more forest/mountains when map size/# clusters is large, and there're surely many others problems.

Anyway, the generator contains all of its main features, and could be used to generate playable maps.
Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Post by Boucman »

did you post it to patches.wesnoth.org ?
Fight key loggers: write some perl using vim
Dobob
Posts: 123
Joined: October 6th, 2003, 9:21 pm

Post by Dobob »

Boucman wrote:did you post it to patches.wesnoth.org ?
Rigth now, it's more of a standalone program than a patch, so I didn't put it on the patch management system. Also, there's many improvement to be made to it.
Dobob
Posts: 123
Joined: October 6th, 2003, 9:21 pm

Version 0.2 - Roads

Post by Dobob »

Okay, not much feedback on the last version, isn't it?

Well, I've added roads between each touching clusters, which guarantee at least on passage between each player keep. This also include bridges and cave paths (examples of them are respectively in file bridges.cfg and caves.cfg).
Note : to use the generator, you must use (example) "ranmap mixed.cfg map" to produce a map in the file "map" using the rules of the file "mixed.cfg".

The bridges are giving some problems, as it's frequent that you get a big group of bridges in all directions, but that's not too bad, since it also allows ground troups to go fighting near the water.

As for the code, I must tell that it's messier than ever before :oops: . So I'll surely have to clean it up for next version (and also add comments).


Edit : I'm ashamed of myself, the "many bridges in a spot" problem seem to be solved by changing the += from line 453 to a -=. I was doing potential backward, making the road love going in the water...
Edit Bis : resolved the problem in the attached file.
Attachments
ranmap-0.2.tar.gz
Another step toward totally messed code...
(34.04 KiB) Downloaded 554 times
Last edited by Dobob on November 25th, 2004, 2:13 pm, edited 1 time in total.
Dobob
Posts: 123
Joined: October 6th, 2003, 9:21 pm

Post by Dobob »

Well, ...

I posted the new version of my RMG 3 days ago and no one has dowloaded it...

It's not a good sign, isn't it ?

I would simply like feedback on how the maps generated are looking (after solving the little bug), and if the WML is simple enough to understand without having the full list of keywords.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

I think it would perhaps be better to post some screenshots of maps generated with it. It's quite alot of effort to plug some code in and getting it compiling ;)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Post Reply