Jump to content

Yet another random map generator


Pyrophorus
 Share

Recommended Posts

Hi everyone !

So here is my little random map generator library. This alpha version is far from perfect yet, but I hope it deserves an eyeshot already.

landscape-7.png.fdb901cfb4698f830c74b3569138056a.png


The archive contains two files and a folder to insert into your local settings at: Oad/mods/public/maps/random. The 'yamg' folder contains a library used by the demo program which creates a random map (Venustas only, it seems there are some differences with earlier versions). Of course, if you prefer all in a single file, you can copy/paste the whole library replacing the 'RMS.LoadLibrary("yamg");' instruction at the beginning of the map script 'aYamgDemo.js'.

The picture here is a 'medium' map using the '7964' random seed value. I only changed the default sun settings to emphazise the relief.
Open the map script and feel free to discover the various settings and options. You shouldn't need to edit the library itself. Just be careful with forests on large maps: the script could try to place a huge number of trees and will then choke Atlas.
Have fun !

Now, I must say I'm not satisfied with this program for some reasons and would be glad to have a discussion about them. Of course, many details could be improved like round maps correct management and terrains melting, for instance. But this not really a big deal.

A more serious reason is the library is too low level IMHO. For instance, someone could want a river crossing the map, a mountain in the north-west and so on. It's possible to do that with the library, but it's far from obvious and easy. I need ideas to build a higher level framework, and if you have some, you're welcome.

The last reason is more abstract. I have worked for years on the topic (creating random maps for games like OAD), and always stumbled on the same problem: creating realistic and good looking maps is one thing, but most often, realistic maps are not balanced at all and even not playable. And well balanced maps are often not very realistic, because they are too regular and exhibit kind of patterns. The real challenge is to have both, and I don't know if it is even possible (contradictory?). This is why I don't rush to code other things like roads or resource placement. How could we define a balanced map in terms of constraints, this is the question I ask to everyone interested here, and I hope to have a discussion about it.

Friendly,

 

yamg.zip

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Yes, realistic and good looking maps for the win! Naturalism adds so much to the immersion felt by by players, which is something that should be a top priority, aside from the incessant balancing discussions.

I always wondered if it isn't possible to have well balanced, and relatively flat area's, for the beginning CC's, so everybody gets a fair chance to start, but wildly varying, extremely natural hinterlands? And these two elements should integrate seamlessly,  I'm talking realistic glowing hills, valleys, mountains, thick forests, open meadows, little streams, swamps and scorched areas, plateaus and depressions... No recurring patterns of any sort, and meticulously painted (overlapping) ground-textures.

Quite a number of impressive maps have been made by individuals over the years, and the best of those should be used as a benchmark for the rest of the maps. A total overhaul, focusing on natural terrain elevations and ground-textures would do magic for 0AD. 

Some of the big immersion killers in my opinion, are the stretching of textures on hills and cliffs, and unnaturally shaped, inaccessible flat topped hills, a lack of more grasses and bushes, and not enough diversity in ground textures in some maps, monotonous patterns of forests. Not enough detail on the shorelines and vegetation around shorelines, and mines should really be integrated in rocky formations, not just plumped right next to your CC. I think it's completely out of context and awkward looking. I believe the secret to beauty lies in the details. 

I believe the 0AD community should be focussing more on updating the aesthetics of the game, to make it more attractive. Don't get me wrong, the game looks amazing already, and people have done an amazing job so far, in so many fields, it's just that it could look even better with some very doable visual adjustments, especially in regard to realistic looking, natural maps. 

Sorry, for my ramblings... But could anyone point me to the best tutorials on making maps for 0AD, and tell me what are the important pitfalls to avoid, things to watch? Basically the basics... Maybe I'll try making one myself (and probably regret the decission later :P )

Spoiler

I really want to see more of this:

12249014794_ac7bc575af_o.png.3a27a1cf1bf9bdfed06c7a3c7d9b8c91.thumb.png.8fb2448b6f92c1ecdca0cf6d43110138.png

 

 

  • Like 2
Link to comment
Share on other sites

Yes, the second point is how do we get passed those performance issues? Other games have created massive scale, natural and realistic maps before, why can't 0AD create playable maps like that, without sacrificing beauty? 0AD has become a platform to create naturalistic art! It just needs to become playable, for the game to reach it's true potential.

I remember the guy who created that map saying something like being able to reach 50 pop or something on that map before lagging out, so many years ago... I believe we could do better today.

Edited by Sundiata
Link to comment
Share on other sites

@Sundiata  @stanislas69 The rendering isn't the issue. Pathfinding is the bottleneck. As you could have noticed, lags are appearing on many units 200, 300, 400 are moving. But for GPU it's not a problem. Problem for GPU is 10000 or 100000 units.

The hard thing is to have a compabililty with old GL (2.*, 3.*).

Edited by vladislavbelov
  • Like 1
Link to comment
Share on other sites

1 minute ago, stanislas69 said:

@vladislavbelov With full graphics quality, and no obstruction actors, I highly doubt it. All this grass make the game lag because of the high number of polygons, and the alpha transparency. This can be reproduced easily by using Lordgood old's corn field for zapotecs @Lion.Kanzen reported huge lag.

I agree that it costs a lot, but not so much as the pathfinder. Instancing, deffered rendering and batching will help a lot.

Edited by vladislavbelov
  • Like 1
Link to comment
Share on other sites

3 minutes ago, stanislas69 said:

@vladislavbelov My point was that in current state, it's an issue and things can be done about it without touching to the pathfinder :)

But you answered on the post above, which reports about performance at all. Not about graphic only. I mean, it absolutely right to improve graphics too, but do not forget that it's not the only one thing that slows the game.

Link to comment
Share on other sites

@vladislavbelov I'm sorry, I meant the only thing preventing us from turning the game into that screenshot in a playable way, is the graphics (Because if you try to do that in atlas, even with nothing moving, no AI, no units, it will lag) (The game pathfinder performance is acceptable in the sense you can play ) Now I agree that combination doesn't help

Link to comment
Share on other sites

Obviously pathfinding and graphics are both very important. Working on either doesn't exclude the other. Especially if certain techniques in one field can benefit the other. Those in the graphics department need to do the best they can, and those in the pathfinding/coding department just the same. I think they're both absolute priorities for 0AD.

Edited by Sundiata
Link to comment
Share on other sites

I can't resist the pleasure to share this,  produced with yamg in Atlas:

landscape-7.jpg.a7735e6c047b479966125808d74e1cd6.jpg

Now, I have another question. I think I see two use cases of random maps in OAD.
- Map designers can use them as a starter for their work (I think painting by hand something like this picture above, would cost a lot of time)
- Random maps designers try to write scripts creating playable maps out of the box, of any dimension and random seed.

Which is the most important one ?

Friendly,

Edited by Pyrophorus
Grammar
  • Like 4
Link to comment
Share on other sites

@stanislas69 Thanks for your reply.

About control, it's an important point. Of course, you need some, and much more in the second use case, but IMHO, the more control you have, the more work you need to put it at use. And I think when you accept some lack of control, you can be rewarded obtaining something you would never have imagined. For myself, I would never have imagined a map like the one in the previous post, and creating it with a height map would be a very, very long task (except if you use an existing one). This is why I work on random map creation instead of designing maps from scratch. Results  are IMHO most often far better than what I could get all by myself.

Friendly,

Link to comment
Share on other sites

Nice work Pyrophorus!

I'd advise to create one or more random map scripts for multiple reasons. Foremost, lobby players almost exsclusively play random map scripts (because they can change the number of players and any other setting arbitrarily). Secondly because it is very rare that someone actually proposes a polished map for 0ad that was done with the map editor.

With regards to your code, you should take care that the generated map is round (thats the convention, looked better with the minimap. Is also better for gameplay as noone can hide in a corner and all players have the same distance to the center of the map. Also square maps have 4/pi times more area on the same mapsize, i.e. 27% more which often causes unintended performance-lag).

Put some players there, straggler trees and details and try to make the resoures balanced (as in guaranteeing 40 starting trees for each player).

It'll be important that there aren't wide areas void of entities. There can be open space, but the eye should always have something to look at.

I saw water can be generated as well, so you might have to paint terrain below players (like archipelago random map script does) or ensure that there is sufficient space for each player.

Most of the maps generated with your script have very steep terrain. That's fine for some map generations, but not for every.

Would be great to include a map that encompasses all these considerations in alpha 23!

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, elexis said:

Nice work Pyrophorus!

Thanks for your feed-back and appreciation !

6 hours ago, elexis said:

I'd advise to create one or more random map scripts for multiple reasons. Foremost, lobby players almost exsclusively play random map scripts (because they can change the number of players and any other setting arbitrarily). Secondly because it is very rare that someone actually proposes a polished map for 0ad that was done with the map editor.

OK...

6 hours ago, elexis said:

With regards to your code, you should take care that the generated map is round (thats the convention, looked better with the minimap. Is also better for gameplay as noone can hide in a corner and all players have the same distance to the center of the map. Also square maps have 4/pi times more area on the same mapsize, i.e. 27% more which often causes unintended performance-lag).

Yes, I don't forget the maps must be round and they shall be. BTW, it's easy to set the round flag in the json file. But it's still a work in progress, so it's easier to see accurately  how the script works on square maps. For now, I'm working on improving relief variety. Basically the script produces homogeneous maps, e.g. steepness and smoothness are everywhere the same. In the last picture I posted, maybe you noticed there is a rather flat part of the map. The idea is to have steep peaks and flat valleys, and more maybe (underwater and shore relief also are different).

let peakHeigth = tRelief /3;
for (let i = 0; i < mSize; i++)
{
	for (let j = 0; j < mSize; j++)
	{
		if( tMap[i][j] > peakHeigth)
			tMap[i][j] = -1;
	}
}

var tRough = 1.05; // this one rules the ground irregularity, from 0.1 (smooth) to 1.2 (very chaotic and probably not playable)
var tProgress = 64; // difficult to explain this in few words, try it from 2 to mapSize (power of two). See algorithm for details.
createAltitudes(0, mSize, 0, mSize, (tRelief * 1.5)); // redraw high peaks

It's how it works: parts of the map higher than some limit are redrawn with parameters giving this kind of chaotic terrain, leaving the lower parts untouched.

7 hours ago, elexis said:

Put some players there, straggler trees and details and try to make the resources balanced (as in guaranteeing 40 starting trees for each player).

It'll be important that there aren't wide areas void of entities. There can be open space, but the eye should always have something to look at.

I saw water can be generated as well, so you might have to paint terrain below players (like archipelago random map script does) or ensure that there is sufficient space for each player.

Yeah, I will do that ;) But I'll try a rather ambitious idea. Instead of spreading resources everywhere equally on the map, I will try to put them in rather realistic places (like  stone at the foot of the cliffs and so on), and later  try to find optimal settlements, given this resources layout (some kind of barycenter of resources, on flat places and so on), just as real people would do colonizing a new land. I have no idea if this could work and give rather balanced maps. Spontaneously, I would say: certainly not. But who knows ?

Friendly,

  • Like 3
Link to comment
Share on other sites

Hi everyone !

I should have thought people here have not much time to spare editing my script and try the settings. My bad...

So in the script below, I have randomized the main settings to show the maps one can get with the library. Changing the map size and random seed in Atlas will show a large variety of maps, from flat landscapes (with or without sea) to steep mountains. It's a tour, so don't tell me there's no control on the map and the result is not predictable !  :P

landscape-9.jpg.387df775f98aefc47ee7c1c04b0e0fce.jpg

There's no need to update the library if you already install it. I put it here for those who don't have it.

Friendly,

aTour.zip

yamg.zip

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Code looks ok. 440 lines of code sounds like a lot, but the file is really small in comparison. Pass by at our Coding_Conventions page and compare with our codebase:

Also might want to checkout FeXoRs heightmap library that is used for Caledonian Meadows and Wild Lake. It distributes the resources depending on height.

(Argh, those ugly 3 black tiles at the map border and incomplete skyset again. Had this issue in the trailer and release screenshots. They only make sense when playing in a top-down perspective, so perhaps we should switch to a complete skyset and enlightened map border if the horizon is within the camera view)

Make sure to end up with a map that we can commit for alpha 23 :P

  • Like 1
Link to comment
Share on other sites

Hi @Pyrophorus :)

I haven't looked into the code or generated some maps but I wanted to at least give you the feedback: This is awesome! Please continue  (y)

I especially like the "some areas harsh, others more even" part!

@realistic and fair: It is possible by choosing a symmetry matching the number of players and use realistic design for the part left. The symmetry will leave a notable global pattern but locally the map will be mostly realistic.

In hope I'll find the time to take a closer look next week...

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...