From a00a678a0ffec752028d500b587c5b8a63c6705a Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Thu, 9 May 2013 09:29:25 +0200 Subject: digital/io-hub/src/apbirthday: fix double candle push --- digital/io-hub/src/apbirthday/candles.cc | 33 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'digital/io-hub/src/apbirthday') diff --git a/digital/io-hub/src/apbirthday/candles.cc b/digital/io-hub/src/apbirthday/candles.cc index 6139efc1..f0944818 100644 --- a/digital/io-hub/src/apbirthday/candles.cc +++ b/digital/io-hub/src/apbirthday/candles.cc @@ -274,20 +274,8 @@ FSM_TRANS (AI_CANDLE_READY, ai_candle_blow, AI_CANDLE_READY) { if (robot->candles.actual_pos[i] != -1) { - // We can already punch if we know the color. - if (robot->candles.state[robot->candles.actual_pos[i]] == Candles::UNPUNCHED - && (robot->candles.color[robot->candles.actual_pos[i]] == (Candles::Color) team_color - || robot->candles.color[robot->candles.actual_pos[i]] == Candles::WHITE)) - { - if (Candles::is_far (robot->candles.actual_pos[i])) - FSM_HANDLE (AI, ai_candle_far_punch); - else - FSM_HANDLE (AI, ai_candle_near_punch); - robot->candles.state[robot->candles.actual_pos[i]] = Candles::PUNCHED; - robot->candles.actual_pos[i] = -1; - } - // We need to analyse color. - else if (robot->candles.color[robot->candles.actual_pos[i]] == Candles::UNKNOWN) + // Analyse color if needed. + if (robot->candles.color[robot->candles.actual_pos[i]] == Candles::UNKNOWN) { if (Candles::is_far (robot->candles.actual_pos[i])) { @@ -296,8 +284,6 @@ FSM_TRANS (AI_CANDLE_READY, ai_candle_blow, AI_CANDLE_READY) robot->candles.color[robot->candles.actual_pos[i]] = Candles::RED; else if (c == Rgb::BLUE) robot->candles.color[robot->candles.actual_pos[i]] = Candles::BLUE; - if (robot->candles.color[robot->candles.actual_pos[i]] == (Candles::Color) team_color) - FSM_HANDLE (AI, ai_candle_far_punch); } else { @@ -306,11 +292,20 @@ FSM_TRANS (AI_CANDLE_READY, ai_candle_blow, AI_CANDLE_READY) robot->candles.color[robot->candles.actual_pos[i]] = Candles::RED; else if (c == Rgb::BLUE) robot->candles.color[robot->candles.actual_pos[i]] = Candles::BLUE; - if (robot->candles.color[robot->candles.actual_pos[i]] == (Candles::Color) team_color) - FSM_HANDLE (AI, ai_candle_near_punch); - } } + // We can already punch if we know the color. + if (robot->candles.state[robot->candles.actual_pos[i]] == Candles::UNPUNCHED + && (robot->candles.color[robot->candles.actual_pos[i]] == (Candles::Color) team_color + || robot->candles.color[robot->candles.actual_pos[i]] == Candles::WHITE)) + { + if (Candles::is_far (robot->candles.actual_pos[i])) + FSM_HANDLE (AI, ai_candle_far_punch); + else + FSM_HANDLE (AI, ai_candle_near_punch); + robot->candles.state[robot->candles.actual_pos[i]] = Candles::PUNCHED; + } + robot->candles.actual_pos[i] = -1; } } } -- cgit v1.2.3