views:

74

answers:

0

I am actually doing coding for a grid solver in C.

Now i have defined a function called void get_target(void){} which has to set the target_x and target_y coordinates to a value on 5*5 coordinate system. I want to traverse the grid in least possible time covering all points with minimum number of turns( only 90deg turns, 180 deg turns and straight path following are allowed).

My bot is capable of reaching any target coordinates and it keeps a track of current coordinates as well.. Now what i want the function get_target() to do is give me such values of target_x and target_y so that it starts from (0,0); moves straight to (0,5) -> (1,5) -> (1,0) and so on to (5,0)... after (5,0) the targets should be origin... ie straight along -ve X axis to origin...

However there is a catch here: there are 3 flags on some coordinates through which the bot must not move... and follow the orignal path... (i m able to know where the flags are dynamically ie only when i m 1 coordinate away from the flagged point) Please give me a short and sweet idea for function get_target(); ...