Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
labyrinthe.h
00001 /** 00002 * @file labyrinthe.h 00003 * @brief Regroupement de fonction pour enregistrer le millieu en 2D. 00004 * @author Salco 00005 * @version 2.00 00006 * @date 11 mars 2015 00007 */ 00008 #ifndef LABYRINTHE_H 00009 #define LABYRINTHE_H 00010 00011 #define DEFAULTLABLEIGHT 4 00012 #define DEBUGLABCOORD 0 00013 #define DEBUGLABSEARCHCOORD 0 00014 00015 #include "mbed.h" 00016 #include "debug.h" 00017 #include "settingDebug.h" 00018 #include <string> 00019 00020 #define UP 1 00021 #define DOWN 2 00022 #define LEFT 3 00023 #define RIGHT 4 00024 00025 00026 /*#define VIDE 3 00027 #define EXPLORER 1 00028 #define MUR 2 00029 #define PAS_EXPLORER 0*/ 00030 00031 // 1 tuile == 4 byte 00032 00033 00034 00035 class Labyrinthe 00036 { 00037 signed char m_posX,m_posY; 00038 char direction; 00039 string mapDuLabyrinthe; 00040 00041 00042 00043 public: 00044 enum coordoner_t{ 00045 /* C7,C8,C9 */ 00046 /* C4,C5,C6 */ 00047 /* C1,C2,C3 */ 00048 unset = -1, 00049 C1 = 1, 00050 C2 = 2, 00051 C3 = 3, 00052 C4 = 4, 00053 C5 = 5, 00054 C6 = 6, 00055 C7 = 7, 00056 C8 = 8, 00057 C9 = 9 00058 }; 00059 00060 enum case_t{ 00061 //error =-1, 00062 pasExplorer = 0, 00063 explorer = 1, 00064 mur = 2, 00065 vide = 3 00066 }; 00067 00068 Labyrinthe(); 00069 ~Labyrinthe(); 00070 00071 char getDirection(){return direction;} 00072 void setDirection(char dir){direction= dir;} 00073 00074 signed char getX(void){return m_posX;} 00075 void setX(signed char x){m_posX = x;} 00076 00077 signed char getY(void){return m_posY;} 00078 void setY(signed char y){m_posY = y;} 00079 00080 void goUp(void){m_posY++;} 00081 void goDown(void){m_posY--;} 00082 void goLeft(void){m_posX--;} 00083 void goRight(void){m_posX++;} 00084 00085 void moveFoward(void){moveFoward(direction);} 00086 void moveFoward(char dir); 00087 void moveBackward(void){moveBackward(direction);} 00088 void moveBackward(char dir); 00089 void moveToLeft(void){moveToLeft(direction);} 00090 void moveToLeft(char dir); 00091 void moveToRight(void){moveToRight(direction);} 00092 void moveToRight(char dir); 00093 00094 void getXY_Foward(signed char &x, signed char &y){getXY_Foward(x,y,direction);} 00095 void getXY_Foward(signed char &x, signed char &y,char dir); 00096 void getXY_Backward(signed char &x, signed char &y){getXY_Backward(x,y,direction);} 00097 void getXY_Backward(signed char &x, signed char &y,char dir); 00098 void getXY_Left(signed char &x, signed char &y){getXY_Left(x,y,direction);} 00099 void getXY_Left(signed char &x, signed char &y, char dir); 00100 void getXY_Right(signed char &x, signed char &y){getXY_Right(x,y,direction);} 00101 void getXY_Right(signed char &x, signed char &y, char dir); 00102 00103 void turnBack(void); 00104 void turnLeft(void); 00105 void turnRight(void); 00106 00107 char caseToChar(case_t value); 00108 00109 case_t getC_Foward(void){return getC_Foward(direction);} 00110 case_t getC_Foward(char dir); 00111 case_t getC_Backward(void){return getC_Backward(direction);} 00112 case_t getC_Backward(char dir); 00113 case_t getC_ToLeft(void){return getC_ToLeft(direction);} 00114 case_t getC_ToLeft(char dir); 00115 case_t getC_ToRight(void){return getC_ToRight(direction);} 00116 case_t getC_ToRight(char dir); 00117 00118 case_t getC(coordoner_t cX); 00119 case_t getC(signed char x, signed char y, coordoner_t cX); 00120 case_t getC(signed char x, signed char y); 00121 void setC(case_t value, signed char x, signed char y, coordoner_t cX); 00122 void setC(case_t value, coordoner_t cX); 00123 void setC(case_t value, signed char x, signed char y); 00124 00125 void setC_Up(case_t value); 00126 void setC_Down(case_t value); 00127 void setC_Left(case_t value); 00128 void setC_Right(case_t value); 00129 void setMyPos(case_t value); 00130 00131 /** 00132 * Surcharge de showMap(void) 00133 * @return The formated map 3x3 result 00134 */ 00135 string showMap(void); 00136 00137 /** 00138 * Fonction permetant de sortire la map de la position x et y 00139 * @param x position X. 00140 * @param y position Y. 00141 * @return The formated map 3x3 result 00142 */ 00143 string showMap(signed char x, signed char y); 00144 string getAllMap(void){return mapDuLabyrinthe;} 00145 void setAllMap(string updatedMap){mapDuLabyrinthe = updatedMap;} 00146 00147 00148 00149 private: 00150 int searchCoord(signed char posX,signed char posY); 00151 00152 coordoner_t getCoordoner(signed char &x, signed char &y); 00153 coordoner_t getCoordoner(void); 00154 00155 bool updateMap(string mapUpdated); 00156 bool updateMap(string mapUpdated,signed char x, signed char y); 00157 bool addMap(signed char x, signed char y); 00158 00159 }; 00160 #endif //LABYRINTHE_H//
Generated on Tue Jul 12 2022 19:04:22 by
1.7.2