AI for Games

A little history

Several years before I came across Processing, I read a book called “Programming Game AI by Example” by Mat Buckland. The book was aimed at experienced C++ programmers who were novices to programming AI techniques. The book was superbly structured with excellent descriptions and industrial strength C++ examples. My favourite example was "Simple Soccer" a sports simulation. Now fast forward a few years to a point when I have a few Processing libraries and tools under my belt and it occurred to me that it would be great to have an AI library for Processing.


Although this library makes several very powerful AI techniques available to the Java/Processing programmer it also provides a game engine framework to take care of all the calculations needed to update and render the game entities.


Some of the examples require the G4P library to be installed. This can be done through the Add Library menu option in the Processing IDE.


  • game world size is virtually unlimited.
  • large complex projects can use cell-space partitioning to improve performance.
  • updating the game physics is independent of the frame rate so the animation runs at the same speed for all computers.
  • double precision variables are used throughout the library to avoid inconsistent behaviour at very high frame rates.
  • hires (nanosecond) timer to control physics update.
  • a range of game entities are available (buildings, obstacles, movers) with library defined appearance
  • users can define how the game entity is rendered on the display.
  • state-driven AI available on all game entities.
  • autonomous agents with optional steering behaviour AI.
  • messaging between state-driven game entities.
  • supports use of navigation meshes and path finding.

User Guides

To help the user get the most out of this library this website hosts two types of user guide.

Library Guides

Their purpose is to give an insight into how the library works. It covers a broad range of topics that are essential for the programmer to be aware of if they are to get the most of the library capabilities.

Programmer Guides

It is normal for libraries to provide examples and this library is no exception, it is also normal for examples to have comments explaining the code. These guides provide more detailed description of the code.