The AI is based around an event driven state machine. The basic AI class is TPEAIState which has virtual OnEnter, OnExit, OnUpdate and OnRender methods that you can override to add your own functionality. The class to manage these states is TPEAIStateMachine. After you have added your states to the state machine, if you change states, the current state's OnExit method will be called and you can free any resource used, then the new state's OnEnter method will be called and you can set this state up to execute. Next the current state's OnUpdate and OnRender methods will be called each frame to update and render this state. You can also set a global state which will be also be executed along with the current state and you can revert back to a previous state. TPEGame/TPEDemo both have state machines in addition to TPEAIActor and TPEEntity classes.

The PolyPoint collision system (TPEPolyPoint, which the TPEEntity and TPESprite classes have) will auto trace arbitrary shaped sprites (this was not easy to get working) with a polygon outline. The line segments in this polygon is then used to test against intersection, the result is a fast and accurate system for testing collisions between sprites. Since entities are created from a group defined in a TPESprite class, you can also copy the PolyPoint mask from the same group that can be defined in the TPESprite class. This will minimize the trace time when you have multiple entities on screen.