1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

TTH Map Generator

Discussion in 'Community Dev Corner' started by Chaosed0, Nov 25, 2013.

Mods: Downburst, Mazey
  1. Chaosed0

    Chaosed0 Catapult Fodder

    Messages:
    15
    EDIT: I've started work on a new map generator that's integrated more nicely with the game. This one 's an actual mod, written in AngelScript. You can find my latest changes here. Once it's in an acceptable state, I'll make a new thread for it.

    Over the weekend, I threw together a map generator for the Take The Halls game mode. It's written in python 3.3, using Pillow to save the image. Here's some sample maps:

    [​IMG]
    [​IMG]
    [​IMG]

    It's still a work in progress, but I think the maps it generates are acceptable enough for now.
    You can get it off of github. Use the script by running:

    Code:
    python genMap.py <size_x> <size_y>
    As mentioned, you'll need Python 3.3 and Pillow to run the script. It'll generate a file named "map.png". Feel free to fork the repo and do whatever you want with the code - I won't have too much time to work on it over the next few weeks, but I'll try to maintain it a bit. Please leave feedback here.

    Issues that still need sorted:
    - Hall doors sometimes are placed below the ground
    - No trading posts!
    - No water is generated, making boat research completely useless
    - Caves are a bit wonky - they're either covering a broad swath of ground or completely undeground
    - No scrolls are placed underground (not completely necessary, but nice)
     
    Last edited: Dec 20, 2013
    Noburu, norill, Monsteri and 5 others like this.
  2. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    Looks good!
    Suggestions:
    1) Resources/placement
    1.1) Less gold
    1.2) More stone
    1.3) Smaller caves
    1.4) Slylands, supported by dirt background (or just some kind of hills). Like you see with the current maps. (You probably thought of this, as it's quite logical.)
    2) Creating maps
    2.1) More options, for instance <baseline>


    More suggestions to come.
     
    norill likes this.
  3. Chaosed0

    Chaosed0 Catapult Fodder

    Messages:
    15
    Thanks for the suggestions, I'll take them into account. I did think of skylands, but it'll probably be a bit difficult to add them with the way I'm doing things right now - I basically just generate a heightmap and then modify it in a bunch of ways.

    There are a bunch of options, but they're all just set in the script file right now. I'll expose them more.

    EDIT: Oh yeah, as an aside, I saw in the server parameters several options for map generation, like map width/height and random seed. What's up with those? Are they for a different game mode?
     
  4. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    They were used for the old KAG map generator of the Classic game, afaik not usable right now.
    @Geti correct me if wrong plz.
     
  5. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    Old gen "works" in the sense that it generates tiles, no spawns or trees or anything meaningful. New generator is all in angelscript and yours to modify, of course.
     
  6. Chaosed0

    Chaosed0 Catapult Fodder

    Messages:
    15
    Damn, I should have asked if there was a generator already; it wasn't readily apparent that there was one, so I just assumed that it didn't exist.

    It did take me a little while to figure out how the heck to generate maps, though. It seems that in "DefaultLoaders.as", you've got "kaggen.cfg" as the file extension; however, none of the included cfg files end in "kaggen.cfg", just in "cfg".

    Anyway, once I got that figured out, I loaded up "generator_WAR_default.cfg". Three questions about the maps that are generated:
    • The maps generated have no halls; from a quick glance at "GenerateFromKAGGen.as", it seems like there is no logic to place them. Is there a way to tell them to do so?
    • The maps aren't symmetric. Is there a way to make them symmetric?
    • Is there any way to change the seed at generation-time without modifying the script (and thus marking the server "modded")?
    I guess a fourth question too: are these even valid questions, or am I doing something completely wrong?

    In any case, this investigation made me think about my approach to the problem. I'll probably either modify the existing generator or make one from scratch in AS if the answers to these questions are all "no". I'm really interested in seeing a good map generator for the TTH mode; I think it's the only thing the game lacks right now. Playing the same map rotation over and over again gets a bit stale.
     
  7. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    There is one kaggen.cfg included. test.kaggen.cfg is the config used for all generated maps currently, the other ones are legacy files that I should delete :^)
    • The hall generation should probably be done by WAR.as rather than the kaggen generator - as far as i remember it already places "main spawn" markers, if not, then it probably should. CTF is the only gamemode i adapted to work with kaggen
    • Copy one half of the map into the other half - requires everything to be stored as abstractions though, as far as i remember it currently hard-places trees etc. Not too hard.
    • kaggen uses m_seed from autoconfig - if it's set to zero the m_seed available to the engine will be changed each time the map changes.
      If you're unfortunate enough to still have this set to 666 from when MM set that as default, change it to zero for a random map each time.
    The whole "modded" server thing is also likely to change quite a bit in the coming weeks, kouji has copypasted some stuff i said on IRC somewhere else if you're interested in the specifics.
     
    Chaosed0 and class101 like this.
  8. Chaosed0

    Chaosed0 Catapult Fodder

    Messages:
    15
    Got it, thanks for the help. I'll try modding the map generator, see what comes out of it. If it's anything substantial, I'll post it in a different thread. I'll leave this script here, though, if anyone wants to tinker with it.

    By the way, I actually did see the copy-paste from IRC - for anyone else who's interested, it's here.
     
    norill likes this.
  9. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    @404ServerError
    Code:
    python2.7 mapgen.py 200 200
    It stops at 'Forming heightmap' and prints:
    heightmap = heightmap[0:halfsizex]
    TypeError: slice indices must be integers or None or have an __index__ method

    e: ok nvm I read the OP again.
     
    Last edited: Nov 26, 2013
  10. Chaosed0

    Chaosed0 Catapult Fodder

    Messages:
    15
    If the problem was the python version, yeah, I didn't even try making it compatible with python 2.x.

    EDIT: Although, that's weird - halfsizex should be an integer. Wonder why it's complaining.
     
    Last edited: Nov 26, 2013
  11. JaniKutscher

    JaniKutscher Builder Fan Donator

    Messages:
    103
    Hey ,good work it looks pretty nice :D
     
  12. tanmang42

    tanmang42 Ballista Bolt Thrower

    Messages:
    13
    I'm a newbie to python, can you post some sort of tutorial on how to run it? I'm clueless on how to do this >_>
     
Mods: Downburst, Mazey