From 2b345075e7591c87794d7f6d09458a20a7a91e3a Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:43:07 +0100 Subject: [PATCH] refactoring: calculate_lab_way --- src/main/c/labyrinth.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index 584f88c..7f3d89f 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -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){ 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){ field[x][y] = SOLUTION; @@ -142,16 +142,16 @@ short calculate_lab_way(Field_State** field, unsigned short len_x, unsigned shor } 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; } - field[c_x][c_y] = WAY; + field[current_x][current_y] = WAY; } turn_direction_right(&direction); }