-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTacticsHockeyistsPrimitive.cpp
93 lines (69 loc) · 2.96 KB
/
TacticsHockeyistsPrimitive.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
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
#include "MyStrategy.h"
#include "MySystem.h"
#include "UsefulFunctions.h"
#include "constants.h"
#define PI 3.14159265358979323846
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
using namespace std;
using namespace model;
using namespace UsefulFunctions;
using namespace MySystem;
void TacticsHockeyists::moveApproxToSector(Information& information, AllSystem& system, const Sector& sector) {
const Hockeyist& self = information.self;
Move& move = information.move;
double range = self.getDistanceTo(sector.x, sector.y);
double angle = self.getAngleTo(sector.x, sector.y);
if (angle > MIN_ANGLE_ANGLE_TO_SPEED) {
move.setSpeedUp(getEffectiveSpeedByAngle(angle));
}
else {
move.setSpeedUp(getEffectiveSpeedByRange(range));
}
move.setTurn(angle);
}
void TacticsHockeyists::moveQuickToSector(Information& information, AllSystem& system, const Sector& sector) {
const Hockeyist& self = information.self;
Move& move = information.move;
double angle = self.getAngleTo(sector.x, sector.y);
move.setSpeedUp(getEffectiveSpeedByAngle(angle));
move.setTurn(angle);
}
void TacticsHockeyists::moveToEnemy(Information& information, AllSystem& system, Hockeyist* enemy) {
Sector enemySector = getPrognosedSectorUnit(information, information.self, *enemy, false);
moveQuickToSector(information, system, enemySector);
}
void TacticsHockeyists::turnToSector(Information& information, const Sector& sector) {
information.move.setTurn(information.self.getAngleTo(sector.x, sector.y));
}
void TacticsHockeyists::turnToPuck(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
const World& world = information.world;
const Game& game = information.game;
Move& move = information.move;
double angleToPuck = getEffectiveAngleToPuck(information);
move.setTurn(angleToPuck);
}
void TacticsHockeyists::passToOther(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
const World& world = information.world;
const Game& game = information.game;
Move& move = information.move;
Hockeyist* mySecondHockeyist = getMyOtherHockeyist(self, world);
double angleToSH = getEffectivePassAngle(information, *mySecondHockeyist);
if (abs(angleToSH) <= game.getPassSector() / 2) {
move.setPassAngle(getEffectivePassAngle(information, *mySecondHockeyist));
move.setPassPower(getEffectivePassPower(information, *mySecondHockeyist));
move.setAction(ActionType::PASS);
system.setJustPassed(true);
system.setPassingNeed(false);
}
move.setTurn(angleToSH);
}
void TacticsHockeyists::moveToMovingSector(Information& information, AllSystem& system) {
const Hockeyist& self = information.self;
int selfId = self.getTeammateIndex();
const Sector movingSector = system.getMovingSector(selfId);
moveQuickToSector(information, system, movingSector);
}