上QQ阅读APP看书,第一时间看更新
The sensor system
Our AI characters need to know about their surroundings and the world they are interacting with in order to make a particular decision. Such information may be the following:
- The position of the player: This is used to decide whether to attack or chase, or keep patrolling
- Buildings and objects nearby: This is used to hide or take cover
- Player's health and its own health: This is used to decide whether to retreat or advance
- Location of resources on the map in a Real-Time Strategy game (RTS): This is used to occupy and collect resources required for updating and/or producing other units
As you can see, choosing the right method to collect game information can vary a lot depending on the type of game we are trying to build. In the following sections, we look at two basic strategies: polling and message (event) systems.