Game Development Reference
In-Depth Information
Constructing a soldier blackboard
Previously, we stored any data from evaluators and actions on the
userData
structure.
We can now move all this data to our blackboard. The following is the list of attribute val-
ues we'll be storing within the blackboard:
Blackboard attributes Description
alive
Whether the agent is considered alive or dead
ammo
The current amount of ammunition the soldier's rifle has left
maxAmmo
The clip size of the soldier's rifle
maxHealth
The starting health of the agent
enemy
The best enemy agent that can be attacked
bestFleePosition
The best strategic position to avoid enemy agents
Constructing a blackboard requires you to set the initial attribute values we previously
stored on the
soldierUserData
table directly. At this point, we can create
Know-
ledgeSource
instance implementations for enemy selection and flee position calcula-
tions. To allow access of the blackboard to all our agent systems, we can store the black-
board itself on
soldierUserData
. While there is fundamentally little difference
between storing data on the
soldierUserData
directly and using the blackboard for
basic attributes, having a common data structure that manages attributes allows for extens-
ibility and easier debugging:
IndirectSoldierAgent.lua
:
require "Blackboard"
require "DebugUtilities"
require "KnowledgeSource"
require "SandboxUtilities"
require "Soldier"
require "SoldierController"