Deprecated: Function set_magic_quotes_runtime() is deprecated in /DISK2/WWW/zweistein.cz/devdiary/textpattern/lib/txplib_db.php on line 14 Fate of Heroes Developer diary: Randomly generated roguelike maps arrived!

Randomly generated roguelike maps arrived!

Sep 12, 21:23

Well, surprisingly it was not that hard after all. Results are not ideal yet, but basics are covered:

As you can see, it looks quite different from typical roguelike map, looking more like circuit board than ‘true’ dungeon map. This has a lot to do with how it is generated:

There are several approaches on how to create map for roguelike, but generally, it is about placing rooms and then attempting to connect them. Rogue alorithm, for example works like this:

  1. Subdivide map to cells
  2. Place rooms to cells
  3. Connect rooms, ensuring that they are all accessible.

Most important thing here is subdividing map and tackling map creation locally on per-grid element.

I started by making library of map components, prefabricated map segments. Each segment is in relation to surrounding segments (that is, can be connected to them by small tunnel, wide hallway or not connected at all).

Then, creating map is simple matter of interating over grid and placing randomly chosen segments to place they ‘fit’. There is no magic involved: choose cell in which to put segment, ask library for list of matching segments and pick one randomly.

Here are some more examples:

As can be seen, they are not aestetically pleasing when displayed in their full glory, but when rendered inside game client, they are much better off because player can not see weird connections, limited to small displayed are and his memory of what is outside of it.

Now, this looks quite well, doesn’t it?

Zwei

,

---

Comment

Commenting is closed for this article.

---