![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code to run the microcontrollers on the R5 competition bot
Dependencies: LineSensors mbed
Diff: r5map.h
- Revision:
- 15:150ec9448efc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/r5map.h Sat Apr 18 02:54:55 2015 +0000 @@ -0,0 +1,66 @@ +#ifndef R5_MAP +#define R5_MAP + +#include <vector> + +using namespace std; + +struct position +{ + position(int xx = 0, int yy = 0) : x(xx), y(yy) {} + inline bool operator==(const typename ::position& rhs){return ((x==rhs.x) && (y==rhs.y)); } + inline bool operator!=(const typename ::position& rhs){return !operator==(rhs);} + int x,y; +}; + +enum wallState { OPEN, CLOSED, UNKNOWN }; +enum direction { NORTH, EAST, SOUTH, WEST }; + +struct Cell +{ + Cell() : north(UNKNOWN), south(UNKNOWN), east(UNKNOWN), west(UNKNOWN), visited(false) {} + wallState north; + wallState south; + wallState east; + wallState west; + bool visited ; + int number; + vector<char> symbols; +}; + +class R5Map +{ + public: + R5Map(int conSize = DEFAULT_SIZE); + void setPosition(position cell); + void setStart(position newStart); + void setFinish(position newFin); + void setWall(position cell, direction dir, wallState state); + void setCurWall(direction dir, wallState state); + void setVisited(position cell); + void setCurVisited(); + void addSymbol(position cell, char symbol); + void addCurSymbol(char symbol); + position getPosition() const; + position getStart() const; + position getFinish() const; + wallState getWall(position cell, direction dir) const; + wallState getCurWall(direction dir) const; + bool getVisited(position cell) const; + bool getCurVisited() const; + vector<char> getSymbols(position cell) const; + vector<char> getCurSymbols() const; + int getSize() const; + void printMap() const; + ~R5Map(); + + private: + static const int DEFAULT_SIZE = 5; + Cell map[7][7]; + int size; + position pos; //X,Y + position start; + position fin; +}; + +#endif