summaryrefslogtreecommitdiffhomepage
path: root/digital/io
diff options
context:
space:
mode:
authorNicolas Schodet2010-05-13 13:07:58 +0200
committerNicolas Schodet2010-05-13 13:07:58 +0200
commitaae43af2228f997082a43518a19cb2fb61851207 (patch)
treed63682c01756a82c46b533b2188689e176857a7c /digital/io
parent8deb0facf1ffd3d770744fe902aaea7ad082c0a5 (diff)
digital/io/src: handle elements near borders
Diffstat (limited to 'digital/io')
-rw-r--r--digital/io/src/food.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/digital/io/src/food.c b/digital/io/src/food.c
index 10edb81f..332b46f8 100644
--- a/digital/io/src/food.c
+++ b/digital/io/src/food.c
@@ -25,6 +25,8 @@
#include "common.h"
#include "defs.h"
#include "food.h"
+#include "bot.h"
+#include "playground.h"
#include "modules/utils/utils.h"
#include "modules/math/geometry/distance.h"
@@ -179,6 +181,9 @@ food_score (position_t robot_pos, uint8_t food)
score += align;
}
/* Distance to unloading area. */
+ /* Avoid food near border. */
+ if (v.y < BOT_SIZE_RADIUS)
+ score -= 2000;
/* Done. */
return score;
}
@@ -212,6 +217,10 @@ food_pos (uint8_t food, vect_t *v)
{
assert (food < UTILS_COUNT (food_table));
*v = food_table[food].pos;
+ if (v->x < BOT_SIZE_RADIUS + 30)
+ v->x = BOT_SIZE_RADIUS + 30;
+ else if (v->x > PG_WIDTH - BOT_SIZE_RADIUS - 30)
+ v->x = PG_WIDTH - BOT_SIZE_RADIUS - 30;
}
void