summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io/src')
-rw-r--r--digital/io/src/food.c20
-rw-r--r--digital/io/src/food.h4
-rw-r--r--digital/io/src/top.c2
3 files changed, 20 insertions, 6 deletions
diff --git a/digital/io/src/food.c b/digital/io/src/food.c
index 87c44b41..c081e4ae 100644
--- a/digital/io/src/food.c
+++ b/digital/io/src/food.c
@@ -166,7 +166,7 @@ food_score (position_t robot_pos, uint8_t food)
if (food_table[food].type == FOOD_TYPE_TOMATO)
score += 100;
else
- score -= 4000;
+ score -= 200;
/* Distance to robot. */
food_pos (food, &v);
int32_t dr = distance_point_point (&v, &robot_pos.v);
@@ -219,10 +219,20 @@ 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;
+}
+
+int16_t
+food_shorten (uint8_t food)
+{
+ assert (food < UTILS_COUNT (food_table));
+ int16_t shorten = 0;
+ /* Corns. */
+ if (food_table[food].type == FOOD_TYPE_CORN)
+ shorten = BOT_SIZE_FRONT + 50;
+ /* Food on playground sides. */
+ if (food <= 4 || (food >= 14 && food <= 18))
+ shorten = BOT_SIZE_FRONT;
+ return shorten;
}
void
diff --git a/digital/io/src/food.h b/digital/io/src/food.h
index a0b7b8eb..cc8ba4f1 100644
--- a/digital/io/src/food.h
+++ b/digital/io/src/food.h
@@ -59,4 +59,8 @@ food_pos (uint8_t food, vect_t *v);
void
food_taken (position_t robot_pos);
+/** Return shorten distance to be used to pick this food. */
+int16_t
+food_shorten (uint8_t food);
+
#endif /* food_h */
diff --git a/digital/io/src/top.c b/digital/io/src/top.c
index f68a71b7..a93496c1 100644
--- a/digital/io/src/top.c
+++ b/digital/io/src/top.c
@@ -57,7 +57,7 @@ top_collect (uint8_t force)
return 0;
vect_t food_v;
food_pos (food, &food_v);
- move_start_noangle (food_v, 0, 0);
+ move_start_noangle (food_v, 0, food_shorten (food));
return 1;
}
else