Using vectors
We will be using vector math frequently when designing the AI for our games. Vectors are used everywhere, from calculating which direction a game agent should shoot its gun in, to expressing the inputs and outputs of an artificial neural network. You should know them well.
Let's take a point P as follows:
P = (x, y)
A two-dimensional vector looks almost the same when written, as follows:
V = (x, y)
However, although similar, a vector represents two components: direction and magnitude. The right-hand side of the following diagram shows the vector (9, 6) situated at the origin:
The bearing of the arrow shows the direction of the vector, and the length of the line represents the magnitude of the vector. A vector can represent the velocity of a vehicle. The magnitude of the vector represents the speed of the vehicle, and the direction represents the heading of the vehicle.
That's quite a lot of information from just two numbers (x, y). Vectors aren't restricted to two dimensions either...