-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added connect-four and switched to CMake.js
chore: switch `node-gyp` with `cmake.js`
- Loading branch information
Showing
12 changed files
with
964 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | ||
cmake_policy(SET CMP0042 NEW) | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
project (skyra-ai | ||
VERSION 1.1.0 | ||
DESCRIPTION "Advanced Gaming AI for Skyra" | ||
HOMEPAGE_URL "https://github.com/skyra-project/ai" | ||
LANGUAGES CXX) | ||
|
||
include_directories(${CMAKE_JS_INC}) | ||
add_definitions(-DNAPI_VERSION=3) | ||
add_definitions(-DNAPI_DISABLE_CPP_EXCEPTIONS) | ||
|
||
set(SOURCE_FILES | ||
src/main.cc | ||
src/games/TicTacToe.cc | ||
src/games/ConnectFour.cc) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") | ||
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) | ||
|
||
# Include N-API wrappers | ||
execute_process(COMMAND node -p "require('node-addon-api').include" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE NODE_ADDON_API_DIR | ||
) | ||
|
||
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR}) | ||
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR}) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PUBLIC | ||
${CMAKE_SOURCE_DIR}/include | ||
${NODE_ADDON_API_DIR} | ||
${CMAKE_JS_INC} | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <array> | ||
#include "utils/Players.hpp" | ||
|
||
namespace connect_four | ||
{ | ||
constexpr uint_fast8_t board_width = 7; | ||
constexpr uint_fast8_t board_height = 6; | ||
constexpr uint_fast8_t board_cells = board_width * board_height; | ||
|
||
typedef std::array<Players, board_cells> ai_cells; | ||
typedef std::array<uint_fast8_t, board_width> ai_remaining; | ||
|
||
struct ai_board { | ||
ai_cells cells; | ||
ai_remaining remaining; | ||
}; | ||
|
||
int_fast8_t position(ai_board &board, int_fast8_t remaining, int_fast8_t maximum_depth) noexcept; | ||
} // namespace connect_four |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.