In the ATTACK state, the shopkeeper is fairly adept at finding the player, although the underlying AI is nothing special. Pathfinding is an area with a lot of research behind it and there are a variety of algorithms that people use to get a non-player character (NPC) from one place to another. For the shopkeeper, however, my simple solutions worked just fine. His ATTACK AI can be summed up like this: Every now and then, turn toward the player. Every now and then, fire my shotgun at the player if they are close enough and I have the shotgun. If the player is below me, and not too far away from
...more

