Geeks With Blogs


Google My Blog

Catch me at: The List!

My InstallScript Utility Belt My Amazon Wishlist
My Standard Disclaimer

Chris G. Williams Beware: I mix tech and personal interests here.

In roguelike games, like HA!, there is a feature called "autowalk" that is part timesaver and part AI.

When your hero is walking down a long (and possibly curvy) hallway, instead of hitting the arrow keys 40-50 times to get where you are going, most Roguelikes let you hit "w" and a directional key. The intent is that your character will walk in the direction (including making corridor turns) until it reaches an obstacle. These obstacles can be anything from a door, an intersection, or an encounter.

The down side to taking an autowalk is that you (typically) aren't taking the time to search for traps or secret doors, or to observe monster movement patterns. You simply indicate a direction to start walking and the game handles the rest. It's still turn based, and monsters move each turn, so interesting things can result.

Standard behavior is to walk all the way up to a door or intersection, but to stop a few spaces away from a potentially hazardous encounter. This might be a monster (or trap or secret door.) While you aren't doing a thorough search for the latter, some races are just better at detecting that sort of thing in passing. On the other hand, not detecting a trap isnt the same as avoidance... ouch.

From a developer perspective, autowalk presents some interesting challenges. It's easy enough to ask the player for a starting direction, but unless all your halls are perfectly straight and end at a door, you're going to have to help your hero make some decisions along the way. You'll also have to take monster turns and various effect durations into account. Every step the hero takes is a turn, whether it's at your direction or by automatic pilot, so normal gameplay rules apply.

There is some basic AI involved, such as checking each upcoming square to see what it contains.
- Is it another floor space? If so, is there anything in it? Should you ignore items on the floor or autograb them? (Given the risk factor, this is a good toggle setting for the player.)
- Is there a door in front of you or beside you? May want to stop.
- Is the space in front of you a wall? If so, don't walk into it. Instead look to see which direction contains an open floor square and head that way. Is there more than one empty floor square (not counting the one you just left) adjacent to your position? If so, you should stop since you're likely at an intersection or room entrance.
- Are you within 2 squares of a creature or NPC? Better stop.
- If your hero detects something hidden, such as a door or trap, you may want to stop instead of setting it off. Of course if you hero doesn't detect it, well...

This doesn't really fall into the same category as pathfinding, since that typically involves getting from point A to point B without input from the player. This is usually accomplished by determining path costs based on the nature of terrain the character must traverse. If something is impassable or difficult, it has a higher "cost" than open terrain, and simple pathfinding algorithms use the lowest cost path. In the same manner, straight lines (where possible) are "cheaper" than long circuitous routes.

So why am I writing about this? Well, I spent a few hours on HA! this weekend (I gave up sleep for lent) and the main thing I worked on was autowalk. As I mentioned before, it's a staple feature of most roguelike games, and HA! needed it. It's not quite done yet, but should be soon.

I also added some extra information to the character generation screen. You can now see the individual attribute bonuses (post race-mod) as calculated for the various skill checks, combat, etc.

Posted on Sunday, March 4, 2007 9:01 PM Game Development , Heroic Adventure! | Back to top

Comments on this post: autowalk

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Chris G. Williams | Powered by: