TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How does an online game with AIs manage so many AIs?

67 点作者 maruhan2超过 7 年前
Each AI should use up a pretty significant resource of the server running the AI. How do the games possibly manage so many of them? Most education on AI is how to make them smarter, not how to make them cheaper. There has to be well known tips and tricks about scaling AI. What are they?

14 条评论

flohofwoe超过 7 年前
It&#x27;s not &#x27;AI&#x27; (what actually is?), but mostly hand-crafted state-machines trying to achieve game-specific goals, which directly inspect the current game state instead of trying to build their own &#x27;world model&#x27; (of course with restrictions like fog-of-war, visibility-checks and so on so that the cheating isn&#x27;t too obvious).<p>Really no <i>that</i> 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&#x27;s and early 00&#x27;s).<p>With this base, scalability is achieved through fairly traditional performance optimizations (mostly using the right algorithms and data layout, especially for path-finding and &#x27;visibility checks&#x27;).<p>Also in strategy games, AI is often layered like a military chain of command, where the &quot;commander AI&quot; only makes high level strategic decisions and only has a very &#x27;sparse&#x27; world model, while the lowest level &#x27;soldier&#x27; AIs are mostly occupied with pathfinding but only know about their immediate surroundings.<p>Also, each game genre has their own highly specialised, hand-crafted &quot;AI&quot; algorithms. A first-person-shooter AI is completely different from a car-racing-game or realtime-strategy game.
评论 #15236717 未加载
评论 #15238438 未加载
评论 #15237158 未加载
miga超过 7 年前
Most of the work needed for decisions is shared between AI instances using a few tricks:<p>1. Precomputing information for all agents, like using global shortest path (Bellman-Ford).<p>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.<p>3. Decoupling expensive algorithms into multiple simple steps. (Like state machine simplifies regular expression.)<p>4. Using separate AI and visualization thread, and using low amortized cost data structures (priority queues etc.).<p>You may observe all these three rules by anomalies in unit behaviour. Play <a href="http:&#x2F;&#x2F;www.screeps.com" rel="nofollow">http:&#x2F;&#x2F;www.screeps.com</a> to learn a lot about modern RTS AIs :-).
评论 #15237112 未加载
pjc50超过 7 年前
&quot;AI&quot; is a ridiculously general term. People use it to talk about everything from line-following robots to machine vision and speech &#x2F; natural language recognition.<p>Most game &quot;AI&quot; has nothing to do with the currently trendy &quot;AI&quot; based on linear algebra and neural nets. It&#x27;s much, much simpler, partly because it has direct access to the game state and doesn&#x27;t have to do any sensor processing.<p>&quot;GameAI&quot; tends to be a bag of puppetry tricks. You don&#x27;t even need the strategic depth of chess, just something that gives you an interesting enough and varied enough move&#x2F;fire pattern.
评论 #15236970 未加载
评论 #15237031 未加载
60654超过 7 年前
There&#x27;s a number of tech solutions to scaling mob AI. Most of these are also applicable to non-online games as well:<p>- Running AI at a different frequency than the game. The network event loop might run at 30Hz (33ms tick delta) but AI doesn&#x27;t need to make decisions that often, maybe every 100ms or 500ms etc.<p>- 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.<p>- AI LOD. Mobs that are far away run much simpler AI that doesn&#x27;t try to perform detailed animations etc. Mobs that are in unpopulated areas get frozen, and thawed once somebody enters.<p>- In instanced dungeons, mobs don&#x27;t even exist until the players enter, and once players leave, the mobs just get unceremoniously killed.<p>- Offloading. Mobs are just game agents so in online games it&#x27;s possible to offload them to other servers that get load balancer as players move about, areas get frozen etc.<p>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&#x27;t need to run the same high fidelity AI when nobody is watching.<p>Then the last tip is:<p>- 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&#x27;t need to have complex strategic cognition, and it would probably be a detriment. Everything need a to match it&#x27;s context.<p>Source: I make games. :)
opless超过 7 年前
Most AI in games are simple.<p>Either state machines or behaviour trees. So they&#x27;re designed to be quick to execute by design :)
评论 #15236080 未加载
TeMPOraL超过 7 年前
Two things:<p>1) Like &#x27;opless wrote, AIs in most games are simple; they&#x27;re designed to execute in real-time.<p>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&#x27; inputs.
评论 #15236322 未加载
评论 #15236333 未加载
new299超过 7 年前
For many games (shooters etc) making a smart AI is relatively easy. What&#x27;s hard is making an AI that&#x27;s provides a realistic and interesting challenge. These &quot;AI&quot;s don&#x27;t use much in the way of machine learning however.<p>I feel like this isn&#x27;t what you&#x27;re getting at though. Perhaps there&#x27;s a specific example you have in mind?
fulafel超过 7 年前
Most comments here are explaining what&#x27;s meant by game AI&#x27;s and how they&#x27;re not closely related to &quot;AI&quot; as understood in other fields.<p>There definitely is lots of room for interesting applications of &quot;real&quot; AI in games. Apart from NPCs, learning and building models about the player has lots of potential too.<p>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.
euphetar超过 7 年前
Could you provide examples of games? The answer is very different for, say RTS or Shooter, MMO or match-based, etc.
moomin超过 7 年前
You&#x27;d be surprised at how devious some of the tricks are. I&#x27;ll give you an example from Startopia: visitors want particular services. These have queues. If the queue is too long, the visitor looks for a shorter line. Except... this led to them aimlessly wandering in circles. Oops.<p>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 &quot;sensibly&quot;.<p>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.
hashmal超过 7 年前
&gt; Each AI should use up a pretty significant resource of the server running the AI.<p>The premise is wrong, in many games AI can be extremely cheap. It&#x27;s usually not the same &quot;AI&quot; as in other fields. Game dev is a completely different dimension.
hypercluster超过 7 年前
I&#x27;ve started playing Destiny 2 and wondered the same thing. There are enemies seen by me and other players at the same time.<p>So the enemies have to be controlled server side not locally. Also there can be (and will be) a lot of enemies around the &quot;Destiny world&quot; at the same time. What kind of servers do you need for that? That&#x27;s not just processing HTTP requests and fetching data.
sidcool超过 7 年前
Could there be a not mathematical model of AI
posterboy超过 7 年前
besides the other sensible opinions on the engineering, if those fail, the far simpler answer is to pay for server farms.