-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDocoMovePatternDiagonal.cpp
52 lines (38 loc) · 1.56 KB
/
DocoMovePatternDiagonal.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
#pragma once
#include "DocoMovePatternDiagonal.h"
#include <vector>
#include "Directions.h"
// Behavior pattern 3 will cause the DOCO to move only in a diagonal direction.
Directions* moveDiagDirs = new Directions();
// --- This is the default move strategy
std::vector<std::pair<int, int> > DocoMovePatternDiagonal::moveStrategy() {
return moveDiagDirs->getDiagonalPairOffsets();
}
// If an edge of the world is encountered the DOCO will randomly elect to move
// left, right, up, or down and either reverse its direction of movement or move
// in the other diagonal direction.
// --- This is the strategy for when the default fails, ie: docos / obstacles prevent movement
std::vector<std::pair<int, int> > DocoMovePatternDiagonal::avoidanceStrategy() {
// TODO: implement avoidance strategy for diagonal move pattern
// If an edge of the world is encountered the DOCO will randomly elect to (move
// left, right, up, or down) and either (reverse its direction of movement) or (move
// in the other diagonal direction.)
// X => +
//
// a c
// x x
// b d
//
// a c
// x
// d b
//a x b go a, reverse is b go b reverse is a the other diagonal direction(line) from c x d Line1
//c x d go c, reverse is d go d reverse is c the other diagonal direction(line) from a x b Line2
//
// Reverse only works on a line not all diagonals
return moveDiagDirs->getPerpPairOffsets();
}
DocoMovePatternDiagonal::DocoMovePatternDiagonal() : DocoMoveStrategy() {
}
DocoMovePatternDiagonal::~DocoMovePatternDiagonal() {
}