Skip to content

Commit

Permalink
unfinished gui support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGAzed committed Jul 8, 2024
1 parent 9ff041d commit a8f9e1e
Show file tree
Hide file tree
Showing 34 changed files with 593 additions and 684 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(SLNOSLAV
if (WIN32)
add_compile_options(/W4)
else()
set(CMAKE_CXX_FLAGS "-std=c17 -Wall -Wextra -Wpedantic -Wnodiscarded-qualifiers")
set(CMAKE_CXX_FLAGS "-std=c23 -Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg")
set(CMAKE_CXX_FLAGS_RELEASE "-03")
endif()
Expand Down
18 changes: 0 additions & 18 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
add_library(greatest INTERFACE "")

target_include_directories(greatest INTERFACE greatest)

add_library(nuklear INTERFACE "")

target_include_directories(nuklear INTERFACE nuklear nuklear/demo/glfw_opengl3)

find_package(OpenGL REQUIRED)

if (!WIN32)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WAYLAND REQUIRED wayland-client wayland-cursor wayland-egl xkbcommon)
find_package(X11 REQUIRED)
find_package(Doxygen)
endif()

add_subdirectory(glew)

set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(glfw)
6 changes: 5 additions & 1 deletion program/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
find_package(OpenGL REQUIRED)
find_package(glfw3 3.3 REQUIRED)
find_package(GLEW REQUIRED)

add_executable(${PROJECT_NAME} main.c)

add_library(PROGRAM_LIBRARY "")
Expand Down Expand Up @@ -26,6 +30,6 @@ target_sources(PROGRAM_LIBRARY
)

target_include_directories(PROGRAM_LIBRARY PUBLIC include)
target_link_libraries(PROGRAM_LIBRARY PRIVATE glfw libglew_shared nuklear)
target_link_libraries(PROGRAM_LIBRARY PRIVATE glfw GLEW::GLEW OpenGL::GL m nuklear)

target_link_libraries(${PROJECT_NAME} PRIVATE PROGRAM_LIBRARY)
2 changes: 1 addition & 1 deletion program/include/algorithms/arc_consistency.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <structures/concrete/state.h>
#include <structures/concrete/board.h>

bool look_ahead(Kakuro board, SArray * current_state);
bool look_ahead(board_s board, SArray * current_state);

#endif /* ALGORITHMS_ARC_CONSISTENCY_H */
2 changes: 1 addition & 1 deletion program/include/algorithms/backtrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <structures/concrete/state.h>
#include <structures/concrete/board.h>

bool backtrack(Kakuro board, SArray current_state);
bool backtrack(board_s board, SArray current_state);

#endif /* ALGORITHMS_BACKTRACK_H */
2 changes: 1 addition & 1 deletion program/include/algorithms/depth_first_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <structures/concrete/state.h>
#include <structures/concrete/board.h>

SArray depth_first_search(Kakuro board);
SArray depth_first_search(board_s board);

#endif /* ALGORITHMS_DEPTH_FIRST_SEARCH_H */
2 changes: 1 addition & 1 deletion program/include/algorithms/forward_checking.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#include <structures/concrete/state.h>
#include <structures/concrete/board.h>

bool forward_checking(Kakuro board, SArray * current_state, ksize_t index);
bool forward_checking(board_s board, SArray * current_state, ulookup_t index);

#endif /* ALGORITHMS_FORWARD_CHECKING_H */
2 changes: 1 addition & 1 deletion program/include/algorithms/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <structures/concrete/state.h>
#include <structures/concrete/board.h>

void reduce(Kakuro board, SArray * initial_state);
void reduce(board_s board, SArray * initial_state);

#endif /* ALGORITHMS_REDUCE_H */
3 changes: 3 additions & 0 deletions program/include/instance/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <stdint.h>

