Cave Generator: Part 3

Just a quick update:

Ok, so the C code now generates 1000x500 sized maps, instead of the 600x500 that I was using earlier. (The original game generated 1000x500 maps...) Plus, the C code now generates color graphics, and can save those graphics to file, all thanks to SDL. (Plus, it only takes .37 sec to generate that huge map, which is good, but I think that it could be better... :) )

Sample level

The code allows for zooming in, and drawing specific parts of the map, so I just need to start catching keyboard events, and throw a tank in there for this thing to be sort-of playable. :)

Cave Generator: Part 2

I rewrote the random cave thing in C, and... wow. I sometimes forget just how quick C is sometimes. I wrote this with painfully simple algorithms, that don't take advantage of some of the logical speedups used in the Python version, and it finishes in only 0.34 seconds. I'm pretty happy with that, but I may still fiddle with it later.

The code uses (hopefully) portable C89, so you should be able to compile it with no arguments. (However, adding -O2 is needed to get you the 0.34 completion time... else it takes around a second and a half...) Also, this program doesn't produce pretty output like the last. Instead, it takes the zero-dependency approach by printing its output in ASCII art.

Source Code (GPLv3)

Cave generator

Well, my current project is at a standstill, cause I need to do some more planning, so I've decided to do a little bit of work towards that tunneler remake project I sort of mentioned in the last post.

First thing I wondered was: "How did Geoffrey Silverton generate those maps?" Indeed, they are real nice, and they rendered quick, even on the limited hardware of the time. However, the levels generated by the old DOS Tunneler are always very similar, with all obstacles cleanly placed along the outer borders. I wanted maps in my version to be larger and more labyrinthine. So, after a bunch of experimentation, I came up with an algorithm that generates fairly interesting maps with high precision. The algorithm is 3-phase:

  1. Tree Generation: A bunch of random points are placed on the screen. Then, we repeatedly make edges between the two closest points which are in disjoint sets. This will generate a non-intersecting, and fairly natural-looking, tree. We then draw this tree, so that the following phases have something to work with.
  2. Random Growth: We iterate over every point on the screen, and any point that is bordering a point that has already been set may then get set. Over many passes, the structure will grow, and will eventually cross some threshold (in this case 62%) where we end this phase. Also, I linearly reduce the probability of points getting set along the borders, so that we don't have have caverns colliding with the borders.
  3. Cellular Automata Smoothing: Using a slightly altered version of Conway's Game of Life, we smooth out the graph. The rules have been altered so that outlying points will die quickly, and so that the entire computation will converge to a solution.

Sample cavern

This isn't the quickest algorithm out there, but it's quick enough. The current version is written in Python, and it takes 14 seconds to generate a new graph. (Most time is spent on the random growth stage.) Once I'm more comfortable with the performance of the algorithm, I'll code it up it C, and hopefully we'll have a nice-n-speedy cave generator.

Any thoughts, btw? This is my first attempt at a random level generator, so it's probably not the best solution out there... But if you can do better, I'd love to see it, and possibly include it as a level option in this Tunneler clone. :)

Source Code (GPLv3)

Tunneler

I haven't posted in a bit, so I thought I'd mention one of my favorite games from way back in the day. It was a freeware DOS game called Tunneler. It was programmed by Geoffrey Silverton in 1991, who released 2 fun DOS games before dropping off the grid.

Tunneler screenshot

Tunneler is a game of minimalism. Two tanks play on a large, random map. Moving, digging, and shooting uses energy. To recharge you can either return to your base, or sneak into your enemy's base.

Shooting an enemy reduces their shield. If their shield hits zero, they lose a life. If you return to your base, you can recharge your shield.

These simple rules lead to interesting strategies. Do you explore the random world, and risk exposing your path to your enemy? Do you dig around your base, so that you can easily get back quickly, without wasting energy digging? How far from base are you willing to go, knowing that the same energy you use to attack is also used to get back to your base?

The original binary is public domain, and works beautifully in dos-box. An SDL-based free-software remake has also been made of this game, but the original is better, IMO. I kind of wish that there was a project that didn't just mimic the capabilities of the current game, but would expand upon the concept, with different map types, Internet multi-player, or even just being able to have more than 2 players. (But with the same 16 color graphics, of course.) Maybe this could be a fun project to work on, but it'll have to wait... I've got other fish to fry. :)

Remake: SDL Tunneler:http://users.jyu.fi/~tvkalvas/code/tunneler/

Original DOS Version:http://members.chello.at/theodor.lauppert/games/tunneler.htm

Note: I scanned that DOS binary with clamscan and it came up clean, but run your own checks. No disclaimer, etc.

Next game I'll be nostalgia-ing over is the "Pedro the tank" game by Sammyspace Software, which was a freeware Scorched earth clone, with awesome graphics and horrific violence. Unfortunately, it seems all of the original DOS binaries have disappeared from the web... :(

EDIT: I finally found the DOS version of Pedro the tank, but most people don't know that there were actually 2 sequels as well. (They were Pedro 2: Nothing to do with Pedro, and Pedro 3 beta) Sadly, I can't find those, now... I've found the old pages on archive.org, but the zips weren't archived. :(


About

User