update flags + cmake
This commit is contained in:
1 parent
adcbed3276
commit
31d66f8008
4 files changed
+54
-20
No files matched your search
Vendored
+25
@@ -4,6 +4,31 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) game_text",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/build/game_text",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "make_build"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "(gdb) debug tests thoguet",
|
"name": "(gdb) debug tests thoguet",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
|
|||||||
+6
-1
@@ -25,9 +25,11 @@ target_link_libraries(game_test_thperrier game history)
|
|||||||
target_link_libraries(game_test_nnunes game history)
|
target_link_libraries(game_test_nnunes game history)
|
||||||
target_link_libraries(history_test game history)
|
target_link_libraries(history_test game history)
|
||||||
|
|
||||||
add_library (game game.c game_aux.c)
|
#Libraries
|
||||||
|
add_library (game game.c game_aux.c game_ext.c)
|
||||||
add_library(history history.c)
|
add_library(history history.c)
|
||||||
|
|
||||||
|
#Tests THOGUET
|
||||||
add_test(test_thoguet_dummy ./game_test_thoguet dummy)
|
add_test(test_thoguet_dummy ./game_test_thoguet dummy)
|
||||||
add_test(test_thoguet_game_new ./game_test_thoguet game_new)
|
add_test(test_thoguet_game_new ./game_test_thoguet game_new)
|
||||||
add_test(test_thoguet_game_print ./game_test_thoguet game_print)
|
add_test(test_thoguet_game_print ./game_test_thoguet game_print)
|
||||||
@@ -40,6 +42,7 @@ add_test(test_thoguet_game_update_flags ./game_test_thoguet game_update_flags)
|
|||||||
add_test(test_thoguet_game_play_move ./game_test_thoguet game_play_move)
|
add_test(test_thoguet_game_play_move ./game_test_thoguet game_play_move)
|
||||||
add_test(test_thoguet_game_check_move ./game_test_thoguet game_check_move)
|
add_test(test_thoguet_game_check_move ./game_test_thoguet game_check_move)
|
||||||
|
|
||||||
|
#Tests THPERRIER
|
||||||
add_test(test_thperrier_dummy ./game_test_thperrier dummy)
|
add_test(test_thperrier_dummy ./game_test_thperrier dummy)
|
||||||
add_test(test_thperrier_game_copy ./game_test_thperrier game_copy)
|
add_test(test_thperrier_game_copy ./game_test_thperrier game_copy)
|
||||||
add_test(test_thperrier_game_new_empty ./game_test_thperrier game_new_empty)
|
add_test(test_thperrier_game_new_empty ./game_test_thperrier game_new_empty)
|
||||||
@@ -50,6 +53,7 @@ add_test(test_thperrier_game_is_lightbulb ./game_test_thperrier game_is_lightbul
|
|||||||
add_test(test_thperrier_game_is_black ./game_test_thperrier game_is_black)
|
add_test(test_thperrier_game_is_black ./game_test_thperrier game_is_black)
|
||||||
add_test(test_thperrier_game_get_black_number ./game_test_thperrier game_get_black_number)
|
add_test(test_thperrier_game_get_black_number ./game_test_thperrier game_get_black_number)
|
||||||
|
|
||||||
|
#Tests NNUNES
|
||||||
add_test(test_nnunes_dummy ./game_test_nnunes dummy)
|
add_test(test_nnunes_dummy ./game_test_nnunes dummy)
|
||||||
add_test(test_nnunes_game_set_square ./game_test_nnunes game_set_square)
|
add_test(test_nnunes_game_set_square ./game_test_nnunes game_set_square)
|
||||||
add_test(test_nnunes_game_get_state ./game_test_nnunes game_get_state)
|
add_test(test_nnunes_game_get_state ./game_test_nnunes game_get_state)
|
||||||
@@ -58,6 +62,7 @@ add_test(test_nnunes_game_is_marked ./game_test_nnunes game_is_marked)
|
|||||||
add_test(test_nnunes_game_is_lighted ./game_test_nnunes game_is_lighted)
|
add_test(test_nnunes_game_is_lighted ./game_test_nnunes game_is_lighted)
|
||||||
add_test(test_nnunes_game_has_error ./game_test_nnunes game_has_error)
|
add_test(test_nnunes_game_has_error ./game_test_nnunes game_has_error)
|
||||||
|
|
||||||
|
#Tests HISTORY
|
||||||
add_test(test_history_history_alloc ./history_test history_alloc)
|
add_test(test_history_history_alloc ./history_test history_alloc)
|
||||||
add_test(test_history_create_empty ./history_test history_create_empty)
|
add_test(test_history_create_empty ./history_test history_create_empty)
|
||||||
add_test(test_history_delete_entire_history ./history_test history_delete_entire_history)
|
add_test(test_history_delete_entire_history ./history_test history_delete_entire_history)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "game_ext.h"
|
||||||
|
|
||||||
int max(int a, int b) {
|
int max(int a, int b) {
|
||||||
if (a > b)
|
if (a > b)
|
||||||
@@ -203,19 +204,21 @@ void game_update_flags(game g) {
|
|||||||
addF_LIGHTED(g, i, j);
|
addF_LIGHTED(g, i, j);
|
||||||
// add FLIGHTED on the 4 directions, when a wall is hit stop this direction, when another lightbulb is hit put the initial lighbulb on error
|
// add FLIGHTED on the 4 directions, when a wall is hit stop this direction, when another lightbulb is hit put the initial lighbulb on error
|
||||||
int tab[] = {-1, 0, 1, 0, 0, -1, 0, 1};
|
int tab[] = {-1, 0, 1, 0, 0, -1, 0, 1};
|
||||||
for (int x = 1; x < max(g->width, g->height); x++) {
|
for (int x = 1; x <= max(g->width, g->height); x++) {
|
||||||
for (uint y = 0; y < 7; y = y + 2) {
|
for (uint y = 0; y < 7 /*tab size*/; y = y + 2) {
|
||||||
if (tab[y] != tab[y + 1] && j + x * tab[y + 1] >= 0 && j + x * tab[y + 1] < g->width && i + x * tab[y] >= 0 &&
|
if (/* test if both tab are not 0*/ tab[y] != tab[y + 1] &&
|
||||||
i + x * tab[y] < g->height) {
|
(/* normal check */ (j + x * tab[y + 1] >= 0 && j + x * tab[y + 1] < g->width && i + x * tab[y] >= 0 &&
|
||||||
if (game_is_black(g, i + x * tab[y], j + x * tab[y + 1])) {
|
i + x * tab[y] < g->height) ||
|
||||||
|
/* wrapping check*/ g->wrapping)) {
|
||||||
|
if (game_is_black(g, ((i + g->height + x * tab[y]) % g->height), ((j + g->width + x * tab[y + 1]) % g->width))) {
|
||||||
tab[y] = 0;
|
tab[y] = 0;
|
||||||
tab[y + 1] = 0;
|
tab[y + 1] = 0;
|
||||||
} else {
|
} else {
|
||||||
// if we found another lightbulb on the line
|
// if we found another lightbulb on the line
|
||||||
if (game_get_state(g, i + x * tab[y], j + x * tab[y + 1]) == S_LIGHTBULB)
|
if (game_get_state(g, ((i + g->height + x * tab[y]) % g->height), ((j + g->width + x * tab[y + 1]) % g->width)) == S_LIGHTBULB)
|
||||||
// update initial lightbulb on F_ERROR
|
// 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));
|
||||||
addF_LIGHTED(g, i + x * tab[y], j + x * tab[y + 1]);
|
addF_LIGHTED(g, ((i + g->height + x * tab[y]) % g->height), ((j + g->width + x * tab[y + 1]) % g->width));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,10 +234,12 @@ void game_update_flags(game g) {
|
|||||||
int notempty = 0;
|
int notempty = 0;
|
||||||
int tab[] = {-1, 0, 1, 0, 0, -1, 0, 1};
|
int tab[] = {-1, 0, 1, 0, 0, -1, 0, 1};
|
||||||
for (uint y = 0; y < 7; y = y + 2) {
|
for (uint y = 0; y < 7; y = y + 2) {
|
||||||
if (j + tab[y + 1] >= 0 && j + tab[y + 1] < g->width && i + tab[y] >= 0 && i + tab[y] < g->height) {
|
if (/* normal check*/ (j + tab[y + 1] >= 0 && j + tab[y + 1] < g->width && i + tab[y] >= 0 && i + tab[y] < g->height) ||
|
||||||
if (game_is_lightbulb(g, i + tab[y], j + tab[y + 1]))
|
/*wrapping check*/ g->wrapping) {
|
||||||
|
if (game_is_lightbulb(g, (i + g->height + tab[y]) % g->height, (j + g->width + tab[y + 1]) % g->width))
|
||||||
lb++;
|
lb++;
|
||||||
else if (!game_is_blank(g, i + tab[y], j + tab[y + 1]) || game_is_lighted(g, i + tab[y], j + tab[y + 1]))
|
else if (!game_is_blank(g, (i + g->height + tab[y]) % g->height, (j + g->width + tab[y + 1]) % g->width) ||
|
||||||
|
game_is_lighted(g, (i + g->height + tab[y]) % g->height, (j + g->width + tab[y + 1]) % g->width))
|
||||||
notempty++;
|
notempty++;
|
||||||
} else {
|
} else {
|
||||||
notempty++;
|
notempty++;
|
||||||
|
|||||||
+8
-9
@@ -44,25 +44,24 @@ game game_new_empty_ext(uint nb_rows, uint nb_cols, bool wrapping) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint game_nb_rows(cgame g) {
|
uint game_nb_rows(cgame g) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint game_nb_cols(cgame g) {
|
uint game_nb_cols(cgame g) {
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool game_is_wrapping(cgame g) {
|
bool game_is_wrapping(cgame g) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void game_undo(game g) {
|
void game_undo(game g) {
|
||||||
if (history_prev(g->hist) == NULL){
|
if (history_prev(g->hist) == NULL) {
|
||||||
printf("waiting for your first move");
|
printf("waiting for your first move");
|
||||||
}
|
} else {
|
||||||
else{
|
game_set_square(g, history_i(history_prev(g->hist)), history_j(history_prev(g->hist)), history_state(history_prev(g->hist)));
|
||||||
game_set_square(g, history_i(history_prev(g->hist)), history_j(history_prev(g->hist)), history_state(history_prev(g->hist)));
|
game_update_flags(g);
|
||||||
game_update_flags(g);
|
g->hist = history_prev(g->hist);
|
||||||
g->hist = history_prev(g->hist);
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user