Overview of this book

Sparrow iOS Game Framework Beginner's Guide
Credits
www.PacktPub.com
Preface
Afterword
Displaying Our First Objects
Beautifying Our Game
Adding Audio to Our Game
Index

Artificial intelligence in theory

The goal for the enemy ships is to move around and attack our ships if they get close enough. There are two concepts we need to look into in detail to help us implement this logic; we will discuss these in the following sections.

Explaining fuzzy logic

Let's take a moving train as an example. We could use a Boolean value to describe its state. If it is set to true, it's moving fast; if it's set to false, it's not moving fast.

However, that will not be enough. Let's say the train is moving at 80 miles per hour and then at 100 miles per hour. At both speeds, our Boolean value will be true, but we have no way of differentiating it further. Also, we don't have a state if the train is not moving.

Fuzzy logic describes an interval of values put into a colloquial term. Let's take a step back and compare it to mathematical logic. Binary (two-valued) logic has two values: true and false. An expression such as 1 + 1 = 2 evaluates to "true". The expression "Adding one...