Showing posts with label Map Generator. Show all posts
Showing posts with label Map Generator. Show all posts

Sunday, February 14, 2010

Frustration with "stitch" map generator...

As I continue work on iteration 8 when I get a chance, I'm becoming somewhat frustrated with my "stitch" map generator. To understand my frustration, here is the 10000ft view of how it works.

A graph of "nodes" is created, using probabilities from a map. That graph is dropped one node at a time onto a large "map", with the nodes next to each other in the graph next to each other. "Dropping" a node involved looking up one of multiple templates from a text file of that type, and placing it so the seams line up. If a node can't be dropped, we add it to a list of nodes we can drop later if we run into a room that doesn't have an output assigned. There is come complicated logic to prevent us from dropping a long group of halls and then being unable to place the endpoint room from leaving the hall. Once we have the graph generated into rooms, the map is "trimmed" so it isn't larger than it needs to be, checked for connectivity, and in/out stairs are placed.

The flaw in the system that keeps biting me over and over again is the separation between the "graph" and the actual map. It makes some things that you'd think were easy, such as dropping doors between rooms difficult. The latest thing I was trying to fix was the fact that the map looked like a spreading tree (since it was). Once you went down a hallway, you'd never reach any of the rooms in any of the other hallways. My idea was to patch this by finding empty "seams" in rooms and trying to draw hallways between them if possible. After burning an hour, I'm frustrated since by the time I've reached the hallway placement stage, I've lost all the information on the map structure and which nodes I'm working on.

I've booted the feature to iteration 9, and in that I'll decide if I want to refactor this map generation to something easier to work with or rewrite it new. Does anyone have any references to map generators that produce great looking maps with hallways, rooms, and such?

Tuesday, November 24, 2009

More Map Madness

So, I don't want to call the map generator "done" yet, but it's good enough for me to move on I think. It now handles all the cases I think are important enough for my first pass. Here's a picture of a map (with FOV turned off) to give you an idea.





As I mentioned before, I've nicknamed this map generator "Stitches". I took some inspiration from torchlight when I came up with the idea. Since it reads "chunks" from a file, if I keep adding more and unique chunks, better quality maps should result. For example here is one of the room chunks:

7 7 MainRoom
###^###
#.....#
#.M#M.#
^.###.^
#.M#M.#
#.....#
###^###

The '^'s are where the map generator can connect up other segments, '#'s are walls, and 'M' are monsters.

Now that both generators are "good enough", I can concentrate on my next tasks. I have two iterations planned before my text "tech demo" release.

Iteration 6 (Current)
  • Map Generator Work
  • Multiple levels, with stairs connecting
  • Help Screen
Iterator 7 (Combat)
  • Wands
  • Multiple monster types (more on this in another post)
  • More spell effects
  • Color!


Sunday, November 22, 2009

Map Generator, and the need to do other things

So the last 2-3 weeks, I've been working on map generators for magecrawl. Here's a few examples:


This is my "Stitch" map generator. It generates a graph of entrances, halls, and rooms, then reads "chunks" from a file and stitches them togeather to make a map. Right now, it looks pretty boring since there is only one room type and 4 hallway types. While there are some issues, I'm pretty proud with it.


 

This is the 'cave' map generator. It implements this algorithm for generating caves with some tweaks. It seems to give more consistent maps than my stitch generator.

The only issue I'm having is that staring at map generators during all my free time gets a bit boring. Last week I implemented a few 'nice' features that were suggested from those who played with the magecrawl tech demo gruop. This week I worked on cleaning up the code, using my point struct instead of int x, int y where reasonable and LINQing up the code where it makes sense.