Hot answers tagged

238

Game AIs are almost always non-competitive, because if the AI would really try its hardest to win, it would often be unbeatable. An AI is not bound to human limitations like reflexes, accuracy, perception, fatigue or computational ability. So when it is seriously playing to win, no human would ever stand a chance. Let's take the first person shooter genre ...


109

Slotting is a technique which is used to confront the player with an overwhelming number of enemies and still give them a chance to win. Instead of having all enemies attack at once, there is a limited number of "slots" of enemies which attack the player seriously, while the rest of the enemies keep their distance and just look threatening but do not do ...


89

The two are pretty different. The real indicator is in the names. Decision trees are just for making decisions. Behavior trees are for controlling behavior. Allow me to explain. A major difference in the two is the way they are traversed, likewise the way they're laid out and the node 'types' are different. Decision trees are evaluated from root to leaf, ...


79

A convex polygon has a very nice property: The shortest path between any two points in the polygon, or anywhere on its edges, is just the straight line between those points, and that line segment lies wholly within the polygon. So if your polygon represents a section of your level known to be obstacle-free, then you're guaranteed you can do the very simplest ...


68

This isn't common in all shooter games, but some do go to this level of detail. In Splinter Cell games, for instance, AI can detect Sam's individual body parts. When an AI is performing a detection check, we fire rays to selected bone positions in Sam's animated skeleton, and tally up how much of him is visible. (We also evaluate lighting per bone, so they ...


50

This sounds like a use case for Flow Fields. In this technique, you do a single pathfinding query outward from your player object(s), marking each cell you encounter with the cell you reached it from. If all your tiles/edges have equal traversal cost, then you can use a simple breadth-first search for this. Otherwise, Dijkstra's algorithm (like A* with no ...


47

A game's AI is a part of a game's overall design. At the end of the day, the AI you create needs to complement the game design. If your game is designed around creating a challenging, competitive environment, then a "perfect" AI might be a good thing. At the same time, you have to consider something very important: Humans aren't computers. Even without ...


43

The first step is to create a minimum viable product. A MVP is the absolute minimum which can be considered a playable game. It doesn't need any graphics yet except for some placeholders. It should just accept basic input and implement the most core game mechanics. Then iterate from there. The reason is that you need a test-bed for testing out if your ...


35

Firstly, you should know that the Myers-Briggs Type Indicator is a proprietary system - if you wanted to use exactly this system in your game you'd need to license it from the foundation that commercializes it. (It's also, in terms of scientific validity, kind of bunk - it's popular mainly due to effective promotion and application in flashy motivation ...


27

At first you see that your commands are in the form of a list, so your first instinct might be to recreate that structure, and each dwarf will run through that list in sequence. What I suggest though is to break the list into steps, with each step having prerequisite(s), and then you run the entire command in reverse. Let me demonstrate with an example: ...


26

As a preface, I'm going to correlate ethics with cheating. If you feel cheated, you feel something unethical has happened to you. In a nutshell, to make your AI's behavior acceptable, make the behavior it mimics believable. People don't feel cheated by believable behavior, they do feel cheated by unbelievable/unrealistic behavior. So be believable, and ...


23

If you really want to detect any exposed part of the player, the extreme approach is to simply render the scene from the gun's perspective using replacement shaders, such as the player rendering as plain white while everything else renders black - any pixels which are white in the result show a potential target. You can even use multiple colour channels to ...


22

My favourite imperfect pong AI is brutally simple, yet lets one do some rather nice AI failure. Invisible Ball AI AI Setup: When the ball reflects off your paddle, you know where it is and how fast it is going. Spawn an invisible ball at that point but at a greater speed. It will wind up where the visible ball is going. Each frame, have the AI move towards ...


22

I haven't looked at specific implementation of A* by Aaron but with a normal A* you could include the 'block tower' as passable terrain but update the heuristic so that the 'cost' is much higher than a normal tile (so that AI will evaluate whether it is easier to destroy the block and continue or simple go around via the path that is not blocked). Then you ...


22

