Wolfenstein AI
What's a good way to let monsters in a raycasting game behave kind of smart? I want them to be able to (once awake) find the shortest path in the world to the player, and open doors when they encounter one. The must not really find the shortest path to the player, but the shortest path to a point where they can shoot the player (except for melee monsters of course). It would also be cool if monsters that shoot slow missiles would shoot them so that they'll hit the player when he moves with constant speed. EDIT: Does there exist a way to do this in such a way that I do a simple calculation for every monster every frame, rather than precalculating a path that has to be updated everytime the player moves?
Monster AI in raycasters only needs to be thought of as monster AI for a top down game like nethack, seeing as most raycaster (if not all...) maps are stored in 2d arrays. And the map probably has enums for WALL, FLOOR, DOOR, etc, which means the monster will be able to tell what type of "tile" is next, right? So it can take appropriate actions. Now, if you want the monsters to just chase after the player, you could simply do some stupid AI like "if the player is left, go left while there is no wall," in all 4 directions. This will, however, have them walking into walls.
I would probably look up some maze traversal algorithms, and have the player location be the "end" locations. Common brute-force maze traversals use recursion (which I wouldn't necessarily recommend). I am sure A* could be applied to this...
Good luck!
I would probably look up some maze traversal algorithms, and have the player location be the "end" locations. Common brute-force maze traversals use recursion (which I wouldn't necessarily recommend). I am sure A* could be applied to this...
Good luck!
Don't know much about AI, so bear with me if this is completely useless, just throwing ideas out here. Opening doors shouldn't be much of a problem, just send an "OpenDoor()" message or something.
For the moving to the player, why not break each straight section into a 'room,' whether it has a door or not. Then just give the monsters a motion vector towards the 'door'(the opening to the next 'room) that would lead them 'in the direction' of the player. It would be pretty simple having monsters doing this from 1-2 'rooms' away, and there wouldn't be much of a need for monsters more than 3 'rooms' away.
To do a simple calculation for the monster every frame, couldn't you get a vector to the players current position, then get the player's vector and create a second motion vector for the monster from that. Then just interpolate over time between the two monster's vectors.
I'd give you code or something, but I'm a 'n00b' and know nothing about AI, like I said, just throwing ideas out.
PS:Your article on the Fourier Transform has been amazingly helpful in my research of the topic, and not to get off topic, but one part I just have a quick question on. Phase doesn't affect the transform of a wave right?(That's what my understanding was.)
For the moving to the player, why not break each straight section into a 'room,' whether it has a door or not. Then just give the monsters a motion vector towards the 'door'(the opening to the next 'room) that would lead them 'in the direction' of the player. It would be pretty simple having monsters doing this from 1-2 'rooms' away, and there wouldn't be much of a need for monsters more than 3 'rooms' away.
To do a simple calculation for the monster every frame, couldn't you get a vector to the players current position, then get the player's vector and create a second motion vector for the monster from that. Then just interpolate over time between the two monster's vectors.
I'd give you code or something, but I'm a 'n00b' and know nothing about AI, like I said, just throwing ideas out.
PS:Your article on the Fourier Transform has been amazingly helpful in my research of the topic, and not to get off topic, but one part I just have a quick question on. Phase doesn't affect the transform of a wave right?(That's what my understanding was.)
if(this.post == SATISFYING){money.send(1.00,&HemoGloben);return thanks;}
Quote:
Original post by HemoGlobenPS:Your article on the Fourier Transform has been amazingly helpful in my research of the topic, and not to get off topic, but one part I just have a quick question on. Phase doesn't affect the transform of a wave right?(That's what my understanding was.)
Phase doesn't affect the amplitude of the transform, but it'll affect the imaginary and real parts of it (but those are never used as far as I know, at least not in electronics ;)).
The vast majority of first person shooters simplify the problem by only giving a monster small areas of responsibility. Most monsters will not follow you if you go through a doorway because you've left their area of responsibility. This eliminates the need for complicated path-finding or maze searching. When you make such a simplification, the optimal path is almost always a straight line.
Modern games, however, have become more complicated and don't make these assumptions. There's enough CPU power to actually do a pathfinding algorithm that allows a monster to chase you once he's aware of your presence. But you asked about wolfenstein, and the wolfenstein AI is not very complicated at all.
Modern games, however, have become more complicated and don't make these assumptions. There's enough CPU power to actually do a pathfinding algorithm that allows a monster to chase you once he's aware of your presence. But you asked about wolfenstein, and the wolfenstein AI is not very complicated at all.
1) Pre-process your level geometry to create a graph of nodes, connected by arcs, where the nodes are well-chosen spots in doorways and centers of rooms, and arcs are passability between nodes.
2) Figure out the closest reachable node to the player.
3) Figure out the closest reachable node to the enemy.
4) Run path search (such as A*) from enemy node to player node.
5) Follow this path by walking the list of nodes you come up with.
6) Repeat as necessary.
You can mark nodes that are in doorways with "need to open door" if that's the case, so the AI knows to stop and open the door when it gets there. Same thing can even be done for elevators, keycards, etc.
I think Unreal used a system much like this, except you had to place the nodes manually, rather than having pre-process generate them. Note that the pre-process will be the hardest thing to get right in this system, so you may choose to do it manually, too.
2) Figure out the closest reachable node to the player.
3) Figure out the closest reachable node to the enemy.
4) Run path search (such as A*) from enemy node to player node.
5) Follow this path by walking the list of nodes you come up with.
6) Repeat as necessary.
You can mark nodes that are in doorways with "need to open door" if that's the case, so the AI knows to stop and open the door when it gets there. Same thing can even be done for elevators, keycards, etc.
I think Unreal used a system much like this, except you had to place the nodes manually, rather than having pre-process generate them. Note that the pre-process will be the hardest thing to get right in this system, so you may choose to do it manually, too.
enum Bool { True, False, FileNotFound };
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement