|
@ -133,8 +133,8 @@ void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len |
|
|
short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y){ |
|
|
short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y){ |
|
|
Direction direction = N; |
|
|
Direction direction = N; |
|
|
|
|
|
|
|
|
unsigned short c_x; |
|
|
|
|
|
unsigned short c_y; |
|
|
|
|
|
|
|
|
unsigned short current_x; |
|
|
|
|
|
unsigned short current_y; |
|
|
|
|
|
|
|
|
if (x == len_x-1 && y == len_y-1){ |
|
|
if (x == len_x-1 && y == len_y-1){ |
|
|
field[x][y] = SOLUTION; |
|
|
field[x][y] = SOLUTION; |
|
@ -142,16 +142,16 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
do { |
|
|
do { |
|
|
c_x = x; |
|
|
|
|
|
c_y = y; |
|
|
|
|
|
if (lab_can_move(field, c_x, c_y, direction, len_x, len_y) == 0){ |
|
|
|
|
|
lab_move(&c_x, &c_y, direction); |
|
|
|
|
|
printf("%d - %d\n", c_x, c_y); |
|
|
|
|
|
field[c_x][c_y] = SOLUTION; |
|
|
|
|
|
if (calculate_lab_way(field, len_x, len_y, c_x, c_y) == 0){ |
|
|
|
|
|
|
|
|
current_x = x; |
|
|
|
|
|
current_y = y; |
|
|
|
|
|
if (lab_can_move(field, current_x, current_y, direction, len_x, len_y) == 0){ |
|
|
|
|
|
lab_move(¤t_x, ¤t_y, direction); |
|
|
|
|
|
printf("%d - %d\n", current_x, current_y); |
|
|
|
|
|
field[current_x][current_y] = SOLUTION; |
|
|
|
|
|
if (calculate_lab_way(field, len_x, len_y, current_x, current_y) == 0){ |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
field[c_x][c_y] = WAY; |
|
|
|
|
|
|
|
|
field[current_x][current_y] = WAY; |
|
|
} |
|
|
} |
|
|
turn_direction_right(&direction); |
|
|
turn_direction_right(&direction); |
|
|
} |
|
|
} |
|
|