Game Development Reference
In-Depth Information
local distanceToAgent = Vector.DistanceSquared(
positions[index], enemyInfo.seenAt);
if (distanceToAgent <
safeDistanceFromEnemySquared) then
scores[index] = scores[index] - 1;
end
end
end
end
Score danger from dead bodies
To add an additional dimension to our agents, we can also negatively weigh positions that
are close to dead bodies. This helps our agents stay away from positions that can essen-
tially be deadly choke points:
SoldierKnowledge.lua :
local function ScoreDangerFromDeadBodies(
positions, bodies, scores)
local safeDistanceFromDeadBody = 20 * 20;
for index=1, #positions do
for key, body in pairs(bodies) do
local distanceToBody = Vector.DistanceSquared(
positions[index], body.seenAt);
if (distanceToBody < safeDistanceFromDeadBody)
then
scores[index] = scores[index] - 1;
end
end
end
end
Search WWH ::




Custom Search