1. 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

NextGen - Just another map generator

Discussion in 'Modding [KAG Classic]' started by fausto636, Dec 14, 2012.

  1. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    Hello, everyone!
    I've been playing KAG for a while now, and i think it's time to give something back to this great game.
    So...
    Yesterday, looking through the forums i found this post, and i thought "Wow, that looks cool. I wonder if i can make something like that.."
    And here it is, my attempt to create a map generator.
    Just a heads up: It's written in C and runs only on Linux (not sure if thats good or bad). (Now running also on windows)

    Pics:
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    The easily customizable parameters(some):
    (just a copy-paste of the header, sry if some of this parameters are hard to understand)

    #define START_COEF 0.75 //relates to the minimum height of the starting area
    #define TENT_SPACE 25 //Amount of Plain ground for base
    #define TENT_LOC 10 //Dist between the tent and the end-of-map
    #define MSIZE_X 250 //Map x size
    #define MSIZE_Y 150 //Map y size
    #define MAX_CLIFF 7 //Max "jump" per pixel
    #define MOM_RATE 0.8 //Momemtum rate
    #define EN_RATE 2 //Energy rate
    #define THICK_RATE 0.1 // Thickness rate of sky islands
    #define PROB_ISLA 0.5 //Probability of a sky island appearing given the necessary conditions (which are random)
    #define PROB_ISLA_B 0.7 //Probability of a sky island having "dirt background" below
    #define ISLA_STRT_R 3 //A rate of the starting point of a sky island
    #define PROB_G_ISLA 0.05 //Probability of a magical(?) golden island appearing
    #define PROB_G_BASE 0.01 //Probability of gold under base
    #define PROB_GOLD 0.005 //Probability of gold
    #define PROB_TREE 0.08 //Probability of a tree
    #define PROB_TREE_I 0.1 //Probability of a tree in island
    #define PROB_TREE_B 0.25 //Probability of a tree on base
    #define PROB_BEDROCK 0.01 //Probability of bedrock

    It outputs in .png 24bits (i think, have to check that :p)

    I realize i'm far from finished, plus still have lots of ideas to implement.
    What i would like is some feedback. What do you guys think? What things do the maps shown need?

    At the top of my to-do list is:
    Make every parameter customizable.
    +random tunnels
    +clustering gold & bedrock
    Question: Is the .kag file format known? If so, where is the data to know how to make one?
    Because that could lead to some crazy maps...(ie: posibility of finding an "Underground KEG storage",etc)

    Ok, cyaz =)
    </br>--- merged: Dec 14, 2012 7:59 PM ---</br>
    Not sure if anyone is reading this post but.. Updates =)
    Added some perlin noise and things started to improve. Tunnels are next.
    Moar Pics:
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    (the bedrock is there, its just hard to see)

    </br>--- merged: Feb 15, 2016 5:46 AM ---</br>
    Video:


    EDIT: Uploaded files.

    Cya =)
     

    Attached Files:

    Noburu, Boxpipe, Rayne and 3 others like this.
  2. BlueLuigi

    BlueLuigi :^) Forum Moderator Donator Tester

    Messages:
    3,620
    Nice stuff, going to have to check this out later today :)
     
    Boxpipe likes this.
  3. Mazey

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

    Messages:
    1,914
    If possible, make a port for windows!

    Really.
     
    Boxpipe likes this.
  4. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    Thanks!
    Regarding the Windows port, I will think about it but the thing is that i have no experience programming on Windows :S

    Coming soon:
    The v08 will have improved tunnels.
    And probably the v09 will be dedicated to also generate underground maps =)

    BTW, do u guys know where can i get the "know-how" info to create .kag files? (.kag files support items, .png files dont..)

    Can someone test if this map is loadable/playable?
    [​IMG]
     

    Attached Files:

    • test.png
      test.png
      File size:
      28.3 KB
      Views:
      198
    Boxpipe and BlueLuigi like this.
  5. Rayne

    Rayne ༼ つ ◕_◕ ༽つ Administrator Global Moderator Forum Moderator Tester

    Messages:
    1,916
    Go into single player sandbox, load up your map you want to make into .kag, then type /savemap name.kag into the console (home key)

    I think that will work.
     
    Boxpipe likes this.
  6. Mazey

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

    Messages:
    1,914
    He means how to 'write' .kag files I think.
     
    Boxpipe likes this.
  7. Rayne

    Rayne ༼ つ ◕_◕ ༽つ Administrator Global Moderator Forum Moderator Tester

    Messages:
    1,916
    that's impossible.

    nah i'm kidding, but idk, you'd have to probably get the info from the devs on how to do this.
     
    Boxpipe likes this.
  8. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    Yeah, the main idea is to make a built-in converter. Manage the creation of the map via .png and export to .kag for item support.
    Hopefully a dev can see this =(

    Tunnel improvement at 640x480 =)
    [​IMG]
    The underground maps are gonna be a pain in the ass..
     
    Boxpipe likes this.
  9. Geti

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

    Messages:
    3,730
    I got forwarded here by rayne; the .kag format is a complicated binary format, and changes from build to build, which is a major issue.
    Due to the unmaintainability of such a format, we'll be using scripts to load more complicated maps in future builds, based off the PNG format or scripted generators.
     
    Ne3zy and Boxpipe like this.
  10. GloriousToast

    GloriousToast Haxor Donator

    Messages:
    1,463
    Geti, have you thought about using duel file map systems ie one map will contain the actual maps with all the materials, the other will contain the shops/items? or is this an entirely unviable system?
     
    Boxpipe likes this.
  11. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    Ok. Then i guess im going to focus on making my map gen as much configurable/transparent as i can using txt files.
    Since the dedicated servers run on linux. maybe with some scripting the regular map gen can be bypassed and mine can be used "on the fly", just a thought.
    Thanks Geti & Rayne
    </br>--- merged: Dec 18, 2012 7:32 PM ---</br>
    Today i had a little bit of free time so here it is, v10.
    Improved tunnels and started working on the "underground" maps.

    ps: The library im using is also available on windows, so a windows port might not be that far away.
     
    Boxpipe and Rayne like this.
  12. Mazey

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

    Messages:
    1,914
    Videos are cool, but show some pics too!
    Can't wait for the windows port
     
    Boxpipe likes this.
  13. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    Pics? Yeah, got lots of those.
    A mix..
    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    [​IMG]
    =)
     
    Boxpipe likes this.
  14. Geti

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

    Messages:
    3,730
    It's viable, it just requires parsing 2 images, which means longer load times and the inconvenience of having 2 maps to edit.

    We'll open up the ability to read PNGs however you see fit with scripts at some point so you'll be able to implement a 2 map system yourself if you so choose.
     
    Boxpipe, BlueLuigi and Rayne like this.
  15. Froghead48

    Froghead48 Haxor

    Messages:
    703
    I really enjoy all of these map generators. Keep making them! :D
     
    Boxpipe likes this.
  16. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    Ok guys first public release (only for linux sadly)
    Keep in mind there's alot to improve.
    There is a README inside the tar that explains a few things (not much..). Hopefully the next version will have a better README.
    I started looking into the windows stuff and the program runs perfectly, i just need to learn how the hell build a "release" version without ppl having to download a ~200mb library metapackage.
    BTW, if someone offers to do the windows thingy it would be great =)

    Anyway, tarball.. (32bit and 64bit)

    Cya

    </br>--- merged: Jan 6, 2013 8:13 PM ---</br>

    Hello KAG ppl..
    The map generator Windows version. (same version as before)
    If you install it in the default dir, i think you need to run it as Admin to save the png.
    To edit the config file, don't use notepad. Use something else like wordpad or similar. (notepad doesn't get the "new line" character)
    Since i've been quite busy these days, i also uploaded the source files. Maybe someone find the code useful.

    Hmm im probably forgeting something, but nevermind.
    Cya =)

    pd: I now realize i forgot to put the Readme inside the installer...
    "Ok, some basic rules..
    Every parameters that goes(by default) between 0 and 1, should remain between 0 and 1
    The following parameters are disabled and some will be available on next releases:
    MAX_CLIFF,DELAY,TUNEL_START,TUNEL_STRT_R,TUNEL_STRT_R2,GANANCIA_I,PROB_TROCK,TUNEL_STRT_R2_C,TUNEL_STRT_R_C

    So there are around 72 values you can mess with."

    (The windows version is called setup.zip)
     

    Attached Files:

  17. Ne3zy

    Ne3zy Haxor

    Messages:
    308
    you should try not to make that much vertical difference, it plays bad, but good job anyway since I like the generated maps just work on that and it's ok in my opinion :) !
     
  18. fausto636

    fausto636 Builder Stabber

    Messages:
    8
    If fact, that's determined by the energy and momentum values which you can modify. (MOM_RATE, EN_RATE, GANANCIA) (with every other prefix)
    Let me explain...
    Every "jump" in the terrain (cliff) absorbs some energy and accumulates momentum. And of course, also every jump it's decided by probability.
    If you put a high energy rate, the jumps will drain more energy, which will impact in the probability of making another jump. ( "high value" = plain map )
    The momentum just makes everything smoother.

    Also de START_COEF indicate where where tent "y" position will be (also affected by some randomness). FYI the point (0,0) it's at the upper left corner.
     
    ParaLogia likes this.
  19. krislor

    krislor Catapult Fodder

    Messages:
    4
    Cool :p