Chapter 7. AI and Logic

In this chapter, we will cover the following points:

  • Processing AI waypoints
  • Firing projectiles at moving targets
  • AI line of sight
  • AI flocking using Boids
  • A* pathfinding on a grid
  • A* pathfinding in a Box2D world
  • A* pathfinding on a TMX tilemap
  • A* pathfinding in a side-scroller
  • Running a Lua script
  • Dynamically loading Lua scripts
  • Using Lua for dialogue trees

Introduction

All games that simulate intelligent behavior use a form of Artificial Intelligence (AI). Different techniques are used to simulate behavior for different gameplay requirements. In this chapter, we will implement a few of these techniques.

Get Cocos2d for iPhone 1 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.