From ff0540c821198da4ebaf104f9da383b802e6db6a Mon Sep 17 00:00:00 2001 From: Michal Vokac Date: Tue, 24 May 2011 16:09:55 +0200 Subject: [PATCH] robofsm: Better version of random positions generator. Do not generate positions close to table borders and on our side. --- src/robofsm/common-states.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/robofsm/common-states.cc b/src/robofsm/common-states.cc index 0b268174..54394952 100644 --- a/src/robofsm/common-states.cc +++ b/src/robofsm/common-states.cc @@ -125,8 +125,13 @@ FSM_STATE(move_around) enable_my_square_walls(true); - srand((int)(robot_current_time()*1000)); - goal = (rand() % (SQ_CNTR - 5)) + 5; + srand((int)(robot_current_time()*10000)); + + do { + goal = (rand() % (SQ_CNTR - 5)) + 5; + + } while (goal == 6 || goal == 11); + printf("goal %d time %f\n", goal, robot_current_time()); if (robot.team_color == RED) { goal_x = blue_sq[goal].x; -- 2.39.2