[5SD033] Plane AI, States and Behaviour
![]() This week has been dedicated to the planning and structuring of a simple AI and the various behaviours necessary to facilitate a basic enemy plane. The underlying structure is a finite state machine, a set of coded behaviours that are switched when specified conditions are met. The desired behaviour of the plane is based on the stealth elements of the game, requiring it to patrol certain routes until it finds a player upon which it will chase after and attack until the player either crashes or manages to shake the enemy off by employing stealth tactics(such as like flying into clouds). The plane then tries to search for the player at and around the last known location the player was seen. The plane should feel predictable enough that one can anticipate what it is currently doing and how it will react if the player is detected or lost from sight. I decided on utilizing class hierarchy, making a class inherit functions from another, in order to switch states as a pointer to a class higher in the hierarchy is a valid pointer to any classes inherited by it. This allows each state to be created and switched to when conditions are met by deleting the previous state and allocating the pointer to the new one. The states are Patrol, Chase and Search, inheriting functions to handle state-specific behaviour, such as following the player and shooting while in Chase, moving along a designated path while in patrol or attempting to find a player that has eluded the plane. States and the behaviours thereof:
|
