Random DuPi Map Generator (September 29th, 2009)

Recently zaphod asked for help on the BZBB for someone to make a script that would randomize the objects on his DuPi map. I thought it shouldn't be too hard since I've used perl to write a number of scripts to make bzflag maps. However, there was a lot more to DuPi than I had thought at first. There were quite a few specifications on the size and placement of objects. There are four main sections: the base area, the pillbox cross, and the ducati style "open fields" and "base fields." Below is a chart zaphod sent me that shows how DuPi is set up.

DuPi Specifications

The bases and pyramids around them were the easiest to make. Since they don't move or change size, they are simply hard coded into the script.

The Pillbox cross was fairly easy to implement, since the objects have a specific position. However, there were a few restrictions, such as one of the eight objects must be a pyramid, and one of the seven remaining boxes must be fifteen units square. Everything else was to be between five and ten units square. Everything had a random rotation of 360º. Below is an example of the code required for one of the eight objects:

$pyramid = 1 + int(rand(8)) ;

$size_15_box = 1 + int(rand(8)) ;

$pb1_size_xy = 5 + int(rand(5)) ;
$pb1_size_z = 5 + int(rand(20)) ;
$pb1_rotation = int(rand(360)) ;

if ($pyramid == 1)
{$pb1 = "pyramid" ;
print FILE "box
pos 345 345 6
size 25 25 1
rot $pb1_rotation
matref clear

pos -345 -345 6
size 25 25 1
rot $pb1_rotation
matref clear
end" ;}

elsif ($size_15_box == 1)
{$pb1 = "box" ;
$pb1_size_xy = 15 ;}

{$pb1 = "box" ;}

print FILE "$pb1
pos 345 345 0
size $pb1_size_xy $pb1_size_xy $pb1_size_z
rot $pb1_rotation
end" ;

The Ducati open fields and base fields were by far the hardest to make. I tried a few different ways to randomly put objects in the triangular area, but nothing seemed to work too well. So finally I decided the script should just pick from some pre-made fields. We have about 8-10 fields, and I made the script randomly rotate each object within the field. That way it is a little more random.

So far everything is going pretty good and the script is bug free. Now it's just down to fine tuning the open and base fields to make them as playable as possible.

A screenshot of DuPi
A public server that was randomly generated with the push of a button