Finite state machine and messaging

A finite state machine is a computation model consisting in a finite set of states, from which can only be in one at a time. Transitions between them are produced under certain conditions.

Game characters' behavior is usually modelled by a series of states and transitions. A clear example is a spy game where enemies patrol all over the map under apparent calm. Suddenly, one of them hears a noise and turns into track state. Seconds later, the alarm is raised because the spy has been spotted, so all nearby enemies enter into alert state. In conclusion, they are no more than a finite state machine capable of communicating with other agents.

This recipe illustrates a new episode of the caveman and the dinosaur whose ...

Get Libgdx Cross-platform Game Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.