Skip to content

Commit

Permalink
another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGAzed committed Jun 13, 2024
1 parent 32516f6 commit 72ea944
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/program/SLNOSLAV",
"args": ["-fp", "test/data/11x11s.kkr"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand Down
23 changes: 0 additions & 23 deletions program/source/instance/argument.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <regex.h>

#include <instance/argument.h>
#include <instance/settings.h>
Expand Down Expand Up @@ -106,17 +105,6 @@ Hash _get_hash(char * string);
* @return Flag enum of valid program argument.
*/
Flag _get_flag(char * flag_string);
/**
* @brief
* Valides if filename in filepath is a .kkr file.
* @note
* Function uses the regex library to check if filepath ends in .kkr.
*
* @param filepath to file.
* @return true if filepath contains a .kkr file.
* @return false otherwise.
*/
bool _is_valid_file(char * filepath);

/**
* @brief
Expand Down Expand Up @@ -263,19 +251,8 @@ Flag _get_flag(char * flag_string) {
return INVALID_F; // returned if flag wasnt found.
}

bool _is_valid_file(char * filepath) {
regex_t rx = { 0 };
// assert that parser worked
assert(regcomp( &rx, "(.*)\\.(kkr)", REG_EXTENDED) == 0 && "REGEX PARSER FAILED");
bool is_valid = regexec(&rx, filepath, 0, NULL, 0) == 0; // evaualte file
regfree(&rx);

return is_valid;
}

void _setup_filepath(char * value) {
assert(value && "ARGUMENT VALUE IS NULL");
assert(_is_valid_file(value) && "INVALID FILE IN FILEPATH");
get_settings_singleton()->filepath = value;
}

Expand Down
26 changes: 18 additions & 8 deletions program/source/instance/statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ void set_dfs_stack_max_size(size_t size) {
if (size > max) get_stat_singleton()->dfs_stack_max_size = size;
}

#ifdef _MSC_VER

#define SIZE_T_FORMAT "%Iu"

#else

#define SIZE_T_FORMAT "%lu"

#endif /* _MSC_VER */

void print_statistics(void) {
puts("SETTINGS");
printf("\t - FILEPATH : %s\n", get_settings_singleton()->filepath);
Expand All @@ -49,18 +59,18 @@ void print_statistics(void) {

puts("STATISTICS");
puts("\tDEPTH FIRST SEARCH:");
printf("\t\t - DFS ITERATIONS : %lu\n", get_stat_singleton()->dfs_iteration_count);
printf("\t\t - MAX STACK SIZE : %lu\n", get_stat_singleton()->dfs_stack_max_size);
printf("\t\t - DFS ITERATIONS : "SIZE_T_FORMAT"\n", get_stat_singleton()->dfs_iteration_count);
printf("\t\t - MAX STACK SIZE : "SIZE_T_FORMAT"\n", get_stat_singleton()->dfs_stack_max_size);

puts("\tBACKTRACK:");
printf("\t\t - CALLS : %lu\n", get_stat_singleton()->backtrack_call_count);
printf("\t\t - VALID BACKTRACKS : %lu\n", get_stat_singleton()->invalid_state_backtrack_count);
printf("\t\t - CALLS : "SIZE_T_FORMAT"\n", get_stat_singleton()->backtrack_call_count);
printf("\t\t - VALID BACKTRACKS : "SIZE_T_FORMAT"\n", get_stat_singleton()->invalid_state_backtrack_count);

puts("\tFORWARD CHECK:");
printf("\t\t - CALLS : %lu\n", get_stat_singleton()->forward_check_call_count);
printf("\t\t - INVALID FORWARD CHECKS : %lu\n", get_stat_singleton()->invalid_state_forward_check_count);
printf("\t\t - CALLS : "SIZE_T_FORMAT"\n", get_stat_singleton()->forward_check_call_count);
printf("\t\t - INVALID FORWARD CHECKS : "SIZE_T_FORMAT"\n", get_stat_singleton()->invalid_state_forward_check_count);

puts("\tARC CONSISTENCY (LOOK AHEAD):");
printf("\t\t - CALLS : %lu\n", get_stat_singleton()->look_ahead_call_count);
printf("\t\t - INVALID LOOK AHEAD : %lu\n", get_stat_singleton()->invalid_state_look_ahead_count);
printf("\t\t - CALLS : "SIZE_T_FORMAT"\n", get_stat_singleton()->look_ahead_call_count);
printf("\t\t - INVALID LOOK AHEAD : "SIZE_T_FORMAT"\n", get_stat_singleton()->invalid_state_look_ahead_count);
}

0 comments on commit 72ea944

Please sign in to comment.