Mblock (random map generator)

martijntje

L8: Fancy Shmancy Member
Aug 2, 2009
539
334
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.
30ht2d4.jpg

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



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
 
Last edited:

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
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.
 

Tapp

L10: Glamorous Member
Jan 26, 2009
776
215
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.

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?
 

martijntje

L8: Fancy Shmancy Member
Aug 2, 2009
539
334
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.
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.
Automatic hint plane and viscluster entity that connects all the open air above the highest pillar.
Yeah, pretty simple, I'll consider it when I reach later versions.

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?
merging is quite possible, and likely will be in there someday. snapping to grid will be in the next version
 

Dr. KillPatient

L3: Member
May 10, 2009
115
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.
 

Penguin

Clinically Diagnosed with Small Mapper's Syndrome
aa
May 21, 2009
2,039
1,484
This + Random Map Name generator = wins.
 

martijntje

L8: Fancy Shmancy Member
Aug 2, 2009
539
334
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.
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
 

Tapp

L10: Glamorous Member
Jan 26, 2009
776
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.
 

Dr. KillPatient

L3: Member
May 10, 2009
115
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:

Gundam

L1: Registered
Jun 22, 2009
34
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.
 
Feb 14, 2008
1,051
931
Y'know, I'd love to have a programming contest.
 

Fraz

Blu Hatte, Greyscale Backdrop.
aa
Dec 28, 2008
944
1,152
what we need now is a non steam/sdk reliant hammer. Whoever does that wins the internet.
 

Fraz

Blu Hatte, Greyscale Backdrop.
aa
Dec 28, 2008
944
1,152
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.

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.
 
Feb 14, 2008
1,051
931
I shall begin work on making a generator of my own :)