diff --git a/stm32/include/strategie/benne.h b/stm32/include/strategie/benne.h index 944b5e0791b134a40762d0868b5592d4822583ab..eb55620bee659ea21e1c736e242eb13644294713 100644 --- a/stm32/include/strategie/benne.h +++ b/stm32/include/strategie/benne.h @@ -8,8 +8,8 @@ public: ~Benne(); - void setIsBenneEmpty(); - void setIsBenneFull(); + void setBenneEmpty(); + void setBenneFull(); bool getIsBenneEmpty(); bool getIsBenneFull(); diff --git a/stm32/include/strategie/krabi2016.h b/stm32/include/strategie/krabi2016.h index 27718d4536f25aaad05c7e2a0e63b8e5869a5f01..0c7425f1e0408826f1e61158a17508156a004043 100644 --- a/stm32/include/strategie/krabi2016.h +++ b/stm32/include/strategie/krabi2016.h @@ -17,6 +17,7 @@ #include "manipulationCoinGaucheBas.h" #include "manipulationCoinGaucheHaut.h" #include "manipulationCoinGaucheHautPiedSolitaire.h" +#include "benne.h" class Krabi2016 : public StrategieV3 { @@ -34,6 +35,9 @@ public: private: + + Benne* benne; + // /** Nombre d'étapes dans le graph */ // int nombreEtapes = NOMBRE_ETAPES; @@ -43,6 +47,7 @@ private: /** @brief update du score d'une étape */ int getScoreEtape(int i); + }; diff --git a/stm32/include/strategie/zoneConstruction.h b/stm32/include/strategie/zoneConstruction.h index 981651d8f47a9c1e0bf143a379d234a1161dc02d..efb3bb3e90d3539f260c637b9f398282ae42531c 100644 --- a/stm32/include/strategie/zoneConstruction.h +++ b/stm32/include/strategie/zoneConstruction.h @@ -4,13 +4,14 @@ #include "position.h" #include "mediumLevelAction.h" #include "command.h" +#include "benne.h" class ZoneConstruction : public MediumLevelAction { public: ZoneConstruction(); - ZoneConstruction(Position goalPosition); + ZoneConstruction(Position goalPosition, Benne* benne); ~ZoneConstruction(); @@ -20,6 +21,7 @@ public: protected: Position goalPosition; + Benne* benne_locale; }; #endif // ZONECONSTRUCTION_H diff --git a/stm32/src/strategie/benne.cpp b/stm32/src/strategie/benne.cpp index eafba9487c4f5f5cd6ca292a25d14a8f0c564cb4..0f77f7a493786ca341b48108c6a8447e0ce23425 100644 --- a/stm32/src/strategie/benne.cpp +++ b/stm32/src/strategie/benne.cpp @@ -5,11 +5,11 @@ Benne::Benne() isBenneEmpty = true; } -void Benne::setIsBenneEmpty() { +void Benne::setBenneEmpty() { isBenneEmpty = true; } -void Benne::setIsBenneFull() { +void Benne::setBenneFull() { isBenneEmpty = false; } diff --git a/stm32/src/strategie/krabi2016.cpp b/stm32/src/strategie/krabi2016.cpp index 97e771d544ba5ec854a377d74f6144e8b00e6dd3..b8bdaed9e309da614118363cc276f35ebfc2c67e 100644 --- a/stm32/src/strategie/krabi2016.cpp +++ b/stm32/src/strategie/krabi2016.cpp @@ -1,41 +1,40 @@ #include "krabi2016.h" #include "ascenseur.h" #include "pinces.h" -#include "benne.h" #ifndef ROBOTHW #include #endif -Benne *benne = new Benne(); Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow) { + // Création de la benne + benne = new Benne(); + //Initialisation des tableaux d'étapes this->numeroEtapeGarage = ETAPE_GARAGE; tableauEtapesTotal = Etape::initTableauEtapeTotal(NOMBRE_ETAPES);//new Etape*[NOMBRE_ETAPES]; - // Création des étapes // Les étapes correspondant à des actions sont créées automatiquement lors de l'ajout d'actions int start = Etape::makeEtape(Position(250, 1000, true), Etape::DEPART); // départ au fond de la zone de départ - - /** Points de passage **/ int wa = Etape::makeEtape(Position(600, 1000, true)); int wb = Etape::makeEtape(Position(880, 1140, true)); - int wc = Etape::makeEtape(Position(1120, 1203, true)); + /** Actions **/ // Zone de construction - int zc1 = Etape::makeEtape(new ZoneConstruction(Position(650, 450, true))); + int zc1 = Etape::makeEtape(new ZoneConstruction(Position(980, 920, true), benne)); + int zc2 = Etape::makeEtape(new ZoneConstruction(Position(1050, 1050, true), benne)); // Pieds - int pa = Etape::makeEtape(new RamasserPied(Position(870, 1755, true))); - int pb = Etape::makeEtape(new RamasserPied(Position(1100, 1770, true))); + int pa = Etape::makeEtape(new RamasserPied(Position(870, 1655, true))); + int pb = Etape::makeEtape(new RamasserPied(Position(1100, 1670, true))); // Etc. @@ -43,11 +42,11 @@ Krabi2016::Krabi2016(bool isYellow) : StrategieV3(isYellow) /** Liens **/ // [WIP] Etape::get(start) ->addVoisin(wa); - Etape::get(wa) ->addVoisin(wb, wc); + Etape::get(wa) ->addVoisin(wb, zc2); Etape::get(wa) ->addVoisin(zc1); - Etape::get(wb) ->addVoisin(wc); - Etape::get(pa) ->addVoisin(wb, wc); - Etape::get(pb) ->addVoisin(pa, wc); + Etape::get(wb) ->addVoisin(zc2); + Etape::get(pa) ->addVoisin(wb, zc2); + Etape::get(pb) ->addVoisin(pa, zc2); #ifndef ROBOTHW qDebug() << Etape::getTotalEtapes(); @@ -77,19 +76,22 @@ int Krabi2016::getScoreEtape(int i) return 0; case Etape::POINT_PASSAGE : return 0; - case Etape::ZONE_CONSTRUCTION : + case Etape::ZONE_CONSTRUCTION : { if (benne->getIsBenneEmpty()) { - return 0; + return 1; } else { - return 100; + return 10000; } + } case Etape::RAMASSER_PIED : { - benne->setIsBenneFull(); - return 10; + // On fait comme si on avait rammasé un cube, du coup la benne est pleine, en vrai on fera + // tout ça dans la future classe cube + benne->setBenneFull(); + return 900; } default : diff --git a/stm32/src/strategie/zoneConstruction.cpp b/stm32/src/strategie/zoneConstruction.cpp index dcda8083d34b6b5b23eb400147e9fdb96726b2f7..a6636a86ead6cad457310106bd0030f3d215d654 100644 --- a/stm32/src/strategie/zoneConstruction.cpp +++ b/stm32/src/strategie/zoneConstruction.cpp @@ -3,6 +3,7 @@ #include "mediumLevelAction.h" #include "command.h" #include "position.h" +#include "krabi2016.h" #ifndef ROBOTHW #include @@ -10,9 +11,10 @@ ZoneConstruction::ZoneConstruction(){} -ZoneConstruction::ZoneConstruction(Position goalPosition):MediumLevelAction(goalPosition) +ZoneConstruction::ZoneConstruction(Position goalPosition, Benne* benne):MediumLevelAction(goalPosition) { - + goalPosition = this->goalPosition; + benne_locale = benne; } ZoneConstruction::~ZoneConstruction(){} @@ -55,7 +57,9 @@ int ZoneConstruction::update() else if (status == 3) { #ifndef ROBOTHW qDebug() << "Etape zone de construction finie"; + #endif + benne_locale->setBenneEmpty(); status = -1; }