1) Like 'opless wrote, AIs in most games are simple; they're designed to execute in real-time.
2) From the point of view of a networked game, AIs and players are the same - the server(s) only care about inputs. The difference between keyboard input and AI input need not to be relevant, and this suggest a trivial approach - execute AIs on clients, and send their inputs along with players' inputs.
I'd suggest digging through old EVE:online devblogs and presentations. They describe server architecture and design points, as well as the process of tuning those with each other and actual community use.
https://community.eveonline.com/news/dev-blogs/ https://www.youtube.com/channel/UCwF3VyalTHzL0L-GDlwtbRw
That seems strange, you'd be sending multiple times the same AI's actions to the server, in which case you better be certain that it's deterministic, not to mention the security concerns. It seems far easier to execute the AI on the server and send its actions to each player, especially if it's a trivial AI.
Of course, for this, you need a bit of determinism, and some games need to synchronize other parameters, which can lead to "security" concerns: bullet spread, hit detection and such for FPSs, for example.
This can also lead to some hilarious de-sync issues when a player tries to cheat on its local game instance. By altering its local state, the AI is effectively desynchronized, and the players can observe different outcomes on their local instances. This is often used as a punishment for cheating.
The alternative (for serverless, p2p games) is to have a central host, but it might take a lot of computing resources, and the host is then generally free to cheat.
One side effect of having deterministic AIs synced over the lobby is that the code needs to have the exact same behavior, down to the rounding errors. This can dramatically increase the complexity of cross-platform multiplayer games, and usually requires the exact same binary to be used by every client.
I think that Civilization and Sins of a solar empire use this kind of distributed AI scheme (as well as most games that don't have cross platform multiplayer, and those where you can experience de-syncs).
This gives you the benefit of low-latency on the client (don't have to wait for the server to tell it what the AI is doing) but also avoids security and non-determinism worries. (Although the AI might still be non-deterministic, it probably can't diverge too much before the client receives the next snapshot from the server).
This might be more effort than it's worth, though...
Sure, if you can execute AI server-side, go ahead. But the GP asked about scaling it up, and this offers a trivial way of doing so.
Really no that much different from what the Pacman ghosts did, just developed further from there (especially during the Golden Age of strategy games during the late 90's and early 00's).
With this base, scalability is achieved through fairly traditional performance optimizations (mostly using the right algorithms and data layout, especially for path-finding and 'visibility checks').
Also in strategy games, AI is often layered like a military chain of command, where the "commander AI" only makes high level strategic decisions and only has a very 'sparse' world model, while the lowest level 'soldier' AIs are mostly occupied with pathfinding but only know about their immediate surroundings.
Also, each game genre has their own highly specialised, hand-crafted "AI" algorithms. A first-person-shooter AI is completely different from a car-racing-game or realtime-strategy game.
I remember working at a games studio years ago and a kid straight out of university joined us after doing a degree in AI - assuming that games used real AI. Nope, it's all smoke and mirrors.
An important sentiment I've heard many times on the gamedev.net forums is that machine learning techniques are usually too difficult to tune in order to make the agents behave in the way that the designer wants.
Game AI is about providing an illusion of intelligence and about providing a designer-crafted experience to the player. So it often makes sense to cheat in order to achieve this.
Having said that, some games really do benefit from smarter AI. For example, real time strategy games sometimes do (eg Supreme Commander AI mods, AI War Fleet Command etc) and often first person shooter bots as typical dumb bots are simply not as fun to play against than real humans, although you mostly want the bots to have some high level tactics ability (not perfect aim or such), which is why the game FEAR is often applauded for having fantastic AI (it uses Goal Oriented Action Planning to produce high level tactics such as flanking). But most games don't go very far at all.
http://doom.wikia.com/wiki/Monster_behavior
An agent's set of possible actions is conditioned on its environment, other NPCs as well as the players actions. Even for a finite number of variables you can quickly see how the problem becomes computationally expensive for a single agent.
You want to to build unsharded persistent worlds with complex character behaviours and allow millions of online simultaneous players all sharing the same game state? Then you need to take a page from architects building scalable cloud computing infrastructure and applications that serve billions of request per second with low latency.
Companies like improbable.io are abstracting game state and logic with SpatialOS. But I think there is still a lot of room here for some startup to combine "Unreal Engine + AWS". Creating a true "cloud native game engine". Even if its just HTML5 based and targeting games such as Slither.io.
Quest - An iOS "io" Game from Improbable
https://improbable.io/games/blog/quest-an-ios-io-game-from-i...
Most game "AI" has nothing to do with the currently trendy "AI" based on linear algebra and neural nets. It's much, much simpler, partly because it has direct access to the game state and doesn't have to do any sensor processing.
"GameAI" tends to be a bag of puppetry tricks. You don't even need the strategic depth of chess, just something that gives you an interesting enough and varied enough move/fire pattern.
So making the bots not a little bit more clever, but really a lot more clever, would improve the game.
OpenAI created a bot for the Dota 2 tournament and it makes the professional gamers look like beginners sometimes.
Either state machines or behaviour trees. So they're designed to be quick to execute by design :)
Edit: undo autocorrect typos
1. Precomputing information for all agents, like using global shortest path (Bellman-Ford).
2. Abandoning per-unit subjectivity (a lot of units will share same view) or in other words: limiting internal unit state, using a shared state between groups of units.
3. Decoupling expensive algorithms into multiple simple steps. (Like state machine simplifies regular expression.)
4. Using separate AI and visualization thread, and using low amortized cost data structures (priority queues etc.).
You may observe all these three rules by anomalies in unit behaviour. Play http://www.screeps.com to learn a lot about modern RTS AIs :-).
- Running AI at a different frequency than the game. The network event loop might run at 30Hz (33ms tick delta) but AI doesn't need to make decisions that often, maybe every 100ms or 500ms etc.
- Separate decision making from performance. A cheap execution system can run at a high frequency, while an expensive decision making system runs at a lower one.
- AI LOD. Mobs that are far away run much simpler AI that doesn't try to perform detailed animations etc. Mobs that are in unpopulated areas get frozen, and thawed once somebody enters.
- In instanced dungeons, mobs don't even exist until the players enter, and once players leave, the mobs just get unceremoniously killed.
- Offloading. Mobs are just game agents so in online games it's possible to offload them to other servers that get load balancer as players move about, areas get frozen etc.
Basically the big question is: if nobody is interacting with a mob, does it need to exist? In most online games they do not. And even in sim heavy games, maybe they don't need to run the same high fidelity AI when nobody is watching.
Then the last tip is:
- Make the AI as cheap as possible for the task at hand, but no cheaper. A mob in MMO that is all aggro and easy to kite doesn't need to have complex strategic cognition, and it would probably be a detriment. Everything need a to match it's context.
Source: I make games. :)
I feel like this isn't what you're getting at though. Perhaps there's a specific example you have in mind?
There definitely is lots of room for interesting applications of "real" AI in games. Apart from NPCs, learning and building models about the player has lots of potential too.
The interesting-game-ai field is of hard to keep track of, because the search resuls are full of combat AI discussions, which is pretty uninteresting.
So, instead, when they decide they want a service, they reserve their place there and then and then just walk to their spot. A completely hidden variable, cheap to compute, and the AI now behaves "sensibly".
In general, the AI of the average opponent in a computer game is way less complex than that of a housefly. Primitive communication and responses to external stimuli is about all there is.
The premise is wrong, in many games AI can be extremely cheap. It's usually not the same "AI" as in other fields. Game dev is a completely different dimension.
So the enemies have to be controlled server side not locally. Also there can be (and will be) a lot of enemies around the "Destiny world" at the same time. What kind of servers do you need for that? That's not just processing HTTP requests and fetching data.