I've worked quite a bit with Mecanim in Unity, and feel I have a quite good understanding of how it works. Like you say, blend-trees are almost definitely the way to go for doing locomotion. Blend-trees are generally for when you want to continously blend animations to create the final output. Like give the player the control of how fast the avatar is ...


19

Rather than solving your problem, here's a way to take the lemons and make lemonade. Many years ago a friend of mine was working on a very well-known FPS which had precisely the problem you describe: a constrained area would have a number of AI characters who had particular desired positions, and the path-finding algorithm was constantly bumping them into ...


18

You can start by letting the pathfinding fail. On failure, choose a random time in the future to re-try pathfinding. Some low level networking protocols work that way, and quite well. What you have to do is build paths one at a time, and mark as used all the tiles an agent will pass through. When further paths fail the random timer to restart will help ...


18

It's, I guess, about how the enemies run toward the player. Slotting implies that, to let the player survive and give her a chance to continue surviving, enemies coordinate themselves to not attack at the same time. So EnemyA will attack and continue attacking while EnemyB will wait his turn. John Romero, in this video, explains that to avoid slotting but ...


18

Yes. An AI should stay at the level that it was set to. A chess AI will beat all of us every time, and it's up to us to tune it to something we find enjoyable. I would never want the AI to dumb itself down when it sees that it's going to win, or have a pop-up saying "mate in 25, do you want me to be worse at chess?". Just beat me until I get tired of ...


17

There are two ways an AI controlled unit with a bound rotation speed and an adjustable movement speed could reach a goal. First, lets consider the challenge we are presented with so we could understand it better: If the player is moving and rotating in constant speeds while trying to reach a goal that is on its right or left side, it will move in circles ...


17

The dot product of two vectors can tell you if they face each other or not. First vector can probably be the enemies view direction the second one should be a vector pointing from player's position to the enemies position. https://www.youtube.com/watch?v=Q9FZllr6-wY


17

We can say that at some level the game is following a pre-computed path. Since the tracks of the racing game are (usually) a pre-computed path anyway. Even if we are talking about generating the tracks by random, the game must have computed the current portion of the tracks for the moment where the car gets there. Well, that was easy. Anything else about ...


16

See the image I provided in my previous answer: If you imagine that node 1 is 'Evade Enemy' and node 2 is 'Chase Enemy', you'll see that even though in the second iteration (when everything is green except for '2' and 'B' is when the second iteration starts), 'Evade Enemy' still gets checked first. Only when 'Evade Enemy' fails, because there are no enemies ...


16

Another technique is to mimic that used by Napoleonic battalions (and probably as far back as Greek phalanxes if not further). Frontage is generally maintained constant, and as a man falls (in any rank except the back) he is replaced by the man directly behind him stepping forward. The back rank is shuffled by the NCO's to ensure a few men at the extreme ...


14

When I created an oh-so-awesome almost-pacman clone on my TI83? calculator, the biggest problem I ran into was that the "ghosts" were far too fast. I had to slow them down somehow. So, I put in a big old sin(cos(tan(x-coordinate))) in there. Easier levels would do that calculation a few times, and harder levels would do only one of the operations. The ...


13

Like so much of gamedev, the answer to how city sim games accomplish this seemingly-impossible feat is: they probably don't. They're just faking it well. ;) Sims like these will typically operate on a "chunked" level, modelling groups of people, neighbourhoods, traffic corridors, or other city dynamics as a whole, rather than processing AI for ...


12

A very simple approach is to use "AI Level of Detail." Roughly, this means that you update AI more frequently the closer it is to the player/camera. You can also reduce the complexity of AI calculations that are farther out, esp. for path-finding. After all, if the player can't see the character well or at all, there's no point putting in a ton of effort ...


12

I would say no. You see for me games are first and foremost entertainment products. They want to deliver an experience to a specific audience. So it all depends on what experience and to what audience you want to make a experience for. Take a new game for example like Cuphead. This game is made for people who want the game to be hard and unforgiving and so ...


Only top voted, non community-wiki answers of a minimum length are eligible