|
|
@ -130,3 +130,32 @@ void ask_lab_walls(Field_State** field, unsigned short len_x, unsigned short len |
|
|
|
} while (wall_input_continue != 1); |
|
|
|
} |
|
|
|
|
|
|
|
short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned short len_y, unsigned short x, unsigned short y){ |
|
|
|
Direction direction = N; |
|
|
|
|
|
|
|
unsigned short c_x; |
|
|
|
unsigned short c_y; |
|
|
|
|
|
|
|
if (x == len_x-1 && y == len_y-1){ |
|
|
|
field[x][y] = SOLUTION; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
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){ |
|
|
|
return 0; |
|
|
|
} |
|
|
|
field[c_x][c_y] = WAY; |
|
|
|
} |
|
|
|
turn_direction_right(&direction); |
|
|
|
} |
|
|
|
while (direction != N); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|