Lua map generators

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Post Reply
Elefant
Hardened
Posts: 217
Joined: Sat May 28, 2022 3:55 am

Lua map generators

Post by Elefant »

The Lua API has most functions needed for a map gen script, so it would be nice to have the ability to write such scripts and select them in the geography tab of the new game menu.
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Lua map generators

Post by Ignatus »

Doubling! Actually, you can just generate any map and then edit the terrain with a script, and then turn the save into a scenario, but that is not very comfortable. We could just run a script on "map_generated" signal, but some API for starting points is needed (well, we could also run on start of the first turn and manipulate already placed units). A better solution would be actually replacing specific parts of map generation procedure with custom parts (e.g., define callbacks for creating or postprocessing height map, for selecting terrains etc.) with an ability to use binary functions for other parts.
User avatar
Alien Valkyrie
Elite
Posts: 513
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Lua map generators

Post by Alien Valkyrie »

Ignatus wrote: Sat Oct 14, 2023 11:28 am A better solution would be actually replacing specific parts of map generation procedure with custom parts (e.g., define callbacks for creating or postprocessing height map, for selecting terrains etc.) with an ability to use binary functions for other parts.
I'd be wary of things like that — anything we expose to scripts/ruleset is something that will be a lot more difficult to ever remove or majorly modify, since doing so would break compatibility. The map_generated signal we already have between generating terrain and placing initial units/cities already means that if we ever want a map generator that cheats a little by modifying terrain to make start positions better suited to each specific player and their specific starting units, it's not going to be easy. (Also, I don't know what happens if lua script makes sweeping changes at map_generated that end up invalidating previously selected start positions, but I don't expect it to be pretty.)
One could even imagine a generator that works completely backwards to what we currently have, deciding on players' starting positions first, then placing fitting starter terrain around those and building outward from there — this would make e.g. a script hook after height map but before terrain selection fundamentally nonsensical.
I'm not necessarily saying we can't do those things, but making things harder to decouple by codifying current implementation details into lasting parts of the interface is a risky endeavor.

What could be possible without that risk is the option to completely do all of map generation in lua script, just starting with an empty map made of one terrain type and calling a single script hook, which then gets left to place terrain, units, etc.
~ AVL
Molo_Parko
Hardened
Posts: 158
Joined: Fri Jul 02, 2021 4:00 pm

Re: Lua map generators

Post by Molo_Parko »

Why not go at it the other way around: run a stand-alone lua script (or any executable form) to read Fc3 settings, generate the map based on user choices, save map as scenario file, and then launch Freeciv to play the scenario.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Lua map generators

Post by Ignatus »

Molo_Parko wrote: Sun Oct 15, 2023 2:43 pm Why not go at it the other way around: run a stand-alone lua script (or any executable form) to read Fc3 settings, generate the map based on user choices, save map as scenario file, and then launch Freeciv to play the scenario.
Cuz writing a new stangalone application requires extra doing something ;)
Post Reply