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

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.

主站蜘蛛池模板: 隆尧县| 汨罗市| 安龙县| 武定县| 同德县| 阳东县| 新余市| 徐州市| 尉氏县| 崇州市| 沧源| 榆中县| 郸城县| 宜君县| 诸暨市| 襄城县| 同仁县| 阿鲁科尔沁旗| 涞源县| 洞头县| 时尚| 盱眙县| 南召县| 辛集市| 牟定县| 南木林县| 千阳县| 长沙市| 灌南县| 遂川县| 温泉县| 苗栗市| 余姚市| 平安县| 阿坝| 鹤岗市| 东乌| 田林县| 汪清县| 延庆县| 靖远县|