-
Notifications
You must be signed in to change notification settings - Fork 0
/
ai.h
146 lines (124 loc) · 2.47 KB
/
ai.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef AI_H
#define AI_H
#include "kinematic.h"
#include "steering.h"
#include "physics.h"
#include <vector>
class PSteerable;
class AIStrategy
{
public:
PSteerable *steerable;
virtual SteerInfo getSteering() = 0;
};
class Seek : public AIStrategy
{
public:
Seek();
Kinematic target;
float slowRadius;
float targetRadius;
float maxSpeed;
bool flee;
virtual SteerInfo getSteering();
};
class Wander : public AIStrategy
{
float orientation;
public:
Seek seeker;
float radius;
float offset;
float rate;
Wander();
virtual SteerInfo getSteering();
};
class WeightedSteering
{
public:
WeightedSteering(SteerInfo s, float weight);
SteerInfo steering;
float weight;
};
class BlendedStrategy : public AIStrategy
{
protected:
std::vector<WeightedSteering> strats;
public:
virtual SteerInfo getSteering();
};
class AvoidObstacles : public AIStrategy
{
Seek seeker;
CollContact obstacle;
protected:
bool wallTrapped;
bool seeObstacle;
public:
void detectWalls();
virtual SteerInfo getSteering();
};
class Flock : public BlendedStrategy
{
Seek seeker;
Wander wanderer;
public:
Flock();
virtual SteerInfo getSteering();
};
class FollowLeader : public BlendedStrategy
{
protected:
Seek seeker;
PSteerable *leader;
public:
FollowLeader(PSteerable *leader);
void setLeader(PSteerable *leader) {this->leader = leader;};
PSteerable *getLeader() {return leader;};
virtual SteerInfo getSteering();
};
class StaticFormation : public FollowLeader
{
protected:
int slot;
virtual Kinematic getSpot() = 0;
public:
StaticFormation(PSteerable *leader, int slot);
virtual SteerInfo getSteering();
};
class Line : public StaticFormation
{
protected:
virtual Kinematic getSpot();
public:
Line(PSteerable *leader, int slot);
};
class Vee : public StaticFormation
{
protected:
virtual Kinematic getSpot();
public:
Vee(PSteerable *leader, int slot);
};
class DynamicFormation : public StaticFormation
{
protected:
int nSlots;
virtual Kinematic getSpot() = 0;
public:
DynamicFormation(PSteerable *leader, int slot, int nSlots);
};
class DefensiveCircle : public DynamicFormation
{
protected:
virtual Kinematic getSpot();
public:
DefensiveCircle(PSteerable *leader, int slot, int nSlots);
};
class DynamicVees : public Flock
{
Vee vee;
public:
virtual SteerInfo getSteering();
};
#endif