Pathfinding At Last!

I probably mentioned before (or maybe I didn’t) that the monster AI in HamQuest was rather simplistic.  It was essentially the following:

1. Flip a coin

2. If it lands on heads, move the creature randomly

3. If it lands on tails:

3a. If creature y > player y, move north, and done

3b. If creature y < player y, move south, and done.

3c. If creature x < player x, move east, and done.

3d. If creature x > player x, move west, and done.

Naturally, while this gets the monsters generally towards the player over time, it mostly just made the monsters line up, and it was easy to manipulate their movement, especially because they could not move through items.

So, I implemented a very simply A* based system that allows the monsters to look at the “how far away am I ” value of its neighboring cells, and move to the one with the lowest value.

And I tried it out, and the monsters swarmed the player, quickly overwhelming and killing him.

So I put the random factor into the movement again, but made it a different chance of random movement for the various monsters. Goblins and thieves move more randomly, whereas the undead move dead on for the player.  The summoner and necromancer move the most randomly, as their job is to throw monsters at the player.

I also haven’t won a game in a really long time, and I have NEVER managed to kill a dragon.


One thought on “Pathfinding At Last!

  1. Yeah, that minus the coin is Zombie Kitten Attack. Of course, in Zombie Kitten Attack you’re unarmed and the whole point of the game is to leverage their very predictable movement to make the kittens kill each other.

    Well you’re not entirely unarmed, but the weapons are pretty ineffective, basically to get around the fact that the levels aren’t guaranteed to be beat-able just by steering cats into buildings and each other.

    Although an A*-based “smart kitteh” that can walk around buildings might be a good new wrinkle. Maybe for the sequel.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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