openage icon indicating copy to clipboard operation
openage copied to clipboard

Terrain generation and Random Map Scripting (RMS)

Open TheJJ opened this issue 10 years ago • 10 comments

openage needs random map generation.

For that we probably need two approaches:

  • Random map scripts
    • Be creative and implement configurable map generation in Python
    • On top of that, we can implement a RMS script parser that then is mapped to the Python API
  • As extension, deterministic infinite terrain generation, comparable to Minecraft, for unlimited map sizes.

The important part is the configurable RMS generator.

  • Input: some configuration
  • Output:
    • Terrain grid (with heights and tile type)
    • List of entities with their positions (trees, animals, resources)

TheJJ avatar Oct 30 '14 21:10 TheJJ

keep in mind that system-provided rand() are not portable in a sense that each system can provide it's own (p)rng. implementation of own prng would likely be required. have a look at lcamtuf's paper for inspiration: http://lcamtuf.coredump.cx/oldtcp/tcpseq.html

janisozaur avatar Oct 30 '14 22:10 janisozaur

A deterministic random number generator that is synced across all multiplayer clients is absolutely essential, of course. De-syncs were the main issue during age2's development. Map seeds and game session seeds would be an essential step.

mic-e avatar Oct 30 '14 23:10 mic-e

RNG here #191

franciscod avatar Feb 05 '15 03:02 franciscod

A good starting point would be parsing the .rms files which generate the random maps (they can be found in the Random folder in the original game folder). Most of the commands used there could be extended to infinite maps, though we obviously want normal maps to work as well. I'd like to gradually implement the commands found in the .rms files, and compare the resulting maps with the original game.

We now have a perlin noise generator in python, and the RNG in c++. Where should the map generation itself live? Maybe parse the .rms files in python, and generate the map itself in c++?

Some other points:

  • There are some resources on random map generation in AOE2, but that's mainly on the scripting aspect, and not how the game uses these scripts to generate the map. Does anyone know of more documentation on the map generation?
  • If we want to extend the random map scripts with new commands, we might want to create our own format for it, but I'm not sure we'd need that. Also, if we get our own format, I'd prefer for the game to be able to still read .rms files, and not forcing the script maker to convert it first somehow, to make it easier for script makers.
  • For easy map generation testing, it would be very nice to be able to get a screenshot of the map without starting the game, but this is probably very hard. The original game also has a (kinda bad) full-map-screenshot utility with Control+F12.

So, let me recap my main questions:

  • Where should the code go? Parsing in python, and generation in c++?
  • Any known documentation on AOE2 map generation? (Edit: there's a lot!)

detrumi avatar Apr 29 '15 09:04 detrumi

Maybe we could generate a random map in AoE2, then save the game, and after thta load the terrain data from the savegame. These guys could help us in "decompiling" (I'm not sure if we need this) the running binary so we can get more info about the generation.

franciscod avatar Apr 29 '15 11:04 franciscod

We don't really need to exactly replicate the original generation, it just has to be at least as good, if not better.

edit: I misunderstood your comment. Yeah, looking at the savegame would help if it wasn't clear what is being generated, but I expect that just looking at the map with fog of war turned off will be enough.

detrumi avatar Apr 29 '15 11:04 detrumi

http://exupero.org/hazard/post/islands/ https://github.com/exupero/islands

TheJJ avatar Nov 11 '16 11:11 TheJJ

https://flafla2.github.io/2014/08/09/perlinnoise.html

TheJJ avatar Jan 10 '19 12:01 TheJJ

Pretty interesting stuff how to generate fair map seeds while staying with the so loved randomness of AoE.

Dire Straits is built using a different process than a typical AoE2 map in order to generate unpredictable geography while validating each map with a computer program to keep things fair for both teams. For more information about how to create maps like this, including the source code for all the programs used, see this guide:

https://web.archive.org/web/20200418033040/https://docs.google.com/document/d/1E_Si9iXmzUqFuptkW-8F6XdmoxDXNUG36XIhnh86krU/edit

Dire Straits & creating random RM maps.pdf

simonsan avatar Apr 18 '20 03:04 simonsan

Documentation and utilities for writing Age of Empires II: DE random map scripts https://github.com/hungarian-notation/rms-toolkit

simonsan avatar Apr 24 '20 08:04 simonsan