Mad Mage Postmortem

This is a postmortem of Mad Mage, the game of subverting roguelike Identification.

I went into Mad Mage with a pretty clear idea of what I wanted to do.


One of the things I decided early on was to do crappy map generation.  Specifically, I was going to just have a grid of X by Y rooms connected by passages, similar to the original Rogue.  The rooms would be assigned an order, and one room would lead to another.  Then, I’d add a few random connections between rooms.  From there, one room on each side would lead to the map edge to move on to the next region.  As much as I would have liked to do cellular automata, pathfinding corridors, etc, I haven’t sat down and implemented anything like that before, so I figured a time-sensitive contest wouldn’t be the opportunity to try that.

Here’s where it gets weird.  My straight line corridors worked as expected, but… well, I’m not a math guy, so I do a lot of cargo cult programming.  I struggled with diagonal passage connections until I got up to something that “kinda” worked.  But when linking the rooms, I forgot to keep in mind that some rooms were border rooms and could connect to fewer rooms than a middle room would – and that rooms should connect to roughly adjacent rooms.  The end result is that I had wild diagonal corridors leading all the way across the map, off the edges, etc.  The thing is, it actually looked kind of cool; it had a mineral striation vibe.  So I rolled with it and added a routine to make sure each map edge had an exit, grabbing crazy lines from anywhere in the map.
Also, I think the math is fundamentally wrong, as some of my diagonal corridors just stop in the middle of nowhere.  But again, it looks cool, so I’ll live with it.

I got the wild idea to add some more open maps, and that’s where the grasslands, swamps, and deserts come from.  They’re just wide open maps peppered with obstructions (trees, cacti) and attributes (water, bones).

Beyond that, I added some random surprises to the maps.  If you look at the source, they won’t be surprises at all, but I figured I’d make things mysterious for players wandering through randomly generated maps.

Map generation was originally supposed to be a copout, but I think I ended up with a cool-looking world.  The downside to the lack of pathfinding and better algorithms is that you’ll occasionally find stranded open spaces.  In the worst cases, you’ll get stuck somewhere and need to use Mist Form to escape through a wall.


You see in a 5×5 radius, not blocked by walls.  But you’re a wizard, so it’s okay – we can assume you’re using magic.  Monsters ALSO see through walls, but they are being driven by a force which provides such benefits, so there’s verisimilitude.  Basically, I was lazy as fuck with my algorithms, but I found a convenient plot device to justify it.

===Escape Key===

As I started developing and testing, I noticed that sometimes the game would hang for a few seconds after pressing a key.  Eventually, I narrowed it down to the realization that this happened when hitting the ESC key.  I didn’t care during testing, since I’m hardcore and adaptable, but I figured it’d piss people off if anyone actually plays this.  I did a little research and discovered that curses has some kind of escape delay built in.  Long story short, if you’re doing curses in c++ in Linux, this will make ESC stop being a bitch:

if (getenv (“ESCDELAY”) == NULL)

If you’re academically interested, go to; for more info.

This doesn’t seem to be an issue in Windows.  When I compiled on my windows machine, it actually gave me some kind of error about ESCDELAY not existing, so I commented it out.  Even without it, ESC worked fine.


I was laboring over exchanging pointers when I was messing around with swapping items between containers.  Then came std::swap via a google search.  I’d never heard of it before, but it did exactly what I needed, and I love it.

In other cases, rather than actually learning how pointers worked, I made a routine that copies all the variables between two classes while keeping the classes intact.  You’ll see this a lot in inventory management.

Here’s my rough guess of time spent on the game:
Sat    6 hrs
Sun    9 hrs
Mon    2 hrs
Tue    2 hrs
Wed    2 hrs
Thu    1 hr
Fri    2 hrs
Sat    5 hrs
Total  29 hrs

I’m sort of amazed that the game is as developed as it is within 29 hours.  Real life interfered significantly.  I really wanted to be done on Friday and spend saturday bugfixing, and that probably would have been good.

The threat of public shame and humiliation was a good motivator to spend my free time working on the project.  I spent zero hours fucking around the past week – it was sleep, work, maintain relationships with loved ones, work on Mad Mage.  I went an entire week without beer.  Having completed something like this, I’m humbled by how buggy Mad Mage is, but inspired by how cool it is and how much work I got done.


All development occured in GNU/Linux  (Ubuntu specifically).  I was vaguely aware/worried that I’d run into complications when compiling in windows, but as time went on I was just focused in getting something to work.

The windows version actually required a little bit of programming after my 6 PM limit, so the windows version is technically not a 7drl (but the Linux version is).  Specifically, I had to comment out the ESC delay stuff.  I also couldn’t match the enter key with KEY_ENTER – I had to change it to 13.  Same with backspace – had to choose some particular ascii code.  Those two codes only affected the newgame procedure – the rest of the game was perfectly cross-compatible.

The linux version looks really classy in my console.  It uses that monospace font and subdued colors.  The windows version also has appeal because the old school DOS ASCII/ANSI characters remind me of the days of yore (and Dwarf Fortress).  Mad Mage looks awful and runs slowly in wine, but whatever.

The source should be pretty easy to work with.  I haven’t set up a makefile or anything yet.  If you throw it all in a code::blocks project and include curses, it’ll compile.

I honestly haven’t tried it in Vista or Windows7, since I don’t have those environments yet.  No guarantees there.


The 7drl is a lot of fun, and I can’t wait to play everyone else’s games.

Also, somewhat of a grave NOTE* – the game seems to crash horribly in Windows Vista and Windows 7 when viewing the Pack.  That part may be a fun killer for you unless you’re on XP or Linux.

To download, go to

4 thoughts on “Mad Mage Postmortem”

  1. Congratulations on finishing to an extent! I got to play around with it for an hour and it was fun. When I first visited the website (Noticed it on RogueBasin first) I was reading the description and thought “Wow, this is an awesome concept, I’m going to try it! Oh, under development…Hmm.” Comes to show that I come here to find Mad Mage being developed for 7DRL, haha!

    So I started playing it and it was quite engaging. Eventually I forgot what everything was and it became a pain trying to find the darn ossuary, but I did!

    Congratulations on a fun game, it was really neat! Map generation seemed pretty neat, sometimes the caves ended up being funky and I had to turn around the moment I entered, but it worked out well!

  2. You’re mad, wiglud. I enjoyed reading this postmortem, and think I will go ahead and play Mad Mage a little bit more just now.

    But before I do, here are some thoughts:

    – love the monster and environment descriptions. too awesome!

    – your broken dungeon generation serendipitously makes mad designs, to this end your code is inherently mad, too.

    – ditto on the beer!

    – I’d like to browse the source after all the review madness has passed.

    – who needs an escape key, anyway? see 😉

Leave a Reply