From a220477446983ddd4e93d41eac24540891d273fe Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Sun, 11 May 2025 21:29:38 -0400 Subject: [PATCH] meow --- .gitmodules | 3 ++ CMakeLists.txt | 79 ++++++++++++++++++++++++++++++ lib/blt-with-graphics | 1 + src/main.cpp | 111 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 lib/blt-with-graphics create mode 100644 src/main.cpp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..70a5151 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/blt-with-graphics"] + path = lib/blt-with-graphics + url = https://git.tpgc.me/tri11paragon/BLT-With-Graphics-Template diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b4104df --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,79 @@ +cmake_minimum_required(VERSION 3.25) + +macro(sanitizers target_name) + if (${ENABLE_ADDRSAN} MATCHES ON) + target_compile_options(${target_name} PRIVATE -fsanitize=address) + target_link_options(${target_name} PRIVATE -fsanitize=address) + endif () + + if (${ENABLE_UBSAN} MATCHES ON) + target_compile_options(${target_name} PRIVATE -fsanitize=undefined) + target_link_options(${target_name} PRIVATE -fsanitize=undefined) + endif () + + if (${ENABLE_TSAN} MATCHES ON) + target_compile_options(${target_name} PRIVATE -fsanitize=thread) + target_link_options(${target_name} PRIVATE -fsanitize=thread) + endif () +endmacro() + +macro(compile_options target_name) + if (NOT ${MOLD} STREQUAL MOLD-NOTFOUND) + target_compile_options(${target_name} PUBLIC -fuse-ld=mold) + endif () + + target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic -Wno-comment) + target_link_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic -Wno-comment) + sanitizers(${target_name}) +endmacro() + +macro(blt_add_project name source type) + + project(${name}-${type}) + + add_executable(${name}-${type} ${source}) + + target_link_libraries(${name}-${type} PRIVATE BLT blt-gp Threads::Threads) + + compile_options(${name}-${type}) + target_compile_definitions(${name}-${type} PRIVATE BLT_DEBUG_LEVEL=${DEBUG_LEVEL}) + + if (${TRACK_ALLOCATIONS}) + target_compile_definitions(${name}-${type} PRIVATE BLT_TRACK_ALLOCATIONS=1) + endif () + + add_test(NAME ${name} COMMAND ${name}-${type}) + + set_property(TEST ${name} PROPERTY FAIL_REGULAR_EXPRESSION "FAIL;ERROR;FATAL;exception") + + project(schedulizer) +endmacro() + +project(schedulizer VERSION 0.0.1) + +option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) +option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) +option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) +option(BUILD_SCHEDULIZER_EXAMPLES "Build example programs. This will build with CTest" OFF) +option(BUILD_SCHEDULIZER_TESTS "Build test programs. This will build with CTest" OFF) + +set(CMAKE_CXX_STANDARD 17) + +add_subdirectory(lib/blt-with-graphics) + +include_directories(include/) +file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") + +add_executable(schedulizer ${PROJECT_BUILD_FILES}) + +compile_options(schedulizer) + +target_link_libraries(schedulizer PRIVATE BLT_WITH_GRAPHICS) + +if (${BUILD_SCHEDULIZER_EXAMPLES}) + +endif() + +if (BUILD_SCHEDULIZER_TESTS) + +endif() diff --git a/lib/blt-with-graphics b/lib/blt-with-graphics new file mode 160000 index 0000000..1808af6 --- /dev/null +++ b/lib/blt-with-graphics @@ -0,0 +1 @@ +Subproject commit 1808af68b55e6bbcbc8ce82dcccbe12c21a7b38a diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..9bcc342 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,111 @@ +#include +#include +#include +#include + +constexpr blt::i32 SHIFTS_PER_WEEK = 5; +constexpr blt::i32 POPULATION_SIZE = 100; + +enum class shift_t : blt::u8 +{ + NONE, AMs, PMs +}; + +enum class weekday_t : blt::u8 +{ + SATURDAY, + SUNDAY, + MONDAY, + TUESDAY, + WEDNESDAY, + THURSDAY, + FRIDAY +}; + +bool days_require_pair(const weekday_t day) +{ + switch (day) + { + case weekday_t::SATURDAY: + case weekday_t::SUNDAY: + return true; + case weekday_t::MONDAY: + case weekday_t::TUESDAY: + case weekday_t::WEDNESDAY: + case weekday_t::THURSDAY: + case weekday_t::FRIDAY: + return false; + } + BLT_UNREACHABLE; +} + +struct placement_t +{ + shift_t shift; + bool invariant; + + explicit placement_t(const shift_t shift, const bool invariant = false) : shift{shift}, invariant{invariant} + {} +}; + +struct day_t +{ + placement_t brett{shift_t::PMs, true}; + placement_t kayda; + placement_t tim; + placement_t braeden; + + weekday_t day; + + [[nodiscard]] bool days_require_pair() const + { + return ::days_require_pair(day); + } + + day_t(const placement_t& kayda, const placement_t& tim, const placement_t& braeden, const weekday_t day) : kayda{kayda}, + tim{tim}, + braeden{braeden}, + day{day} + {} +}; + +struct week_t +{ + day_t days[7]; + + explicit week_t(const day_t days[7]): days{} + { + std::memcpy(this->days, days, sizeof(day_t) * 7); + } +}; + +class shift_solver_t +{ +public: + static placement_t + + static day_t generate_random_day(const weekday_t day) + { + auto& random = get_random(); + std::array placements{}; + if (days_require_pair(day)) + { + + } else + { + + } + } + + static blt::random::random_t& get_random() + { + thread_local blt::random::random_t random{691}; + return random; + } +private: +}; + +int main() +{ + std::cout << "Hello World!" << std::endl; +}