From 0cf5dfed3e492608d044a5fc90c1815fab506fd7 Mon Sep 17 00:00:00 2001 From: scratko Date: Sun, 14 Apr 2024 21:18:36 +0300 Subject: Capture and liberation of ghosts Fixed coordinate in field_has_coin. Added marks on the field for the liberation zone (1 in front of #). Prison parameters for the ghost are set. Fixed condition in BFS search (additionally exclude the current point in the loop, dx == 0 && dy == 0). --- field.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'field.c') diff --git a/field.c b/field.c index 2dcd783..340e380 100644 --- a/field.c +++ b/field.c @@ -17,7 +17,7 @@ static const char field_sample[field_height][field_width] = { {"/1....2//1..1//1..1//2....1/"}, {"//////.///// // /////.//////"}, {" /.///// // /////./ "}, - {" /.//1 y y 1//./ "}, + {" /.//1 y11y 1//./ "}, {" /.// ///##/// //./ "}, {"//////.// / /2 2//////"}, {" 3 2/ / //2 "}, @@ -55,9 +55,10 @@ game_space get_new_field() int field_has_coin(int x, int y) { - return !((x == 12 && y == 9) || (x == 12 && y == 18) || - (x == 14 && y == 18) || (x == 15 && y == 9) || - (x == 17 && y == 9) || (x == 17 && y == 18)); + return !((x == 9 && y == 12)|| (x == 18 && y == 12) || + (x == 18 && y == 14) || (x == 9 && y == 15) || + (x == 9 && y == 17) || (x == 18 && y == 17) || + (x == 13 && y == 12) || (x == 14 && y == 12)); } int field_has_energizer(const game_space field, int x, int y) @@ -242,3 +243,14 @@ void clear_energizer(game_space field, struct coordinates point) y = point.y; field[y][x] = ' '; } + +int is_equal_points(struct coordinates first_point, struct coordinates + second_point) +{ + int x1, y1, x2, y2; + x1 = first_point.x; + y1 = first_point.y; + x2 = second_point.x; + y2 = second_point.y; + return x1 == x2 && y1 == y2; +} -- cgit v1.2.3