Top game AI

I am creating a game that requires units on the screen to fight each other, based on teams and designated opponents for each team. The player does not control any of the tanks or teams.

The problem is that the battle between units (tanks at the moment) should be interesting enough for the player so that they can watch and enjoy without doing anything.

Currently, I have tanks that move absolutely randomly and shoot at each other when they are in range, but I'm looking for something smarter.

What types of algorithms ai and ai should be studied? All ideas are welcome, I just want every battle to be interesting.

+7
source share
2 answers

For strategies and tactics, your AI probably needs to make some rational decisions to make it more intelligent. There are many ways to do this, the easiest way is to write down a few rules of the conditions of action for your tanks and implement them as a finite state machine. FSMs are easy to implement and easy to debug, but it gets tedious later when you want to revise the rules of the conditions or add / remove any conditions. You can also use agent utilities - AI checks the operability of each potential target (for example, hire, retreat, reload / refuel, take cover, repair, etc.) Based on current statistics (ammunition, health, number of enemies and locations) periodically and then selects the most preferred target. This takes more time to implement than FSM, but it is more flexible in the sense that you do not need to change the flow of decisions when you need to add or remove behavior. This makes AI look like it follows a general rule, but is not always predictable. The agent utility is also more difficult to debug and control, because you do not have strict rules for the conditions for tracking how you do with FSM when your AI goes crazy. Another popular method is the behavior tree. Sequences of actions are implemented as a tree structure. This requires more code to write up, but usually gives you a better balance between control and flexibility than the FSM and service agent. These decision-making processes are not mutually exclusive - you can use any method for top-level strategies and another method for low-level tactics.

No matter which decision-making process you choose, you need some input to feed your AI. You can use the influence AI card to determine where on the battlefield is considered hostile and where it is considered safe. The influence map is distributed between the team, so it can also help in group tactics. When your AI involves multiple enemies, it is important to choose the right target. If your AIs choose a target that most people don’t own, the player will feel that the AI ​​is “stupid,” even when sometimes the chosen target is actually the best. You can perform remote verification on enemy units and filter / prioritize the target using the line of sight, the current range of weapons, the level of threat, etc. Some tests are more expensive than others (eye testing is usually one of the worst offenders), so if you have a lot of enemy units within range, you want to run those slower tests last.

Study the steering behavior for tank movement. It covers a lot of vehicle driving behavior, but chasing and dodging are the ones you need the most. Also look at A * to find a way if your tanks must navigate difficult terrain. There are other good solutions that give you the shortest / fastest way, but in the game the shortest / fastest way is not always the best way. If your shortest path is open, but too close to the enemy’s line, you want to give your tank a heuristic to take another route. You can easily customize your path with A *.

What you need to see: finite state machine, utility-based agent, behavior tree, steering behavior, search algorithm *, navigation waypoints or navigation grid, influence map.

+9
source

The simplest would be to make them move in a random direction and when an enemy tank is in range, they start firing until one of them is destroyed. You can also randomly retreat when their health is too low. You can also try to add group tactics when a tank that will not be involved joins (with some ability, so that maybe it will happen, maybe it won’t just be interesting) is the closest neighbor in battle .

If you are looking for algorithms, A * ("A-Star") is a general path-finding algorithm that can help your tanks move around, but I don't know any general algorithms for battle control.

+2
source

All Articles