Mblock (random map generator)

Discussion in 'Mapping Questions & Discussion' started by martijntje, Jan 14, 2010.

  1. martijntje

    martijntje L8: Fancy Shmancy Member

    Messages:
    539
    Positive Ratings:
    168
    MBlock

    So this is the first public version of my random map generator. The goal is that when finished it will generate a blocked out map. MBlock stands for Mappers block, the moment this program will be quite handy.

    currently Mblock is still in early stages and so not quite usefull
    Currently all it does is place some random blocks in the map, a floor a skybox and some light entities. Brushes will not overlap each other nor intersect. by default it generates several thousand brushes.
    [​IMG]
    maps generated are always symmetrical. (like 2fort, not pipeline)
    after running the program, you should have a file called "randommap.vmf" in the directory of the program, wich is te generated map.

    known issues
    -no info_player_start
    your map should not have any issues, if so, just add one
    -texture perpendicular to face on every non-horizontal face.
    causes ugly red wall when compiled, to fix this, in hammer check for problems, then fix all of type.
    -no spawn points
    you will simply spawn in the center of the map, wich should be just fine.
    -Everything is world geometry, not func_Detail
    deal with it, convert manually or compile with fast vvis

    [​IMG]

    coding geek info
    I would quite like some help with this, source code is included, so have a look at it.

    the process

    1.writing first part of file.
    simply copies everything from vmftop.dat
    2.laying down the field.
    a 2 dimensional boolean array call field is generated where each boolean represents a x,y location on the map. True means that you may place a brush there and False means you cannot. Here I set all places to true
    3.calculating open space.
    here I call the function do_magic, wich should tell where the open spaces should be. Currently is does nothing. This is what will probably determen the layout of the map the most.
    4.fill the non-open space with cubes.
    this is a simple proces of generating ranom locations and sizes of the cubes, then checking whether space is avaible (using the field array), then (using the field array) set the room to occupied and add the brushes.
    5.write the last part of the file
    adds vmfbot.dat to the final file. when you want to add predefined entities to the map, add them to this file.

    some useful functions
    add_brush(x,y,z,a,b,c)
    will make a brush with corners on (x,y,z) and (a,b,c) (the are the corners farthest apart) with gray dev texture and a blu dev texture on the top face
    add_brusht(x,y,z,a,b,c,str)
    same as add_brush, but the texture of each face will be str.
    write_entity
    do not use, should not work.
    is_place
    will tell you wheter there is occupied space in between the given coordinates
    reserve_place
    will set the space in betwee the coordinates to occupied.

    plans for future versions
    -Have do_magic done
    -Have user input for size of map, number of brushes etc
    -Have a simple graphical overview of the map when done, so you dont have to open up hammer every time
     
    • Thanks Thanks x 4
    Last edited: Jan 14, 2010
  2. zaratustra

    zaratustra L2: Junior Member

    Messages:
    52
    Positive Ratings:
    1
    This is a great advance in random mapping technology.
     
  3. The Political Gamer

    aa The Political Gamer

    Messages:
    4,468
    Positive Ratings:
    1,704
    :D This is going to be fun to mess around in.
     
  4. Terr

    aa Terr Cranky Coder

    Messages:
    1,591
    Positive Ratings:
    405
    Here are two ideas that promise some interesting algorithmic challenges, in case that's part of the fun:

    Sentry sight ranges. Create a random field of pillars in which no ground-level location can see another 'open" area more than X distance away.

    Automatic hint plane and viscluster entity that connects all the open air above the highest pillar.
     
  5. Tapp

    Tapp L10: Glamorous Member

    Messages:
    776
    Positive Ratings:
    215
    Last time I checked vvis was designed as a program to optimise the map's visportals as well as possible without human input? Anyway, remember to try and keep the geometry on a grid, and with gaps of a certain size. And would it be possible to merge generations? So that one could generate one floor, move it down, then generate another?
     
  6. martijntje

    martijntje L8: Fancy Shmancy Member

    Messages:
    539
    Positive Ratings:
    168
    I dont know how well it would work, at least if I would want it I would have to ask some AI guy. btw sentries range is not that great, on most maps you can take down a sentry without being "visible". on viaduct I once took down several sentries with a pistol as an engineer.
    Yeah, pretty simple, I'll consider it when I reach later versions.

    merging is quite possible, and likely will be in there someday. snapping to grid will be in the next version
     
  7. martijntje

    martijntje L8: Fancy Shmancy Member

    Messages:
    539
    Positive Ratings:
    168
    Updated to v0.2
    -Mblock may or may not produce playable layouts right now
    You will have to try multiple times to get something useful, but at least there is progress now
    -Generated maps now "snap to grid" (gridsize 64)
     
  8. Dr. KillPatient

    Dr. KillPatient L3: Member

    Messages:
    115
    Positive Ratings:
    8
    It'd be awesome if it could use partially preprogrammed building templates so it has the ability to create simple, hollow structures using four walls, a roof, and basic unit scales of 128, 192, and 256 as wall heights.
     
  9. Penguin

    aa Penguin Clinically Diagnosed with Small Mapper's Syndrome

    Messages:
    2,004
    Positive Ratings:
    1,428
    This + Random Map Name generator = wins.
     
  10. martijntje

    martijntje L8: Fancy Shmancy Member

    Messages:
    539
    Positive Ratings:
    168
    had that planned from the beginning. the only real problem is first I would have to place all brushes and then all props (windows, doorframes). other than that it would be a piece of cake. I mean, I did already figure out an easy way to make good looking building
     
  11. Tapp

    Tapp L10: Glamorous Member

    Messages:
    776
    Positive Ratings:
    215
    Might I suggest, if this project gets far enough, a program which draws out a set of corridors, and another which generates open space with obstacles, such that one could generate full maps. You already have the open space generator, just make one which adds in random pockets of indoor areas.
     
  12. Dr. KillPatient

    Dr. KillPatient L3: Member

    Messages:
    115
    Positive Ratings:
    8
    Like Tapp said regarding obstacles, prop addition would make the software utterly invaluable. Perhaps a theme setting with chocies like 'snow', 'desert', etc that would tell it what kind of basic prop_statics to decorate relevant areas of the map with; Badlands rocks in large, flat areas or Spytech computers along walls for instance.
     
    Last edited: Jan 16, 2010
  13. Gundam

    Gundam L1: Registered

    Messages:
    34
    Positive Ratings:
    18
    Well, I made a couple of edits to the code, and now you have the ability to create empty rooms with doors.

    The textures and props are from the swamp pack so make sure you have it as well.
     
    • Thanks Thanks x 2
  14. FaTony

    FaTony Banned

    Messages:
    902
    Positive Ratings:
    160
    Oh crap I smell random mapping contest.
     
  15. Randdalf

    aa Randdalf

    Messages:
    1,054
    Positive Ratings:
    466
    Y'know, I'd love to have a programming contest.
     
  16. Fraz

    aa Fraz Blu Hatte, Greyscale Backdrop.

    Messages:
    944
    Positive Ratings:
    573
    what we need now is a non steam/sdk reliant hammer. Whoever does that wins the internet.
     
    • Thanks Thanks x 1
  17. martijntje

    martijntje L8: Fancy Shmancy Member

    Messages:
    539
    Positive Ratings:
    168
    D: Dont have the time to check it today, but from the looks of it: I like it.
     
  18. Tapp

    Tapp L10: Glamorous Member

    Messages:
    776
    Positive Ratings:
    215
    Clearly one only needs to get source sdk compatible with steam offline mode. I don't see what the problem could be, valve did it with the l4d sdk.
     
  19. Fraz

    aa Fraz Blu Hatte, Greyscale Backdrop.

    Messages:
    944
    Positive Ratings:
    573
    I'd enjoy a version which doesnt need the SDK open to run, or steam for that matter. My brother and I share the account (he plays football manager and the likes) which means I can often be left without anything to do.
     
  20. Randdalf

    aa Randdalf

    Messages:
    1,054
    Positive Ratings:
    466
    I shall begin work on making a generator of my own :)