Game Development Reference
In-Depth Information
Decaying blackboard events
When we update our agent senses, we can use the deltaTimeInMillis to decrement
the time-to-live value of each stored event. If the time-to-live drops below 0, we'll remove
the stored event:
AgentSenses.lua :
local function PruneEvents(events, deltaTimeInMillis)
local validEvents = {};
for index = 1, #events do
local event = events[index];
event.ttl = event.ttl - deltaTimeInMillis;
if (event.ttl > 0) then
table.insert(validEvents, event);
end
end
return validEvents;
end
Providing a helper function to wrap pruning events is useful, as most auditory events will
require being pruned during the normal agent's update loop:
AgentSenses.lua :
local function PruneBlackboardEvents(
blackboard, attribute, deltaTimeInMillis)
local attributeValue = blackboard:Get(attribute);
if (attributeValue) then
blackboard:Set(
attribute,
PruneEvents(attributeValue, deltaTimeInMillis));
Search WWH ::




Custom Search