Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGAzed committed Jun 13, 2024
1 parent 5337700 commit aedd23d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(SLNOSLAV
)

if(MSVC)
set(CMAKE_C_FLAGS "-std=c17 -pg -Wall /WX")
set(CMAKE_C_FLAGS "-std=c17 -pg -Wall")
else()
set(CMAKE_C_FLAGS "-std=c17 -pg -Wall -Werror")
endif()
Expand Down
6 changes: 3 additions & 3 deletions program/include/structures/concrete/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ typedef uint8_t ulookup_t;
typedef uint8_t ksize_t;
typedef enum kakuro_grid_sizes { ROW = 0, COLUMN = 1, } KGSizes;
typedef struct kakuro_grid {
lookup_t **grids[GRID_DIMENTIONS];

ksize_t size[GRID_DIMENTIONS];
ksize_t count;
ksize_t empty_count;
ksize_t size[GRID_DIMENTIONS];

lookup_t **grids[GRID_DIMENTIONS];
} KGrid;

#define U_LOOKUP_COUNT 3
Expand Down
4 changes: 2 additions & 2 deletions program/include/structures/concrete/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ typedef uint8_t ksize_t;
typedef uint16_t state_t;

typedef struct state_array {
ksize_t size;
state_t * elements;
ksize_t size;
} SArray;

typedef struct state_array_array {
ksize_t size;
SArray elements[MAX_BLOCK_VALUES];
ksize_t size;
} SMatrix;

typedef enum edge_type {
Expand Down
7 changes: 7 additions & 0 deletions program/source/algorithms/backtrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#include <instance/settings.h>
#include <instance/statistics.h>

#ifdef _MSC_VER

#include <intrin.h>
#define __builtin_ctz __lzcnt

#endif /* _MSC_VER */

bool _backtrack_row_sum(Kakuro board, SArray current_state, size_t index);
bool _backtrack_col_sum(Kakuro board, SArray current_state, size_t index);

Expand Down
2 changes: 1 addition & 1 deletion program/source/structures/concrete/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void _kakuro_alloc(Kakuro * board, FILE * kakuro_file) {
void _kakuro_setup(Kakuro * board) {
assert(board && "KAKURO POINTER IS NULL");

size_t index = 0;
lookup_t index = 0;
for (size_t r = 0; r < board->game.size[ROW]; r++) {
for (size_t c = 0; c < board->game.size[COLUMN]; c++) {
board->grid[r][c] = (board->game.grids[ROW][r][c] == 0) ? index++ : -1;
Expand Down
9 changes: 8 additions & 1 deletion program/source/structures/concrete/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

#include <structures/concrete/state.h>

#ifdef _MSC_VER

#include <intrin.h>
#define __builtin_ctz __lzcnt
#define __builtin_popcount __popcnt

#endif /* _MSC_VER */

SArray create_state_array(ksize_t size) {
assert(size != 0 && "SIZE OF ARRAY CAN'T BE ZERO");

Expand Down Expand Up @@ -110,7 +118,6 @@ ksize_t state_to_sums(state_t state) {
copy_state &= ~(copy_state & -copy_state);
}

//for (ksize_t i = 0; i < MAX_BLOCK_VALUES; i++) if (state & (1 << i)) sum += i + 1;
return sum;
}

Expand Down

0 comments on commit aedd23d

Please sign in to comment.