-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCell.cpp
131 lines (110 loc) · 1.92 KB
/
Cell.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
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
#include "Cell.h"
Cell::Cell(int x, int y)
{
this->x_pos = x;
this->y_pos = y;
}
Cell::~Cell()
{
}
int Cell::getXPos(void)
{
return this->x_pos;
}
int Cell::getYPos(void)
{
return this->y_pos;
}
bool Cell::getOccupied(void)
{
return this->occupied;
}
bool Cell::getObstacle(void)
{
return this->obstacle;
}
bool Cell::getFoodPresent(void)
{
return this->food_present;
}
int Cell::getFoodCount(void)
{
return this->food_count;
}
char Cell::getSymbol(void)
{
return this->symbol;
}
std::string Cell::getStrategy(void)
{
return this->strategy;
}
void Cell::setOccupied(bool isOccupied)
{
this->occupied = isOccupied;
}
void Cell::setSymbol()
{
// The symbols are as follows : '*' = location of a DOCO,
// '.' = one or more food pellets, and '-' = an empty cell.
// prioritizes the occupied symbol.
if (this->occupied) {
if (this->strategy == "Horizontal") {
this->symbol = '=';
}
else if (this->strategy == "Vertical") {
this->symbol = '|';
}
else if (this->strategy == "Diagonal") {
this->symbol = 'X';
}
else if (this->strategy == "Perp") {
this->symbol = '+';
}
else { // default DOCO movement Random
this->symbol = '*';
}
}
else if (this->obstacle) {
this->symbol = unsigned int(0xB2); // obstacle
}
else if (this->food_present) { // cell with one or more food
this->symbol = '.';
}
else { // empty cell
this->symbol = '-';
}
}
void Cell::setCustomSymbol(char newSymbol)
{
this->symbol = newSymbol;
}
void Cell::setFoodPresent()
{
if (this->food_count == 0) {
this->food_present = false;
}
else {
this->food_present = true;
}
}
void Cell::addFood(int foodAdded)
{
this->food_count += foodAdded;
}
void Cell::removeFood(int foodRemoved)
{
this->food_count -= foodRemoved;
}
void Cell::removeAllFood(void)
{
this->food_count = 0;
}
void Cell::setStrategy(std::string newStrat)
{
this->strategy = newStrat;
}
void Cell::setObsPresent(void)
{
this->obstacle = true;
}