Fub.DLL - History & Technical Stuff

I first started writing a graphical map & scenario editor. Since Visual Basic 6.0 has become my language of choice, that is the language I used. At some point during the course of developing the editor, I wanted some random maps to work with. Next thing I know, I had spent almost as much time working on making random maps as I had working on the rest of the editor. So I decided to continue working on the random map maker, and put it out as a DLL prior to finishing the editor. 

This is when I discovered that VB does not have the ability to create normal DLLs. So, armed with almost no C++ knowledge, I embarked upon creating an ActiveX DLL from the VB code I had written, and then calling that from a regular DLL written in C++. I got through what should have been the hardest part, actually making a successful call, only to discover that I cannot pass an array parameter to the VB ActiveX DLL in a way that the VB code can modify the array! If you are aware of the technical specs for a World Build DLL, then you understand what a huge stumbling block this is.

Mark gave me the idea that finally worked. After the C++ "shell" code calls the main function exposed by VB and control returns to C++, the C++ code makes a series of calls to other exposed VB functions, basically sending array position as a parameter, and receiving the value of that position as a return value. While this is not as elegant as an array parameter would be, it is surprisingly quick, even for a max sized map!

Here is the history behind the shapes and building algorithms. I started with some code that just placed a single square on the map and randomly added squares until the desired size land mass was created. The problem with this algorithm was that all land masses over a certain size (say 100 squares or so) ended up being the same shape, a roughly circular blob.

So I started building known "shapes", then adding random squares to make something unique. (So, looking at the final three algorithms implemented, "shapes" was actually the first one written.) Adding new shapes became as fun to me as anything else; call me a geek, I guess, it is pure geometry and algebra. At the small level, less than 500 or so squares, this worked very well. However, as the land mass grew larger, the base shape became very recognizable. Like my "blob" algorithm, randomly adding a lot of squares simply padded the original shape. So, I played with the concept of limiting where the random squares were added. This was much better, as I was able to achieve a random(ish) coastline, and some large irregularities.

OK, if you have read this far on this page, you must be a real EDIE geek like me.  I'm also assuming that you have downloaded and installed the program.  I've got a little treat for you that is undocumented anywhere else: Press Alt-F5 anytime before clicking on "Build", this will activate a "Watch-Build" option that I built into the program to help with some de-bugging.  If, while watching, you want to stop watching but continue the build in progress, just press Alt-F5 again to turn it off.  One last thing, if you are reading about this for the first time on this website, please email me, I'd really like to know!  Now, back to the boring history stuff...

As I was working on the "Erratic Pad" part of the shape algorithm, I realized that I could use the same concept to build random blobs with distinct shapes. This led to the Blob version 2 algorithm, which I have renamed the "Wandering Blob" algorithm. I liked the results, and this quickly became my favorite over "shapes". But, I noticed that as I tried to make the shape more interesting, or erratic, the result had a lot of "holes", or land-locked lakes, and this was undesirable to me. Try using 80/3 as the first two values for the Wandering Blob to see similar results.

This led to the Blob v3 algorithm, which I have renamed the "Stick Blob" algorithm. Here, the base shape is created by starting with a few scattered squares (points), then connecting them (resulting in sticks). The main problem I had with this was that small land masses tended to end up as mostly sticks with only a few additional random squares. To overcome this I try to ensure that no more than 1/3 of the entire land mass is used in making "sticks".