Rolling downhill on the result (recalculated each time the player moves) will cause monsters to flee for the nearest door. Take the result and pass it back through the Dijkstra scanning function. Multiply every value in the map by a negative number somewhere in the neighborhood of -1.2. Treat monsters that haven't moved since last turn as obstacles. Solution: Start with a Dijkstra map calculated around goal points at the player's location and at any player allies from which your monsters will also want to flee. This happens even if you use a Dijkstra map and try to roll uphill instead of downhill. If they just run away from the player, they'll bang their heads against the nearest corner of the room that they start in. The problem is that it's not easy to get them to flee intelligently. Everyone likes monsters that know how to flee. Here are the revelations I've had while making Brogue:ġ) Safety maps. Note that this 'rolling' works with both 4 and 8-way movement, though you might want to add additional code to ensure units don't clip through non-walkable cells if moving diagonally.īut there is SO MUCH MORE that these things can do. Make a Dijkstra map around a single goal point, and then no matter where you're starting from, you can just "roll downhill" on the Dijkstra map and you will reach the goal in an optimal number of moves. The resulting grid of numbers represents the number of steps that it will take to get from any given tile to the nearest goal. up, down, left or right a cell next to the one we are checking), set it to be exactly 1 greater than its lowest value neighbor. If any floor tile has a value greater than 1 regarding to its lowest-value floor neighbour (in a cardinal direction - i.e. Iterate through the map's "floor" cells - skip the impassable wall cells. To get a Dijkstra map, you start with an integer array representing your map, with some set of goal cells set to zero and all the rest set to a very high number. I call them Dijkstra maps because of their similarity to the basic Dijkstra pathfinding algorithm, but rather than conducting a strict breadth-first search from a single point or set of points, I mean doing the following: I don't know if there is a better name for these things. I came up with these while developing Brogue. This article describes a few simple, mechanical techniques that do not involve any hand-waving or complicated state machines, but that can nevertheless give rise to behaviour that is eerie in its seeming intelligence.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |