-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTurmite.hpp
54 lines (42 loc) · 1.49 KB
/
Turmite.hpp
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
#ifndef TURMITE_HPP
#define TURMITE_HPP
#include <string>
#include <Map.hpp>
struct TransitionTriple {
unsigned char color;
char direction; // TODO longer direction for splitting turmites
unsigned char state;
};
class Turmite {
public:
Turmite();
Turmite(Map *newMap, std::string transitionRule);
Turmite(Map *newMap, void (* newTransitionFunction)(Turmite *));
~Turmite();
bool step(); // true if leaving map
bool setTransitionRule(std::string transitionRule);
void setTransitionFunction(void (* newTransitionFunction)(Turmite *));
void setPosition(unsigned int x, unsigned int y);
void setRotation(unsigned int newRotation);
unsigned int getStepsPassed() const;
unsigned int getState() const;
void setState(unsigned int newState);
unsigned char getCell() const;
void setCell(unsigned char value);
void increaseCell(unsigned char max);
void turnLeft();
void turnRight();
bool move(); // true if leaving map
private:
Map *map;
int posX, posY;
unsigned int rotation, state, stepCounter;
void (* transitionFunction)(Turmite *);
TransitionTriple *transitionTable;
unsigned char numberOfColors;
unsigned int numberOfStates;
bool useTransitionRule;
void init(Map *newMap);
void transitionRule();
};
#endif // TURMITE_HPP