Answer the question
In order to leave comments, you need to log in
How does AI work in games?
Hello. Maybe I asked the wrong question.
Tell me how AI is implemented in games. For example in the same SIMS or for example CS with bots?
Is each individual character a separate thread or do they calculate their actions sequentially?
I want to try to write a small game for myself with simple AI, but I don’t know how to implement it correctly.
I couldn't find anywhere to read about it.
Answer the question
In order to leave comments, you need to log in
There are many approaches to the development of AI, the specific implementation depends on the specific game, somewhere two rules are enough that react to events, somewhere you need to build behavioral trees. They usually start with finite automata, as the easiest to implement, then behavioral trees and Utility AI go further in terms of complexity, you can read about all three in the article on gamasutra . In addition, you can read pdfs with articles on the Game AI Pro website . If you like to watch presentations more, you can look at the GDC channel .
Whether the code is executed in separate threads or not does not apply to AI development, it's just an optimization that is used according to the situation.
For a beginner will do:
"game maker"
Google and find a ton of examples
Study, and then create your own games)
Good luck!
On Habré there was an article about AI recently.
Well, seriously, the AI is completely dependent on the game. Next comes the engine. Well, then everything else. For example, there is no AI in poker at all.
AI (AI) is called purely by tradition.
As a rule, it does not smell of any real AI there.
A full-fledged AI in games can only be called https://habrahabr.ru/post/319518/
And usually, certain rules are simply sewn into the program, clearly tied to the logic of the game.
Well, for example, for PacMan (I hope you know the rules of the game) - the monster at each turn simply chooses the shortest path to the hero. The path is built simply by blunt enumeration. Choice of the shortest - too.
For simple AI, a switch case or a bunch of if then else is enough
https://habrahabr.ru/company/intel/blog/265679/
The question is rather about "scripted game logic in games." Think about a key example (pseudocode):
monster1.walkTo(level.homepointA); // идет из текущей точки в точку A, длится минуты
monster1.walkTo(level.coverpointD); // идет из точки A в точку D, длится минуты
monster1.fireAt(enemy, 5.0); // стрелять по врагу 5 минут
monster1.walkTo(level.homepointA); // идти обратно в точку A
This cannot be called AI, it's just a bot that is controlled by the game engine depending on the situation. It analyzes the information received and, depending on it, takes the action for which it is programmed.
Imagine, it just takes and works!
But in fact, this is not AI. These are just sets of decisions for each player’s action. AI is now weak and capable of making only one or several goals of the same character. Make a tic-tac-toe bot and you will stick for a month.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question