Game Development Reference
In-Depth Information
Calculating the best flee position
To take all these scoring functions into account, we can update how we choose the best flee
position by processing each of the random points we've selected on the navigation mesh.
After each point is scored, we'll return the best possible position and have our agent imme-
diately flee to that location.
Note
Using scoring functions is an easy way to evaluate a large number of factors that need to be
considered. Each new factor to be scored against increases the dimensionality of the prob-
lem and can quickly lead to problems with balancing.
Updating the ChooseBestFleePosition function will start with fetching all relevant
blackboard information and then process the 32 random navmesh points based on our scor-
ing functions.
SoldierKnowledge.lua :
function SoldierKnowledge_ChooseBestFleePosition(userData)
local sandbox = userData.agent:GetSandbox();
local bestPosition;
local bulletImpacts =
userData.blackboard:Get("bulletImpacts") or {};
local bulletShots =
userData.blackboard:Get("bulletShots") or {};
local visibleEnemies =
userData.blackboard:Get("visibleAgents") or {};
local deadEnemies =
userData.blackboard:Get("deadEnemies") or {};
local deadFriendlies =
userData.blackboard:Get("deadFriendlies") or {};
if (#visibleEnemies) then
local positions = {};
local scores = {};
local bestScore = 0;
Search WWH ::




Custom Search