Game Development Reference
In-Depth Information
Setting and retrieving blackboard attributes
Blackboard attributes aren't limited to knowledge sources that provide calculated results.
Simple attributes that require no calculations can be stored and read using simple setters
and getters. As our blackboard uses a Lua table to store attribute values, setting an attribute
to a nil value will remove the attribute from the blackboard:
Blackboard.lua :
function Blackboard.Get(self, attribute)
-- Return the evaluated information from a knowledge
source.
if (self.sources_[attribute]) then
return EvaluateSources(self,
self.sources_[attribute]);
end
-- Return stored data if there are no knowledge sources
to
-- evaluate.
return self.attributes_[attribute];
end
function Blackboard.Set(self, attribute, value)
self.attributes_[attribute] = value;
end
Search WWH ::




Custom Search