-
Notifications
You must be signed in to change notification settings - Fork 1
/
RegroupGoal_Evaluator.cpp
60 lines (50 loc) · 1.58 KB
/
RegroupGoal_Evaluator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "RegroupGoal_Evaluator.h"
#include "Raven_Teammate.h"
#include "goals/GetHealthGoal_Evaluator.h"
#include "Raven_ObjectEnumerations.h"
#include "goals/Raven_Goal_Types.h"
#include "misc/Stream_Utility_Functions.h"
#include "goals/Raven_Feature.h"
#include "Goal_ThinkAsTeammate.h"
RegroupGoal_Evaluator::RegroupGoal_Evaluator(double bias):
Goal_Evaluator(bias)
{
}
RegroupGoal_Evaluator::~RegroupGoal_Evaluator()
{
}
double RegroupGoal_Evaluator::CalculateDesirability(Raven_Bot * pBot)
{
Raven_Teammate * pTarget = static_cast<Raven_Teammate *>(pBot);
if (pTarget->TeamSize() <= 1 || !pTarget->HasPartner()) {
return 0.0;
}
//double distance = pTarget->GetRegroupLocation().Distance(pTarget->Pos());
double distance = pTarget->DistanceToPartner();
const double distanceMin = 50.0;
const double distanceMax = 100.0;
if (distance <= distanceMin) {
return 0.0;
}
else // distance > distanceMin
{
//value used to tweak the desirability
const double Tweaker = 0.6;
double Desirability = Tweaker * (distance - distanceMin) / (distanceMax - distanceMin);
//ensure the value is in the range 0 to 1
Clamp(Desirability, 0, 1);
//bias the value according to the personality of the bot
Desirability *= m_dCharacterBias;
return Desirability;
}
}
void RegroupGoal_Evaluator::SetGoal(Raven_Bot * pBot)
{
Raven_Teammate * pTarget = static_cast<Raven_Teammate *>(pBot);
pTarget->GetBrain()->AddGoal_Regroup();
}
void RegroupGoal_Evaluator::RenderInfo(Vector2D Position, Raven_Bot * pBot)
{
gdi->TextAtPos(Position, "R: " + ttos(CalculateDesirability(pBot), 2));
return;
}