官术网_书友最值得收藏!

The messaging system

AI does decision making in response to the events in the world. The events are communicated between the AI entity and the player, the world, or the other AI entities through a messaging system. For example, when the player attacks an enemy unit from a group of patrol guards, the other AI units need to know about this incident as well, so that they can start searching for and attacking the player. If we were using the polling method, our AI entities would need to check the state of all of the other AI entities to know about this incident. However, with an event-driven messaging system, we can implement this in a more manageable and scalable way. We can register the AI characters interested in a particular event as listeners, and if that event happens, our messaging system will broadcast to all listeners. The AI entities can then proceed to take appropriate actions or perform further checks.

The event-driven system does not necessarily provide a faster mechanism than polling. Still, it provides a convenient, central checking system that senses the world and informs the interested AI agents, rather than each agent having to check the same event in every frame. In reality, both polling and messaging systems are used together most of the time. For example, AI might poll for more detailed information when it receives an event from the messaging system.

主站蜘蛛池模板: 奈曼旗| 同心县| 沂源县| 南皮县| 信宜市| 印江| 中西区| 乐亭县| 房产| 刚察县| 年辖:市辖区| 博罗县| 炎陵县| 崇文区| 寿光市| 论坛| 新化县| 称多县| 青龙| 泗水县| 寻乌县| 华亭县| 德兴市| 甘南县| 琼结县| 依兰县| 湖南省| 南溪县| 瑞丽市| 深泽县| 钟山县| 大埔县| 贵州省| 纳雍县| 巢湖市| 赤水市| 西峡县| 茶陵县| 江都市| 伊川县| 东山县|