Map generation #4.5 – tidying up some ends

In my last post about this map-making process, I seemed to have left off at the part where the image itself is generated in its own separate program. Converting this image into a matrix for use in Graff was relatively straightforward. Pygame’s surfarray module allows one to access a surface (the screen) and treat it as a matrix of color values. From there I pulled out the color, used a dict datatype to convert that color into a tile type, and then write that into a matrix for use with the Graff; that wasn’t much of a problem.

However, one glitch I’ve noticed is that often the map would have some holes in it–it seemed like the algorithm would skip over a tile, perhaps because it couldn’t find a properly-fitting tile, so sometimes you get things that looked like this:

glitchy tiles

As it turns out, that was the case. I simply did not make enough tiles to cover each possible combination. After thinking that I’d have to make a mind-boggling number of additions to the 6×6 tile pieces I already have, I edited the code so that if the tile it needed could not be found, it should spit out that key combination and then I’d see where that would take me. Altogether, only about 30 “impossible” combinations of tiles ever seemed to come up, so I just added those extra ones onto the tileset.

After doing that, the results are much cleaner. Some glitches still remain (mainly I missed a few combinations, it seems), and I’ll probably adapt this to work with a smaller scale (say 3×3 instead of 6×6) or make changes to it to develop other areas, but I think I’ve just about exhausted the usefulness of posting about this process.

Still a little glitchy, but better!

Oh, there is also the problem of the map not always being one complete piece. I still haven’t decided in what way I’ll solve that one yet, but there are some more interesting questions about Graff that I think I need to find an answer to first.


5 Responses to “Map generation #4.5 – tidying up some ends”

  1. Scott Barlow Says:

    Hey, this is Scott (Made a number of comments on the pygame page). I wanted to let you know, that I still see this problem as described in this post. Send me an email and I’ll send you the screenshot if you want.

    I’ve only seen it (so far) at the exit of the dungeon.

    • hahn Says:

      Heya, I remember you 🙂

      Yeah, there’s still some issues with the odd gaps–it’s primarily because I just haven’t finished adding in extra corner cases to the tiles. : x I have a bunch of screenshots saved already, one of these days I’ll get around to fixing them.

      Oh yeah, and ditto with the dungeon exit being placed oddly.

  2. Scott Barlow Says:

    Ok, do you also get cases when you go into the dungeon, but you cannot get to the exit? I was sometimes going into the dungeon and was stuck in a small room with no way out. Other times, I could roam around and get almost anywhere, but the exit was in the middle of darkness with no way to reach it.

    Thanks for all this work!

    • hahn Says:

      Haha, yeah that is indeed the case sometimes. With the default keys, press J K L and I to “dig out” a floor tile to push your way through. Careful with the bounds though as I don’t set an upper limit on it (IE it’ll crash if you try digging a tile on the edges of the map). A slightly more intelligent version of digging is coming in when I next update the code.

      Ditto goes for how to reach an inaccessible staircase–at present I just arbitrarily set it’s spawn point to be at something like (60,60) on the map grid every time, so it’s a toss up as to whether you can actually get to the place, heh.

      And hopefully after that digging gets fixed, a slightly more intelligent (read: self-connecting) map generator will also be modified & thrown in.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: