Game Development Reference
In-Depth Information
Agent actions
Ultimately, any decision logic or structure we create for our agents comes down to deciding
what action our agent should perform. Actions themselves are isolated structures that will
be constructed from three distinct states:
• Uninitialized
• Running
• Terminated
The typical lifespan of an action begins in uninitialized state and will then become initial-
ized through a onetime initialization, and then, it is considered to be running. After an ac-
tion completes the running phase, it moves to a terminated state where cleanup is per-
formed. Once the cleanup of an action has been completed, actions are once again set to
uninitialized until they wait to be reactivated.
We'll start defining an action by declaring the three different states in which actions can be
as well as a type specifier, so our data structures will know that a specific Lua table should
be treated as an action.
Note
Remember, even though we use Lua in an object-oriented manner, Lua itself merely creates
each instance of an object as a primitive table. It is up to the code we write to correctly in-
terpret different tables as different objects. The use of a Type variable that is moving for-
ward will be used to distinguish one class type from another.
Action.lua :
Action = {};
Action.Status = {
RUNNING = "RUNNING",
TERMINATED = "TERMINATED",
UNINITIALIZED = "UNINITIALIZED"
};
Action.Type = "Action";
Search WWH ::




Custom Search