FloodFill #2
30
main.cpp
30
main.cpp
|
|
@ -77,6 +77,35 @@ void flood(struct maze* maze, struct mmstats* mmstats) {
|
|||
}
|
||||
}
|
||||
|
||||
void follow(struct maze maze, class mmstats mms) {
|
||||
/* para que el micromouse siga el camino descendente
|
||||
* se tienen que dar 16 estados, esta funcion lo reduce a 4
|
||||
*/
|
||||
int x = mms.x;
|
||||
int y = mms.y;
|
||||
int mht = maze.mhtn[x][y];
|
||||
|
||||
}
|
||||
|
||||
void updatepos(class mmstats* mms) {
|
||||
/* cada que se ejecuta moveForward la funcion actualiza
|
||||
* la posicion del micromouse en el valor correspondiente
|
||||
*/
|
||||
switch (mms->dir) {
|
||||
case norte: mms->y++;
|
||||
break;
|
||||
case este: mms->x++;
|
||||
break;
|
||||
case sur: mms->y--;
|
||||
break;
|
||||
case oeste: mms->x--;
|
||||
break;
|
||||
}
|
||||
log(mms->x);
|
||||
log(mms->y);
|
||||
log("");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
log("Running...");
|
||||
|
|
@ -98,5 +127,6 @@ int main(int argc, char* argv[]) {
|
|||
stats.turn(right);
|
||||
}
|
||||
API::moveForward();
|
||||
updatepos(&stats);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
mms.h
4
mms.h
|
|
@ -10,7 +10,6 @@ struct dirnode {
|
|||
class mmstats {
|
||||
private:
|
||||
dirnode* tail;
|
||||
dirnode* head;
|
||||
void addnode(int val) {
|
||||
dirnode* temp = new dirnode(val);
|
||||
if (head != nullptr) {
|
||||
|
|
@ -27,6 +26,7 @@ private:
|
|||
}
|
||||
}
|
||||
public:
|
||||
dirnode* head;
|
||||
int y;
|
||||
int x;
|
||||
char dir;
|
||||
|
|
@ -42,6 +42,7 @@ public:
|
|||
head = head->next;
|
||||
else head = head->prev;
|
||||
dir = head->value;
|
||||
/*
|
||||
switch (dir) {
|
||||
case norte: log("Norte");
|
||||
break;
|
||||
|
|
@ -52,6 +53,7 @@ public:
|
|||
case oeste: log("Oeste");
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user