summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/robospierre
diff options
context:
space:
mode:
authorJérôme Jutteau2011-06-02 15:36:47 +0200
committerJérôme Jutteau2011-06-02 15:36:47 +0200
commit8fef548edab0f336bb86d0aeaa070e8fcbdf65d6 (patch)
tree713e2deaca69dd975c581b24e102a1663c5c33de /digital/io-hub/src/robospierre
parent4bae7237c6d4509838870dd23eb50b0b92f6e6a4 (diff)
digital/io-hub: take care of founded towers in logistic
Diffstat (limited to 'digital/io-hub/src/robospierre')
-rw-r--r--digital/io-hub/src/robospierre/logistic.c23
-rw-r--r--digital/io-hub/src/robospierre/logistic.h2
2 files changed, 25 insertions, 0 deletions
diff --git a/digital/io-hub/src/robospierre/logistic.c b/digital/io-hub/src/robospierre/logistic.c
index 82e4f5f2..4b0536f2 100644
--- a/digital/io-hub/src/robospierre/logistic.c
+++ b/digital/io-hub/src/robospierre/logistic.c
@@ -83,6 +83,8 @@ logistic_case_test (uint8_t loc, uint8_t e)
return 1;
if ((e == LOG_H || e == LOG_h) && ELEMENT_IS_HEAD (ctx.slots[loc]))
return 1;
+ if (e == LOG_t && ctx.slots[loc] == ELEMENT_TOWER)
+ return 1;
return 0;
}
@@ -208,6 +210,14 @@ static void
logistic_update_construct_possible ()
{
uint8_t pawn = 0, head = 0, i;
+ /* Check for tower. */
+ if (ctx.slots[CLAMP_SLOT_FRONT_BOTTOM] == ELEMENT_TOWER ||
+ ctx.slots[CLAMP_SLOT_BACK_BOTTOM] == ELEMENT_TOWER)
+ {
+ ctx.construct_possible = 1;
+ return;
+ }
+
for (i = CLAMP_SLOT_FRONT_BOTTOM; i < CLAMP_SLOT_NB; i++)
{
if (ELEMENT_IS_HEAD (ctx.slots[i]))
@@ -258,6 +268,11 @@ logistic_update_need_prepare ()
/* If a head appear at the back (?) */
if (ELEMENT_IS_HEAD (ctx.slots[opp_bay]))
ctx.need_prepare = 1;
+
+ /* We founded a tower ! */
+ if (ctx.slots[CLAMP_SLOT_FRONT_BOTTOM] == ELEMENT_TOWER ||
+ ctx.slots[CLAMP_SLOT_FRONT_BOTTOM] == ELEMENT_TOWER)
+ ctx.need_prepare = 1;
}
static void
@@ -275,6 +290,14 @@ logisitic_make_broken ()
static void
logistic_make_tower ()
{
+ LOGISTIC_CASE (_, _,
+ _, _, _,
+ _, t, LEFT, 1);
+
+ LOGISTIC_CASE (_, _,
+ _, _, _,
+ t, _, RIGHT, 1);
+
LOGISTIC_CASE (D, _,
e, _, _,
H, _, RIGHT, 0);
diff --git a/digital/io-hub/src/robospierre/logistic.h b/digital/io-hub/src/robospierre/logistic.h
index f27c082b..9962874b 100644
--- a/digital/io-hub/src/robospierre/logistic.h
+++ b/digital/io-hub/src/robospierre/logistic.h
@@ -44,6 +44,8 @@
#define LOG_h 7
/** Destination (who has to be empty). */
#define LOG_D 8
+/** We have a tower (always at bottom). */
+#define LOG_t 9
/* LEFT means we keep the same side, RIGHT means we put the opposed side. */
#define LOG_DIR_LEFT 0
#define LOG_DIR_RIGHT 1