]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robofsm: Better version of random positions generator.
authorMichal Vokac <vokac.m@gmail.com>
Tue, 24 May 2011 14:09:55 +0000 (16:09 +0200)
committerMichal Vokac <vokac.m@gmail.com>
Tue, 24 May 2011 14:09:55 +0000 (16:09 +0200)
Do not generate positions close to table borders and on our side.

src/robofsm/common-states.cc

index 0b2681749d0827fed2e3bb36f2dd14926f5cfaa6..54394952967fadef2a7c0fd080dd8a6c1776fa62 100644 (file)
@@ -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;