Changes between Version 16 and Version 17 of Random_Map_Generator


Ignore:
Timestamp:
Jun 20, 2020, 2:12:03 PM (9 months ago)
Author:
FeXoR
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Random_Map_Generator

    v16 v17  
     1[[TOC]]
     2
     3= The random map generator =
     4
    15There is a random map generator integrated with the engine. Random map scripts (RMS) are implemented in Javascript with a minimal C++ interface, see [wiki:Random_Map_Generator_Internals Random Map Generator Internals].
    26
    3 = Playing Random Maps =
     7== Playing Random Maps ==
    48
    59Random maps can be played through the game setup, by choosing Random from the Match Type dropdown. See the [wiki:Manual_SettingUpAGame Gameplay Manual] for more details.
    610
    7 = Guide to !JavaScript =
     11== Guide to !JavaScript ==
    812
    913The game supports scripts written in Javascript, which are used for random maps, game logic, and AIs. The engine uses the [https://developer.mozilla.org/en/SpiderMonkey SpiderMonkey] library to implement the language. References for those interested in Javascript programming:
     
    1115 * http://msdn.microsoft.com/en-us/library/6974wx4d
    1216
    13 = Guide to Random Map Scripting =
     17== Guide to Random Map Scripting ==
    1418
    1519Basically a random map script is responsible for all the logic of generating a map: modeling terrain, placing units and resources, and then returning the data to the engine. In practice, most of the logic is hidden by APIs also implemented in JavaScript. We have added the concept of libraries for this purpose.
     
    1721Random map scripts are placed in the `maps/random/` directory (see [wiki:Mod_Layout mod layout]). In addition to the script itself, there is also an associated [wiki:JSON] data file. This file is loaded by game setup to recognize a new random map, and it includes various settings, see [wiki:Random_Map_Generator_Internals#DefiningtheMap defining the map] for details.
    1822
    19 == Load libraries ==
     23=== Load libraries ===
    2024
    2125A random map script should first load any libraries it will need. Libraries are stored in the game data directories under `maps/random/libraryName/`. When a library is loaded, all scripts in that directory are parsed and their code made available to the random map script. They are loaded through the function call `Engine.LoadLibrary(libraryName)`.
    2226
    23 == Initialize the library ==
     27=== Initialize the library ===
    2428
    2529The next step is to initialize the library. This may vary, but for rmgen, you would call `InitMap()`.
    2630
    27 == Save the results ==
     31=== Save the results ===
    2832
    2933The random map script should end with a call to `Engine.ExportMap(data)`, which returns all the map data back to the engine. In rmgen this is abstracted by a call to `ExportMap()`. For the exact format of the data see [wiki:Random_Map_Generator_Internals Random Map Generator Internals].
     
    3135'''Note:''' The export map function does a coordinate conversion from the 2D used in the rmgen libs to 3D for the engine. You should only use it once, only after the map is fully generated.
    3236
    33 == Design Tips and Conventions ==
     37=== Design Tips and Conventions ===
    3438
    3539* Maps should be round, not square.
     
    5155* Match the aesthetics of hand-crafted scenarios as much as possible.
    5256
    53 = Roadmap / To do =
     57== Roadmap / To do ==
    5458
    5559* Colliding entity detection: On many maps there are entities like trees or chicken in Iberian walls or the Civic Center. To make sure this will not happen we need a finer grained collision detection than tile based. An implementation can be found [[https://wildfiregames.com/forum/index.php?/topic/16242-random-maps-suggestions-bug-reports-and-ideas-about-random-maps-here/&do=findComment&comment=297548|here]]. Components involved: Map, placers, areas, constraints
     
    6367* Painter/placer support: Unifying all functionality that can be used with painters/painters to have a painter or placer. Examples for that would be the diamond square terrain generation and the starting entity placement. There are likely a lot more that has to be found and listed e.g. in [[https://wildfiregames.com/forum/index.php?/topic/16242-random-maps-suggestions-bug-reports-and-ideas-about-random-maps-here/|The Random Map Forum Topic]]. Components involved: Painters, placers, areas, constraints.
    6468
    65 = Available Libraries =
     69== Available Libraries ==
    6670
    6771Here's a list of libraries currently included with the map generator: