From 7d826b608232b8ed86501878f2bbe4636c624e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophyl=20Hoguet?= Date: Thu, 9 Dec 2021 18:23:38 +0100 Subject: [PATCH] update clang --- game.c | 79 +++++++++++++++---------------------------- game.h | 35 ++++++++++--------- game_aux.c | 7 ++-- game_test_nnunes.c | 6 ++-- game_test_thoguet.c | 72 ++++++++++++--------------------------- game_test_thperrier.c | 3 +- game_text.c | 3 +- 7 files changed, 72 insertions(+), 133 deletions(-) diff --git a/game.c b/game.c index 4fa1b7c..95aa361 100644 --- a/game.c +++ b/game.c @@ -122,9 +122,7 @@ bool game_is_blank(cgame g, uint i, uint j) { } bool game_is_lightbulb(cgame g, uint i, uint j) { - return ((g->tab_cell[i][j] == S_LIGHTBULB) || - (g->tab_cell[i][j] == (S_LIGHTBULB | F_LIGHTED)) || - (g->tab_cell[i][j] == (S_LIGHTBULB | F_ERROR)) || + return ((g->tab_cell[i][j] == S_LIGHTBULB) || (g->tab_cell[i][j] == (S_LIGHTBULB | F_LIGHTED)) || (g->tab_cell[i][j] == (S_LIGHTBULB | F_ERROR)) || (g->tab_cell[i][j] == (S_LIGHTBULB | F_LIGHTED | F_ERROR))); } @@ -141,9 +139,7 @@ int game_get_black_number(cgame g, uint i, uint j) { } bool game_is_marked(cgame g, uint i, uint j) { - return ((g->tab_cell[i][j] == S_MARK) || - (g->tab_cell[i][j] == (S_MARK | F_LIGHTED)) || - (g->tab_cell[i][j] == (S_MARK | F_ERROR)) || + return ((g->tab_cell[i][j] == S_MARK) || (g->tab_cell[i][j] == (S_MARK | F_LIGHTED)) || (g->tab_cell[i][j] == (S_MARK | F_ERROR)) || (g->tab_cell[i][j] == (S_MARK | F_LIGHTED | F_ERROR))); } @@ -165,9 +161,7 @@ bool game_has_error(cgame g, uint i, uint j) { } bool game_check_move(cgame g, uint i, uint j, square s) { - if (i >= DEFAULT_SIZE || j >= DEFAULT_SIZE || - (s != S_BLANK && s != S_MARK && s != S_LIGHTBULB) || - game_is_black(g, i, j)) + if (i >= DEFAULT_SIZE || j >= DEFAULT_SIZE || (s != S_BLANK && s != S_MARK && s != S_LIGHTBULB) || game_is_black(g, i, j)) return false; return true; } @@ -177,58 +171,49 @@ void game_play_move(game g, uint i, uint j, square s) { game_update_flags(g); } -void game_update_flags(game g) { +void delete_flags(g) { // delete prev flags for (uint i = 0; i < DEFAULT_SIZE; i++) { for (uint j = 0; j < DEFAULT_SIZE; j++) { game_set_square(g, i, j, game_get_state(g, i, j)); } } +} + +void game_update_flags(game g) { + delete_flags(g); // update flags lighted and lightbulb error for (uint i = 0; i < DEFAULT_SIZE; i++) { for (uint j = 0; j < DEFAULT_SIZE; j++) { if (game_get_state(g, i, j) == S_LIGHTBULB) { - if (game_get_flags(g, i, j) > 16) - game_set_square(g, i, j, - (S_LIGHTBULB | F_LIGHTED | F_ERROR)); + if (game_get_flags(g, i, j) == F_ERROR) + game_set_square(g, i, j, (S_LIGHTBULB | F_LIGHTED | F_ERROR)); else game_set_square(g, i, j, (S_LIGHTBULB | F_LIGHTED)); - for (uint i2 = i + 1; - i2 < DEFAULT_SIZE && !game_is_black(g, i2, j); i2++) { + for (uint i2 = i + 1; i2 < DEFAULT_SIZE && !game_is_black(g, i2, j); i2++) { if (game_get_state(g, i2, j) == S_LIGHTBULB) // update initial lightbulb on F_ERROR - game_set_square(g, i, j, - (S_LIGHTBULB | F_LIGHTED | F_ERROR)); + game_set_square(g, i, j, (S_LIGHTBULB | F_LIGHTED | F_ERROR)); // update cases on FLIGHTED - game_set_square(g, i2, j, - (game_get_state(g, i2, j) | F_LIGHTED)); + game_set_square(g, i2, j, (game_get_state(g, i2, j) | F_LIGHTED)); } - for (int i2 = i - 1; i2 >= 0 && !game_is_black(g, i2, j); - i2--) { + for (int i2 = i - 1; i2 >= 0 && !game_is_black(g, i2, j); i2--) { if (game_get_state(g, i2, j) == S_LIGHTBULB) // update initial lightbulb on F_ERROR - game_set_square(g, i, j, - (S_LIGHTBULB | F_LIGHTED | F_ERROR)); - game_set_square(g, i2, j, - (game_get_state(g, i2, j) | F_LIGHTED)); + game_set_square(g, i, j, (S_LIGHTBULB | F_LIGHTED | F_ERROR)); + game_set_square(g, i2, j, (game_get_state(g, i2, j) | F_LIGHTED)); } - for (int j2 = j - 1; j2 >= 0 && !game_is_black(g, i, j2); - j2--) { + for (int j2 = j - 1; j2 >= 0 && !game_is_black(g, i, j2); j2--) { if (game_get_state(g, i, j2) == S_LIGHTBULB) // update initial lightbulb on F_ERROR - game_set_square(g, i, j, - (S_LIGHTBULB | F_LIGHTED | F_ERROR)); - game_set_square(g, i, j2, - (game_get_state(g, i, j2) | F_LIGHTED)); + game_set_square(g, i, j, (S_LIGHTBULB | F_LIGHTED | F_ERROR)); + game_set_square(g, i, j2, (game_get_state(g, i, j2) | F_LIGHTED)); } - for (uint j2 = j + 1; - j2 < DEFAULT_SIZE && !game_is_black(g, i, j2); j2++) { + for (uint j2 = j + 1; j2 < DEFAULT_SIZE && !game_is_black(g, i, j2); j2++) { if (game_get_state(g, i, j2) == S_LIGHTBULB) // update initial lightbulb on F_ERROR - game_set_square(g, i, j, - (S_LIGHTBULB | F_LIGHTED | F_ERROR)); - game_set_square(g, i, j2, - (game_get_state(g, i, j2) | F_LIGHTED)); + game_set_square(g, i, j, (S_LIGHTBULB | F_LIGHTED | F_ERROR)); + game_set_square(g, i, j2, (game_get_state(g, i, j2) | F_LIGHTED)); } } } @@ -267,23 +252,18 @@ void game_update_flags(game g) { notempty++; } for (int l = 0; l < size; l++) { - if (choice[l] == S_LIGHTBULB || - choice[l] == (S_LIGHTBULB | F_LIGHTED) || - choice[l] == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { + if (choice[l] == S_LIGHTBULB || choice[l] == (S_LIGHTBULB | F_LIGHTED) || choice[l] == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { lb++; } else if (choice[l] != S_BLANK) { notempty++; } } if (lb > game_get_black_number(g, i, j)) { - game_set_square(g, i, j, - (game_get_state(g, i, j) | F_ERROR)); + game_set_square(g, i, j, (game_get_state(g, i, j) | F_ERROR)); } // look if there is enough empty cell around the wall - else if (notempty > - abs(game_get_black_number(g, i, j) - 4)) { - game_set_square(g, i, j, - (game_get_state(g, i, j) | F_ERROR)); + else if (notempty > abs(game_get_black_number(g, i, j) - 4)) { + game_set_square(g, i, j, (game_get_state(g, i, j) | F_ERROR)); } } } @@ -294,9 +274,7 @@ void game_update_flags(game g) { bool game_is_over(cgame g) { for (uint i = 0; i < DEFAULT_SIZE; i++) { for (uint j = 0; j < DEFAULT_SIZE; j++) { - if ((game_get_state(g, i, j) == S_BLANK && - game_get_flags(g, i, j) == S_BLANK) || - game_get_flags(g, i, j) == F_ERROR || + if ((game_get_state(g, i, j) == S_BLANK && game_get_flags(g, i, j) == S_BLANK) || game_get_flags(g, i, j) == F_ERROR || game_get_flags(g, i, j) == (F_LIGHTED | F_ERROR)) return false; } @@ -307,8 +285,7 @@ bool game_is_over(cgame g) { void game_restart(game g) { for (uint i = 0; i < DEFAULT_SIZE; i++) { for (uint j = 0; j < DEFAULT_SIZE; j++) { - if (game_get_state(g, i, j) == S_MARK || - game_get_state(g, i, j) == S_LIGHTBULB) + if (game_get_state(g, i, j) == S_MARK || game_get_state(g, i, j) == S_LIGHTBULB) game_set_square(g, i, j, S_BLANK); } } diff --git a/game.h b/game.h index 3a2af8a..2206fb7 100644 --- a/game.h +++ b/game.h @@ -33,20 +33,20 @@ typedef unsigned int uint; * https://en.wikipedia.org/wiki/Bitwise_operations_in_C. **/ typedef enum { - /* states */ - S_BLANK = 0, /**< a blank square */ - S_LIGHTBULB = 1, /**< a light bulb */ - S_MARK = 2, /**< a marked square (as not-a-light) */ - S_BLACK = 8, /**< black wall base code */ - S_BLACK0 = S_BLACK, /**< a numbered black wall (with 0 adjacent lights) */ - S_BLACK1, /**< a numbered black wall (with 1 adjacent light) */ - S_BLACK2, /**< a numbered black wall (with 2 adjacent lights) */ - S_BLACK3, /**< a numbered black wall (with 3 adjacent lights) */ - S_BLACK4, /**< a numbered black wall (with 4 adjacent lights) */ - S_BLACKU, /**< an unnumbered black wall (any number of adjacent lights) */ - /* flags */ - F_LIGHTED = 16, /**< lighted flag */ - F_ERROR = 32 /**< error flag */ + /* states */ + S_BLANK = 0, /**< a blank square */ + S_LIGHTBULB = 1, /**< a light bulb */ + S_MARK = 2, /**< a marked square (as not-a-light) */ + S_BLACK = 8, /**< black wall base code */ + S_BLACK0 = S_BLACK, /**< a numbered black wall (with 0 adjacent lights) */ + S_BLACK1, /**< a numbered black wall (with 1 adjacent light) */ + S_BLACK2, /**< a numbered black wall (with 2 adjacent lights) */ + S_BLACK3, /**< a numbered black wall (with 3 adjacent lights) */ + S_BLACK4, /**< a numbered black wall (with 4 adjacent lights) */ + S_BLACKU, /**< an unnumbered black wall (any number of adjacent lights) */ + /* flags */ + F_LIGHTED = 16, /**< lighted flag */ + F_ERROR = 32 /**< error flag */ } square; /** state mask used in square enum */ @@ -61,14 +61,14 @@ typedef enum { /** * @brief The structure pointer that stores the game state. **/ -typedef struct game_s *game; +typedef struct game_s* game; /** * @brief The structure constant pointer that stores the game state. * @details That means that it is not possible to modify the game using this * pointer. **/ -typedef const struct game_s *cgame; +typedef const struct game_s* cgame; /** * @brief Creates a new game with default size and initializes it. @@ -78,7 +78,7 @@ typedef const struct game_s *cgame; * @pre @p squares must be an initialized array of default size squared. * @return the created game **/ -game game_new(square *squares); +game game_new(square* squares); /** * @brief Creates a new empty game with defaut size. @@ -251,7 +251,6 @@ bool game_is_lighted(cgame g, uint i, uint j); **/ bool game_has_error(cgame g, uint i, uint j); - /** * @brief Checks if a given move is legal. * @details This function checks that it is possible to play a move at a given diff --git a/game_aux.c b/game_aux.c index 9168c56..cb2c983 100644 --- a/game_aux.c +++ b/game_aux.c @@ -7,13 +7,10 @@ char charPrintCell(square sqState) { return ' '; } if ((sqState == S_LIGHTBULB) || - (sqState == (S_LIGHTBULB | F_ERROR)) | - (sqState == (S_LIGHTBULB | F_LIGHTED)) | - (sqState == (S_LIGHTBULB | F_ERROR | F_LIGHTED))) { + (sqState == (S_LIGHTBULB | F_ERROR)) | (sqState == (S_LIGHTBULB | F_LIGHTED)) | (sqState == (S_LIGHTBULB | F_ERROR | F_LIGHTED))) { return '*'; } - if ((sqState == S_MARK) || - (sqState == (S_MARK | F_ERROR)) | (sqState == (S_MARK | F_LIGHTED))) { + if ((sqState == S_MARK) || (sqState == (S_MARK | F_ERROR)) | (sqState == (S_MARK | F_LIGHTED))) { return '-'; } if (sqState == S_BLACK0 || sqState == (S_BLACK0 | F_ERROR)) { diff --git a/game_test_nnunes.c b/game_test_nnunes.c index 24f823f..c418dbc 100644 --- a/game_test_nnunes.c +++ b/game_test_nnunes.c @@ -332,8 +332,7 @@ bool test_game_is_lighted(void) { return true; } game_set_square(g, 0, 0, S_BLANK | F_LIGHTED | F_ERROR); - if ((game_get_flags(g, 0, 0) == (F_LIGHTED | F_ERROR)) && - game_is_lighted(g, 0, 0)) { + if ((game_get_flags(g, 0, 0) == (F_LIGHTED | F_ERROR)) && game_is_lighted(g, 0, 0)) { game_delete(g); return true; } @@ -350,8 +349,7 @@ bool test_game_has_error(void) { return true; } game_set_square(g, 0, 0, S_LIGHTBULB | F_LIGHTED | F_ERROR); - if ((game_get_flags(g, 0, 0) == (F_LIGHTED | F_ERROR)) && - game_has_error(g, 0, 0)) { + if ((game_get_flags(g, 0, 0) == (F_LIGHTED | F_ERROR)) && game_has_error(g, 0, 0)) { game_delete(g); return true; } diff --git a/game_test_thoguet.c b/game_test_thoguet.c index 7e54964..fc80d6c 100644 --- a/game_test_thoguet.c +++ b/game_test_thoguet.c @@ -58,9 +58,7 @@ bool test_game_restart(void) { bool test_game_new(void) { square tab[DEFAULT_SIZE * DEFAULT_SIZE]; game g; - square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK, - S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, - S_BLACK4, S_BLACKU, F_ERROR}; + square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK, S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU, F_ERROR}; for (uint i = 0; i < sizeof(list) / sizeof(list[0]); i++) { g = NULL; for (uint j = 0; j < DEFAULT_SIZE * DEFAULT_SIZE; j++) { @@ -70,8 +68,7 @@ bool test_game_new(void) { g = game_new(tab); for (uint i2 = 0; i2 < DEFAULT_SIZE; i2++) { for (uint j = 0; j < DEFAULT_SIZE; j++) { - printf("list :%d, get square :%d\n", list[i], - game_get_square(g, i2, j)); + printf("list :%d, get square :%d\n", list[i], game_get_square(g, i2, j)); assert(list[i] == game_get_square(g, i2, j)); } } @@ -87,8 +84,7 @@ bool test_game_new(void) { bool test_game_print(void) { square tab[DEFAULT_SIZE * DEFAULT_SIZE]; - square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, - S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU}; + square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU}; game g; for (uint i = 0; i < sizeof(list) / sizeof(list[0]); i++) { for (uint j = 0; j < DEFAULT_SIZE * DEFAULT_SIZE; j++) { @@ -108,25 +104,14 @@ bool test_game_print(void) { bool test_game_get_square(void) { game g; square tab[DEFAULT_SIZE * DEFAULT_SIZE]; - square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK, - S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, - S_BLACK4, S_BLACKU, F_ERROR}; + square list[] = {S_BLANK, S_LIGHTBULB, S_MARK, S_BLACK, S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU, F_ERROR}; for (uint i = 0; i < sizeof(list) / sizeof(list[0]); i++) { for (uint j = 0; j < DEFAULT_SIZE * DEFAULT_SIZE; j++) { tab[j] = list[i]; g = game_new(tab); - printf( - "[%d, %d] %d %d\n", j / (DEFAULT_SIZE), - j - (j / (DEFAULT_SIZE)) - - (j / (DEFAULT_SIZE) * (DEFAULT_SIZE - 1)), - game_get_square(g, j / (DEFAULT_SIZE), - j - (j / (DEFAULT_SIZE)) - - (j / (DEFAULT_SIZE) * (DEFAULT_SIZE - 1))), - tab[j]); - assert(game_get_square(g, j / (DEFAULT_SIZE), - j - (j / (DEFAULT_SIZE)) - - (j / (DEFAULT_SIZE) * - (DEFAULT_SIZE - 1))) == tab[j]); + printf("[%d, %d] %d %d\n", j / (DEFAULT_SIZE), j - (j / (DEFAULT_SIZE)) - (j / (DEFAULT_SIZE) * (DEFAULT_SIZE - 1)), + game_get_square(g, j / (DEFAULT_SIZE), j - (j / (DEFAULT_SIZE)) - (j / (DEFAULT_SIZE) * (DEFAULT_SIZE - 1))), tab[j]); + assert(game_get_square(g, j / (DEFAULT_SIZE), j - (j / (DEFAULT_SIZE)) - (j / (DEFAULT_SIZE) * (DEFAULT_SIZE - 1))) == tab[j]); game_delete(g); } } @@ -192,8 +177,7 @@ int checklightbulb(game g, uint i, uint j, bool wall) { // if true we can break the loop because every others cases wont be lighted // by the bulb we are testing if (game_is_lightbulb(g, i, j)) { - if (/*test if this lightbulb is well updated*/ flags == S_BLANK || - flags == F_ERROR) { + if (/*test if this lightbulb is well updated*/ flags == S_BLANK || flags == F_ERROR) { // printf("156\n"); return 0; } @@ -214,8 +198,7 @@ int checklightbulb(game g, uint i, uint j, bool wall) { for (int i2 = i - 1; i2 >= 0; i2--) { flags = game_get_square(g, i2, j); // printf("i2:%d i2state:%d i2flags:%d\n",i2,state,flags); - if (flags == (S_LIGHTBULB | F_LIGHTED) || - flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { + if (flags == (S_LIGHTBULB | F_LIGHTED) || flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { return -1; } if (flags != F_LIGHTED && flags != (F_LIGHTED | S_MARK)) { @@ -224,8 +207,7 @@ int checklightbulb(game g, uint i, uint j, bool wall) { } for (int i2 = i + 1; i2 < DEFAULT_SIZE; i2++) { flags = game_get_square(g, i2, j); - if (flags == (S_LIGHTBULB | F_LIGHTED) || - flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { + if (flags == (S_LIGHTBULB | F_LIGHTED) || flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { return -1; } if (flags != F_LIGHTED && flags != (F_LIGHTED | S_MARK)) { @@ -234,8 +216,7 @@ int checklightbulb(game g, uint i, uint j, bool wall) { } for (int j2 = j - 1; j2 >= 0; j2--) { flags = game_get_square(g, i, j2); - if (flags == (S_LIGHTBULB | F_LIGHTED) || - flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { + if (flags == (S_LIGHTBULB | F_LIGHTED) || flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { return -1; } if (flags != F_LIGHTED && flags != (F_LIGHTED | S_MARK)) { @@ -244,8 +225,7 @@ int checklightbulb(game g, uint i, uint j, bool wall) { } for (int j2 = j + 1; j2 < DEFAULT_SIZE; j2++) { flags = game_get_square(g, i, j2); - if (flags == (S_LIGHTBULB | F_LIGHTED) || - flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { + if (flags == (S_LIGHTBULB | F_LIGHTED) || flags == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { return -1; } if (flags != F_LIGHTED && flags != (F_LIGHTED | S_MARK)) { @@ -270,17 +250,14 @@ bool check_update(game g) { for (uint j = 0; j < DEFAULT_SIZE; j++) { if (game_is_lightbulb(g, i, j)) { square flags = game_get_flags(g, i, j); - if (/*test if this lightbulb is well updated*/ flags == - S_BLANK || - flags == F_ERROR) { + if (/*test if this lightbulb is well updated*/ flags == S_BLANK || flags == F_ERROR) { // printf("196\n"); return false; } // loop checking every case before i wall = false; for (int k = i - 1; k >= 0; k--) { - if (/*test if current case is a wall*/ game_is_black(g, k, - j)) { + if (/*test if current case is a wall*/ game_is_black(g, k, j)) { wall = true; } else { int tmp = checklightbulb(g, k, j, wall); @@ -294,8 +271,7 @@ bool check_update(game g) { } wall = false; for (int k = i + 1; k < DEFAULT_SIZE; k++) { - if (/*test if current case is a wall*/ game_is_black(g, k, - j)) { + if (/*test if current case is a wall*/ game_is_black(g, k, j)) { wall = true; } else { int tmp = checklightbulb(g, k, j, wall); @@ -309,8 +285,7 @@ bool check_update(game g) { } wall = false; for (int k = j - 1; k >= 0; k--) { - if (/*test if current case is a wall*/ game_is_black(g, i, - k)) { + if (/*test if current case is a wall*/ game_is_black(g, i, k)) { wall = true; } else { int tmp = checklightbulb(g, i, k, wall); @@ -324,8 +299,7 @@ bool check_update(game g) { } wall = false; for (int k = j + 1; k < DEFAULT_SIZE; k++) { - if (/*test if current case is a wall*/ game_is_black(g, i, - k)) { + if (/*test if current case is a wall*/ game_is_black(g, i, k)) { wall = true; } else { int tmp = checklightbulb(g, i, k, wall); @@ -337,8 +311,7 @@ bool check_update(game g) { } } } - } else if (/*test if current case is a wall*/ game_is_black(g, i, - j)) { + } else if (/*test if current case is a wall*/ game_is_black(g, i, j)) { if (game_get_black_number(g, i, j) != -1) { // lookup for lightbulb and emptycells size = 0; @@ -370,8 +343,7 @@ bool check_update(game g) { notempty++; } for (int l = 0; l < size; l++) { - if (choice[l] == (S_LIGHTBULB | F_LIGHTED) || - choice[l] == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { + if (choice[l] == (S_LIGHTBULB | F_LIGHTED) || choice[l] == (S_LIGHTBULB | F_LIGHTED | F_ERROR)) { lb++; } else if (choice[l] != S_BLANK) { notempty++; @@ -381,8 +353,7 @@ bool check_update(game g) { res = false; } // look if there is enough empty cell around the wall - else if (notempty > - abs(game_get_black_number(g, i, j) - 4)) { + else if (notempty > abs(game_get_black_number(g, i, j) - 4)) { res = false; } if (game_get_flags(g, i, j) == F_ERROR) { @@ -410,8 +381,7 @@ bool brutforce(game g, int a, bool* deldup) { fprintf(stderr, "Not enought memory\n"); exit(EXIT_FAILURE); } - square list[] = {S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2, - S_BLACK3, S_BLACK4, S_BLACKU, S_BLANK}; + square list[] = {S_LIGHTBULB, S_MARK, S_BLACK0, S_BLACK1, S_BLACK2, S_BLACK3, S_BLACK4, S_BLACKU, S_BLANK}; for (uint i = 0; i < DEFAULT_SIZE; i++) { for (uint j = 0; j < DEFAULT_SIZE; j++) { // printf("state: %d i:%d j:%d\n",game_get_state(g,i,j),i,j); diff --git a/game_test_thperrier.c b/game_test_thperrier.c index 0754180..bc77498 100644 --- a/game_test_thperrier.c +++ b/game_test_thperrier.c @@ -122,8 +122,7 @@ bool test_game_is_black() { bool test_game_is_lightbulb() { game g = game_new_empty(); game_set_square(g, 0, 0, S_LIGHTBULB); - if ((game_get_square(g, 0, 0) == S_LIGHTBULB) && - game_is_lightbulb(g, 0, 0)) { + if ((game_get_square(g, 0, 0) == S_LIGHTBULB) && game_is_lightbulb(g, 0, 0)) { game_delete(g); return true; } diff --git a/game_text.c b/game_text.c index 46b9d55..57adcb1 100644 --- a/game_text.c +++ b/game_text.c @@ -79,8 +79,7 @@ int main(void) { return EXIT_SUCCESS; } else if (c == 'l' || c == 'm' || c == 'b') { if (scanf(" %u %u", &i, &j) == 2) { - if (i < DEFAULT_SIZE && j < DEFAULT_SIZE && - !game_is_black(g, i, j)) { + if (i < DEFAULT_SIZE && j < DEFAULT_SIZE && !game_is_black(g, i, j)) { if (c == 'l') { game_set_square(g, i, j, S_LIGHTBULB); game_update_flags(g);