From d7a4f0cd7ae68092da02250b148bc1b18fa3bb08 Mon Sep 17 00:00:00 2001 From: fernando Date: Thu, 8 Aug 2024 20:18:50 -0600 Subject: [PATCH] El micromouse sabe donde esta en todo momento --- main.cpp | 30 ++++++++++++++++++++++++++++++ mms.h | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 29b26ef..fe29661 100644 --- a/main.cpp +++ b/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); } } diff --git a/mms.h b/mms.h index 47fc718..fa18f5c 100644 --- a/mms.h +++ b/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; } + */ } };