From f073e6ad9d968bd0ae02fceb848f7473e4bb81f8 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 15 May 2012 23:39:51 +0200 Subject: digital/io-hub/src/guybrush: prepare first decision in advance --- digital/io-hub/src/guybrush/strat.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'digital/io-hub/src/guybrush/strat.c') diff --git a/digital/io-hub/src/guybrush/strat.c b/digital/io-hub/src/guybrush/strat.c index bf81e462..7608ff65 100644 --- a/digital/io-hub/src/guybrush/strat.c +++ b/digital/io-hub/src/guybrush/strat.c @@ -92,6 +92,10 @@ struct strat_t uint8_t last_decision; /** Place of last decision. */ uint8_t last_place; + /** Decision is prepared in advance. */ + uint8_t prepared; + /** Prepared position. */ + vect_t prepared_pos; /** Robot content estimation. */ uint8_t load; /** Places information. */ @@ -161,6 +165,14 @@ strat_decision (vect_t *pos) int32_t best_score = -1; uint8_t best_place = 0; uint8_t i; + /* If decision was prepared, use it now. */ + if (strat.prepared) + { + strat.prepared = 0; + *pos = strat.prepared_pos; + return strat.last_decision; + } + /* Else compute the best decision. */ if (strat.load > 0) { strat.last_decision = STRAT_DECISION_UNLOAD; @@ -188,6 +200,13 @@ strat_decision (vect_t *pos) return -1; } +void +strat_prepare (void) +{ + strat_decision (&strat.prepared_pos); + strat.prepared = 1; +} + void strat_success (void) { -- cgit v1.2.3