Changes between Version 16 and Version 17 of Random_Map_Generator
- Timestamp:
- Jun 20, 2020, 2:12:03 PM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Random_Map_Generator
v16 v17 1 [[TOC]] 2 3 = The random map generator = 4 1 5 There 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]. 2 6 3 = Playing Random Maps=7 == Playing Random Maps == 4 8 5 9 Random 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. 6 10 7 = Guide to !JavaScript=11 == Guide to !JavaScript == 8 12 9 13 The 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: … … 11 15 * http://msdn.microsoft.com/en-us/library/6974wx4d 12 16 13 = Guide to Random Map Scripting=17 == Guide to Random Map Scripting == 14 18 15 19 Basically 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. … … 17 21 Random 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. 18 22 19 == Load libraries==23 === Load libraries === 20 24 21 25 A 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)`. 22 26 23 == Initialize the library==27 === Initialize the library === 24 28 25 29 The next step is to initialize the library. This may vary, but for rmgen, you would call `InitMap()`. 26 30 27 == Save the results==31 === Save the results === 28 32 29 33 The 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]. … … 31 35 '''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. 32 36 33 == Design Tips and Conventions==37 === Design Tips and Conventions === 34 38 35 39 * Maps should be round, not square. … … 51 55 * Match the aesthetics of hand-crafted scenarios as much as possible. 52 56 53 = Roadmap / To do=57 == Roadmap / To do == 54 58 55 59 * 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 … … 63 67 * 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. 64 68 65 = Available Libraries=69 == Available Libraries == 66 70 67 71 Here's a list of libraries currently included with the map generator: