Creating a finite state machine agent