typedef enum playstate {
STOP_E, PLAY_E, PAUSE_E,
Expand All @@ -17,6 +19,7 @@ typedef struct settings {
bool is_reduce;

playstate_e state;
uint16_t time;
} Settings;

Settings * get_settings_singleton(void);
Expand Down
3 changes: 2 additions & 1 deletion program/include/structures/abstract/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ typedef struct queue {
size_t max;
QUEUE_DATA_TYPE * elements;
#else
QLArray * head, tail;
QLArray * head;
QLArray * tail;
#endif /* FINITE_QUEUE */

} Queue;
Expand Down
40 changes: 19 additions & 21 deletions program/include/structures/concrete/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@

typedef int8_t lookup_t;
typedef uint8_t ulookup_t;
typedef uint8_t ksize_t;
typedef enum kakuro_grid_sizes { ROW = 0, COLUMN = 1, } KGSizes;
typedef struct kakuro_grid {
typedef enum kakuro_grid_sizes { ROW_E = 0, COLUMN_E = 1, } KGSizes;
typedef struct board_grid {
lookup_t **grids[GRID_DIMENTIONS];

ksize_t size[GRID_DIMENTIONS], count, empty_count;
} KGrid;
ulookup_t size[GRID_DIMENTIONS], count, empty_count;
} board_grid_s;

#define U_LOOKUP_COUNT 3
typedef struct kakuro {
KGrid game;
typedef struct board {
board_grid_s game;

lookup_t ** grid;
union {
Expand All @@ -29,26 +27,26 @@ typedef struct kakuro {
ulookup_t * blocks[GRID_DIMENTIONS];
ulookup_t * sums [GRID_DIMENTIONS];
};
ulookup_t *u_lookups[U_LOOKUP_COUNT * GRID_DIMENTIONS];
ulookup_t * u_lookups[U_LOOKUP_COUNT * GRID_DIMENTIONS];
};
} Kakuro;
} board_s;

typedef enum check {
UNCHECKED = 0, ROWCHECK = 1,
COLCHECK = 2, CHEKCED = 3,
} Check;
} check_e;

Kakuro init_kakuro(FILE * kakuro_file);
void free_kakuro(Kakuro * board);
bool is_wall_hit(Kakuro board, ksize_t row, ksize_t col);
void print_board(Kakuro board);
board_s create_board(FILE * kakuro_file);
void destroy_board(board_s * board);
bool is_wall_hit(board_s board, ulookup_t row, ulookup_t col);
void print_board(board_s board);

void add_check (Kakuro board, Check * checks, ksize_t index);
void add_row_check(Kakuro board, Check * checks, ksize_t index);
void add_col_check(Kakuro board, Check * checks, ksize_t index);
void add_check (board_s board, check_e * checks, ulookup_t index);
void add_row_check(board_s board, check_e * checks, ulookup_t index);
void add_col_check(board_s board, check_e * checks, ulookup_t index);

void sub_check (Kakuro board, Check * checks, ksize_t index);
void sub_row_check(Kakuro board, Check * checks, ksize_t index);
void sub_col_check(Kakuro board, Check * checks, ksize_t index);
void sub_check (board_s board, check_e * checks, ulookup_t index);
void sub_row_check(board_s board, check_e * checks, ulookup_t index);
void sub_col_check(board_s board, check_e * checks, ulookup_t index);

#endif /* STRUCTURES_CONCRETE_BOARD_H */
24 changes: 12 additions & 12 deletions program/include/structures/concrete/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stddef.h>
#include <stdbool.h>

typedef uint8_t ksize_t;
typedef uint8_t ulookup_t;
#define KAKURO_SIZE_MAX (sizeof(ksize_t) << 8)

#define MAX_BLOCK_VALUES 9
Expand All @@ -18,20 +18,20 @@ typedef uint16_t state_t;

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

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

typedef enum edge_type {
UPPER_EDGE = 9,
LOWER_EDGE = 1
} EType;

SArray create_state_array (ksize_t size);
SArray create_state_array (ulookup_t size);
void set_full_state_array(SArray * array);
void destroy_state_array (SArray * array);

Expand All @@ -43,16 +43,16 @@ SArray split_state (state_t state);
state_t merge_state_array(SArray array);

bool is_one_value (state_t state);
ksize_t get_sums (ksize_t start, EType type);
state_t get_edge_state(ksize_t count, EType type);
ksize_t get_one_value (state_t state);
ulookup_t get_sums (ulookup_t start, EType type);
state_t get_edge_state(ulookup_t count, EType type);
ulookup_t get_one_value (state_t state);

ksize_t state_to_sums (state_t state);
state_t get_one_state (ksize_t value);
ksize_t shortest_multi_index(SArray array);
ksize_t state_count(state_t state);
ulookup_t state_to_sums (state_t state);
state_t get_one_state (ulookup_t value);
ulookup_t shortest_multi_index(SArray array);
ulookup_t state_count(state_t state);

SMatrix generate_neighbor(SArray array, ksize_t index);
SMatrix generate_neighbor(SArray array, ulookup_t index);
void destroy_state_matrix(SMatrix * matrix);

void print_state(state_t s);
Expand Down
Loading

0 comments on commit a8f9e1e

Please sign in to comment.