Game Development Reference
In-Depth Information
Scoring dangerous positions
We can also update how retreat positions are selected within the sandbox using a number of
different sources of information. A utility pattern comes in handy when individually weigh-
ing the importance of each piece of information, as it pertains to our randomly selected re-
treat positions.
Score danger from bullet impacts
First, we can score our sandbox retreat positions based on known bullet impacts positions.
If a bullet impact happened within 10 meters of a position, we can reduce the score by a
small value. As a large number of bullet impacts typically happen within the same area, this
will quickly avoid positions where combat is taking place readily:
SoldierKnowledge.lua :
local function ScoreDangerFromBulletImpacts(
positions, impacts, scores)
local safeDistanceFromBulletImpactSquared = 10 * 10;
for index=1, #positions do
for key, impact in pairs(impacts) do
local distanceToImpact = Vector.DistanceSquared(
positions[index], impact.position);
if (distanceToImpact <
safeDistanceFromBulletImpactSquared) then
scores[index] = scores[index] - 0.5;
end
end
end
end
Score danger from bullet shots
Scoring dangerous shots is almost identical to scoring bullet impacts, except that we can try
out an even wider radius while simultaneously reducing the score contribution:
Search WWH ::




Custom Search