Commit be5a54439053ec8d258dbbec7ffa3463f7ef42b2

Authored by Hakeem
0 parents

My commit

.clang-format 0 → 100644
  1 +++ a/.clang-format
  1 +---
  2 +Language: Cpp
  3 +# BasedOnStyle: LLVM
  4 +AccessModifierOffset: -2
  5 +AlignAfterOpenBracket: Align
  6 +AlignConsecutiveAssignments: true
  7 +AlignConsecutiveDeclarations: true
  8 +AlignEscapedNewlinesLeft: false
  9 +AlignOperands: true
  10 +AlignTrailingComments: true
  11 +AllowAllParametersOfDeclarationOnNextLine: true
  12 +AllowShortBlocksOnASingleLine: false
  13 +AllowShortCaseLabelsOnASingleLine: false
  14 +AllowShortFunctionsOnASingleLine: All
  15 +AllowShortIfStatementsOnASingleLine: true
  16 +AllowShortLoopsOnASingleLine: true
  17 +AlwaysBreakAfterDefinitionReturnType: None
  18 +AlwaysBreakAfterReturnType: None
  19 +AlwaysBreakBeforeMultilineStrings: false
  20 +AlwaysBreakTemplateDeclarations: true
  21 +BinPackArguments: true
  22 +BinPackParameters: true
  23 +BraceWrapping:
  24 + AfterClass: false
  25 + AfterControlStatement: false
  26 + AfterEnum: false
  27 + AfterFunction: true
  28 + AfterNamespace: true
  29 + AfterObjCDeclaration: false
  30 + AfterStruct: false
  31 + AfterUnion: false
  32 + BeforeCatch: true
  33 + BeforeElse: true
  34 + IndentBraces: false
  35 +BreakBeforeBinaryOperators: All
  36 +BreakBeforeBraces: Custom
  37 +BreakBeforeTernaryOperators: true
  38 +BreakConstructorInitializersBeforeComma: false
  39 +ColumnLimit: 80
  40 +#CommentPragmas: '^ IWYU pragma:'
  41 +ConstructorInitializerAllOnOneLineOrOnePerLine: false
  42 +ConstructorInitializerIndentWidth: 2
  43 +ContinuationIndentWidth: 2
  44 +Cpp11BracedListStyle: true
  45 +DerivePointerAlignment: false
  46 +DisableFormat: false
  47 +ExperimentalAutoDetectBinPacking: false
  48 +FixNamespaceComments: true
  49 +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
  50 +#IncludeCategories:
  51 +# - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
  52 +# Priority: 2
  53 +# - Regex: '^(<|"(gtest|isl|json)/)'
  54 +# Priority: 3
  55 +# - Regex: '.*'
  56 +# Priority: 1
  57 +IndentCaseLabels: true
  58 +IndentWidth: 2
  59 +IndentWrappedFunctionNames: false
  60 +KeepEmptyLinesAtTheStartOfBlocks: true
  61 +MacroBlockBegin: ''
  62 +MacroBlockEnd: ''
  63 +MaxEmptyLinesToKeep: 10
  64 +NamespaceIndentation: All
  65 +ObjCBlockIndentWidth: 2
  66 +ObjCSpaceAfterProperty: false
  67 +ObjCSpaceBeforeProtocolList: true
  68 +PenaltyBreakBeforeFirstCallParameter: 19
  69 +PenaltyBreakComment: 300
  70 +PenaltyBreakFirstLessLess: 120
  71 +PenaltyBreakString: 1000
  72 +PenaltyExcessCharacter: 1000000
  73 +PenaltyReturnTypeOnItsOwnLine: 60
  74 +PointerAlignment: Left
  75 +ReflowComments: true
  76 +SortIncludes: false
  77 +SpaceAfterCStyleCast: false
  78 +SpaceBeforeAssignmentOperators: true
  79 +SpaceBeforeParens: ControlStatements
  80 +SpaceInEmptyParentheses: false
  81 +SpacesBeforeTrailingComments: 3
  82 +SpacesInAngles: false
  83 +SpacesInContainerLiterals: true
  84 +SpacesInCStyleCastParentheses: false
  85 +SpacesInParentheses: false
  86 +SpacesInSquareBrackets: false
  87 +Standard: Auto
  88 +TabWidth: 2
  89 +UseTab: Never
  90 +...
  91 +
... ...
CMakeLists.txt 0 → 100644
  1 +++ a/CMakeLists.txt
  1 +# Minimum CMake version required
  2 +cmake_minimum_required(VERSION 3.8)
  3 +
  4 +# Global name of the project
  5 +project(othello_game_engine VERSION 0.1 LANGUAGES CXX)
  6 +
  7 +
  8 +# headers and source files
  9 +set( HDRS
  10 + orangemonkey_ai.h
  11 + engine.h
  12 + utility.h
  13 + )
  14 +
  15 +set( SRCS
  16 + orangemonkey_ai.cpp
  17 + engine.cpp
  18 + utility.cpp
  19 + )
  20 +
  21 +add_library( ${PROJECT_NAME} STATIC
  22 + ${HDRS} ${SRCS} )
  23 +
  24 +
  25 +###################
  26 +# Compiler features
  27 +
  28 +# TURN ON C++17 FEATURES
  29 +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17 )
  30 +
  31 +# Compiler spesific options
  32 +target_compile_options(${PROJECT_NAME}
  33 + PUBLIC $<$<CXX_COMPILER_ID:Clang>:
  34 + # Mandatory compiler flags
  35 + -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic
  36 + -pedantic -Werror
  37 +
  38 + # Disable clangs overtidyness for documentation
  39 + -Wno-documentation
  40 +
  41 + # Deal with Qt - which is not 100% clangified ><
  42 + -Wno-padded
  43 + -Wno-redundant-parens
  44 +
  45 + # Stuff we want to deal with later
  46 + -Wno-weak-vtables
  47 + >
  48 + PUBLIC $<$<CXX_COMPILER_ID:GNU>:
  49 + # Mandatory compiler flags
  50 + -pedantic -Wall -Werror
  51 + >
  52 + )
  53 +
  54 +
  55 +
  56 +
  57 +##############################
  58 +# Configure othello interfaces
  59 +find_package(othello_interfaces REQUIRED CONFIG NO_DEFAULT_PATH)
  60 +if(othello_interfaces_FOUND)
  61 +
  62 + # gmlib2 interface_link_libraries
  63 + get_target_property(othello_interfaces_include_directories othello::othello_interfaces INTERFACE_INCLUDE_DIRECTORIES)
  64 + target_include_directories(${PROJECT_NAME} PUBLIC ${othello_interfaces_include_directories})
  65 +
  66 +# get_target_property(othello_interfaces_link_libraries othello::othello_interfaces INTERFACE_LINK_LIBRARIES)
  67 +# target_link_libraries(${PROJECT_NAME} PUBLIC ${othello_interfaces_link_libraries})
  68 +
  69 +else()
  70 + message(FATAL_ERROR "Missing Othello Interfaces")
  71 +endif()
  72 +
  73 +
  74 +
  75 +
  76 +
  77 +
  78 +
  79 +
  80 +
  81 +
  82 +
  83 +##################################
  84 +# Export targets and configuration
  85 +
  86 +target_include_directories( ${PROJECT_NAME} PUBLIC
  87 + $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>
  88 +)
  89 +
  90 +
  91 +export(TARGETS ${PROJECT_NAME}
  92 + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}-targets.cmake"
  93 + NAMESPACE othello::
  94 + )
  95 +
  96 +include(CMakePackageConfigHelpers)
  97 +write_basic_package_version_file(
  98 + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
  99 + COMPATIBILITY SameMajorVersion
  100 +)
  101 +configure_package_config_file(
  102 + "cmake/${PROJECT_NAME}-config.cmake.in"
  103 + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
  104 + INSTALL_DESTINATION "lib/cmake/gmlib2qt"
  105 + )
... ...
CMakeLists.txt.user 0 → 100644
  1 +++ a/CMakeLists.txt.user
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE QtCreatorProject>
  3 +<!-- Written by QtCreator 4.7.0, 2018-09-19T08:36:15. -->
  4 +<qtcreator>
  5 + <data>
  6 + <variable>EnvironmentId</variable>
  7 + <value type="QByteArray">{bb76aeff-9571-4144-9f49-011ee88054ea}</value>
  8 + </data>
  9 + <data>
  10 + <variable>ProjectExplorer.Project.ActiveTarget</variable>
  11 + <value type="int">0</value>
  12 + </data>
  13 + <data>
  14 + <variable>ProjectExplorer.Project.EditorSettings</variable>
  15 + <valuemap type="QVariantMap">
  16 + <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
  17 + <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
  18 + <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
  19 + <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
  20 + <value type="QString" key="language">Cpp</value>
  21 + <valuemap type="QVariantMap" key="value">
  22 + <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
  23 + </valuemap>
  24 + </valuemap>
  25 + <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
  26 + <value type="QString" key="language">QmlJS</value>
  27 + <valuemap type="QVariantMap" key="value">
  28 + <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
  29 + </valuemap>
  30 + </valuemap>
  31 + <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
  32 + <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
  33 + <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
  34 + <value type="int" key="EditorConfiguration.IndentSize">4</value>
  35 + <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
  36 + <value type="int" key="EditorConfiguration.MarginColumn">80</value>
  37 + <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
  38 + <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
  39 + <value type="int" key="EditorConfiguration.PaddingMode">1</value>
  40 + <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
  41 + <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
  42 + <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
  43 + <value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
  44 + <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
  45 + <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
  46 + <value type="int" key="EditorConfiguration.TabSize">8</value>
  47 + <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
  48 + <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
  49 + <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
  50 + <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
  51 + <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
  52 + <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
  53 + </valuemap>
  54 + </data>
  55 + <data>
  56 + <variable>ProjectExplorer.Project.PluginSettings</variable>
  57 + <valuemap type="QVariantMap">
  58 + <valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
  59 + <value type="QString">-fno-delayed-template-parsing</value>
  60 + </valuelist>
  61 + <value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
  62 + </valuemap>
  63 + </data>
  64 + <data>
  65 + <variable>ProjectExplorer.Project.Target.0</variable>
  66 + <valuemap type="QVariantMap">
  67 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.11.2 MSVC2017 64bit</value>
  68 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.11.2 MSVC2017 64bit</value>
  69 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5112.win64_msvc2017_64_kit</value>
  70 + <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
  71 + <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
  72 + <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
  73 + <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
  74 + <valuelist type="QVariantList" key="CMake.Configuration">
  75 + <value type="QString">CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}</value>
  76 + <value type="QString">CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}</value>
  77 + <value type="QString">CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}</value>
  78 + <value type="QString">QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}</value>
  79 + <value type="QString">othello_interfaces_DIR:PATH=D:/slimk/Documents/STE6274_2018/BUILDINTERFACE/cmake</value>
  80 + </valuelist>
  81 + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/slimk/Documents/STE6274_2018/BUILDENGINE</value>
  82 + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
  83 + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
  84 + <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
  85 + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
  86 + <value type="QString">all</value>
  87 + </valuelist>
  88 + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
  89 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">CMake Build</value>
  90 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  91 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
  92 + </valuemap>
  93 + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
  94 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
  95 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  96 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
  97 + </valuemap>
  98 + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
  99 + <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
  100 + <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
  101 + <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets">
  102 + <value type="QString">all</value>
  103 + </valuelist>
  104 + <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
  105 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">CMake Build</value>
  106 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  107 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
  108 + </valuemap>
  109 + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
  110 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
  111 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  112 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
  113 + </valuemap>
  114 + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
  115 + <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
  116 + <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
  117 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Default</value>
  118 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Default</value>
  119 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
  120 + </valuemap>
  121 + <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
  122 + <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
  123 + <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
  124 + <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
  125 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
  126 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  127 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
  128 + </valuemap>
  129 + <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
  130 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value>
  131 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  132 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
  133 + </valuemap>
  134 + <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
  135 + <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
  136 + <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
  137 + <value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
  138 + <value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
  139 + <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
  140 + <value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
  141 + <value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
  142 + <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
  143 + <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
  144 + <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
  145 + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
  146 + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
  147 + <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
  148 + <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
  149 + <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
  150 + <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
  151 + <value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
  152 + <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
  153 + <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
  154 + <value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
  155 + <value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
  156 + <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
  157 + <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
  158 + <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
  159 + <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
  160 + <value type="int">0</value>
  161 + <value type="int">1</value>
  162 + <value type="int">2</value>
  163 + <value type="int">3</value>
  164 + <value type="int">4</value>
  165 + <value type="int">5</value>
  166 + <value type="int">6</value>
  167 + <value type="int">7</value>
  168 + <value type="int">8</value>
  169 + <value type="int">9</value>
  170 + <value type="int">10</value>
  171 + <value type="int">11</value>
  172 + <value type="int">12</value>
  173 + <value type="int">13</value>
  174 + <value type="int">14</value>
  175 + </valuelist>
  176 + <value type="int" key="PE.EnvironmentAspect.Base">2</value>
  177 + <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
  178 + <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
  179 + <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
  180 + <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"></value>
  181 + <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory.default"></value>
  182 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
  183 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
  184 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
  185 + <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
  186 + <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
  187 + <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
  188 + <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
  189 + <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
  190 + <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
  191 + </valuemap>
  192 + <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
  193 + </valuemap>
  194 + </data>
  195 + <data>
  196 + <variable>ProjectExplorer.Project.TargetCount</variable>
  197 + <value type="int">1</value>
  198 + </data>
  199 + <data>
  200 + <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
  201 + <value type="int">18</value>
  202 + </data>
  203 + <data>
  204 + <variable>Version</variable>
  205 + <value type="int">18</value>
  206 + </data>
  207 +</qtcreator>
... ...
README.md 0 → 100644
  1 +++ a/README.md
... ...
cmake/othello_game_engine-config.cmake.in 0 → 100644
  1 +++ a/cmake/othello_game_engine-config.cmake.in
  1 +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
  2 +message(STATUS "Found @PROJECT_NAME@")
... ...
engine.cpp 0 → 100644
  1 +++ a/engine.cpp
  1 +#include "engine.h"
  2 +
  3 +namespace othello
  4 +{
  5 +
  6 + bool OthelloGameEngine::initNewGame()
  7 + {
  8 + clearGame();
  9 +
  10 + m_board[0].set(36);
  11 + m_board[0].set(27);
  12 + m_board[1].set(35);
  13 + m_board[1].set(28);
  14 +
  15 + m_playerid = PlayerId::One;
  16 +
  17 + return true;
  18 + }
  19 +
  20 + void OthelloGameEngine::clearGame() {
  21 + //removes all pieces from the board
  22 + m_board[0].reset();
  23 + m_board[1].reset();
  24 + }
  25 +
  26 + bool OthelloGameEngine::performMoveForCurrentHuman(const BitPos& board_pos)
  27 + {
  28 + if (utility::isLegalMove(m_board, m_playerid, board_pos)){
  29 + utility::placeAndFlip(m_board, m_playerid, board_pos);
  30 + switchCurrentPlayerId();
  31 + return true;
  32 + }
  33 + return false;
  34 +
  35 + }
  36 +
  37 + void OthelloGameEngine::think(const std::chrono::seconds& /*time_limit*/)
  38 + {
  39 +
  40 + }
  41 +
  42 + void OthelloGameEngine::switchCurrentPlayerId()
  43 + {
  44 + if (m_playerid == PlayerId::One){
  45 + m_playerid = PlayerId::Two;
  46 + }
  47 + else m_playerid = PlayerId::One;
  48 + }
  49 +
  50 + PlayerId OthelloGameEngine::currentPlayerId() const
  51 + {
  52 +
  53 + return m_playerid;
  54 + }
  55 +
  56 + PlayerType OthelloGameEngine::currentPlayerType() const
  57 + {
  58 + //for use after implementing AI
  59 + return {};
  60 + }
  61 +
  62 + BitPieces OthelloGameEngine::pieces(const PlayerId& player_id) const
  63 + {
  64 + return m_board[static_cast<size_t>(player_id)];
  65 + }
  66 +
  67 + const BitBoard& OthelloGameEngine::board() const {return m_board;}
  68 +
  69 +
  70 +} // namespace othello
... ...
engine.h 0 → 100644
  1 +++ a/engine.h
  1 +#ifndef ENGINE_H
  2 +#define ENGINE_H
  3 +
  4 +
  5 +
  6 +#include "utility.h"
  7 +
  8 +#include <basic_types.h>
  9 +#include <engine_interface.h>
  10 +
  11 +
  12 +namespace othello
  13 +{
  14 +/*
  15 + class OpeningBook {
  16 + // ...
  17 + };
  18 +
  19 + class GreenBookWormAI : public AIInterface {
  20 + public:
  21 + GreenBookWormAI( const OpeningBook& openingbook )
  22 + : m_openingbook{openingbook} {}
  23 + // ...
  24 + private:
  25 + const OpeningBook m_openingbook;
  26 + };
  27 +*/
  28 +
  29 + class OthelloGameEngine : public othello::GameEngineInterface {
  30 + // GameEngineInterface interface
  31 +
  32 + PlayerId m_playerid = PlayerId::One;
  33 +
  34 + public:
  35 + bool initNewGame() override;
  36 + void clearGame() override;
  37 + bool performMoveForCurrentHuman(const othello::BitPos&) override;
  38 + bool legalMovesCheck();
  39 + void switchCurrentPlayerId();
  40 +
  41 + void think(const std::chrono::seconds&) override;
  42 + othello::PlayerId currentPlayerId() const override;
  43 + othello::PlayerType currentPlayerType() const override;
  44 + othello::BitPieces pieces(const othello::PlayerId&) const override;
  45 +
  46 + const othello::BitBoard& board() const override;
  47 +
  48 +// const OpeningBook m_openingbook;
  49 +
  50 + };
  51 +
  52 +} // namespace othello
  53 +#endif // ENGINE_H
... ...
engine_og.cpp 0 → 100644
  1 +++ a/engine_og.cpp
  1 +#include "engine.h"
  2 +
  3 +namespace othello
  4 +{
  5 +
  6 +bool OthelloGameEngine::initNewGame()
  7 +{
  8 + return true;
  9 +}
  10 +
  11 +void OthelloGameEngine::clearGame() {
  12 +}
  13 +
  14 +bool OthelloGameEngine::performMoveForCurrentHuman(const BitPos& /*board_pos*/)
  15 +{
  16 + return true;
  17 +}
  18 +
  19 +void OthelloGameEngine::think(const std::chrono::seconds& /*time_limit*/)
  20 +{
  21 +}
  22 +
  23 +PlayerId OthelloGameEngine::currentPlayerId() const
  24 +{
  25 + return {};
  26 +}
  27 +
  28 +PlayerType OthelloGameEngine::currentPlayerType() const
  29 +{
  30 + return {};
  31 +}
  32 +
  33 +BitPieces OthelloGameEngine::pieces(const PlayerId& /*player_id*/) const
  34 +{
  35 + return {};
  36 +}
  37 +
  38 +const BitBoard& OthelloGameEngine::board() const { static BitBoard bb; return bb; }
  39 +
  40 +
  41 +} // namespace othello
... ...
orangemonkey_ai.cpp 0 → 100644
  1 +++ a/orangemonkey_ai.cpp
  1 +#include "orangemonkey_ai.h"
  2 +
  3 +#include <utility.h>
  4 +
  5 +
  6 +// stl
  7 +#include <iostream>
  8 +
  9 +namespace othello::monkey_ais
  10 +{
  11 +
  12 +
  13 + OrangeMonkeyAI::OrangeMonkeyAI(const PlayerId&) {
  14 + m_engine.seed(m_rd());
  15 + }
  16 +
  17 + void OrangeMonkeyAI::think(const othello::BitBoard& board,
  18 + const othello::PlayerId& player_id,
  19 + const std::chrono::seconds& /*max_time*/)
  20 + {
  21 + std::cout << "orange monkey thinking!!" << std::endl;
  22 + const auto legal_moves = utility::legalMoves(board, player_id);
  23 +
  24 + std::uniform_int_distribution<size_t> dist(0, legal_moves.size()-1);
  25 +
  26 + auto b_iter = std::begin(legal_moves);
  27 + std::advance(b_iter, dist(m_engine));
  28 +
  29 + m_best_move = *b_iter;
  30 + }
  31 +
  32 + BitPos OrangeMonkeyAI::bestMove() const {
  33 +
  34 + const auto best_move = BitPos(m_best_move.value());
  35 + m_best_move = BitPos::invalid();
  36 + return best_move;
  37 + }
  38 +
  39 +} // namespace othello::monkey_ais
... ...
orangemonkey_ai.h 0 → 100644
  1 +++ a/orangemonkey_ai.h
  1 +#ifndef ORANGEMONKEY_H
  2 +#define ORANGEMONKEY_H
  3 +
  4 +#include <player_interface.h>
  5 +
  6 +#include <random>
  7 +
  8 +
  9 +namespace othello::monkey_ais
  10 +{
  11 +
  12 + class OrangeMonkeyAI : public AIInterface {
  13 +
  14 + // Constructors
  15 + public:
  16 + OrangeMonkeyAI(const PlayerId& player_id);
  17 +
  18 + // PlayerInterface interface
  19 + public:
  20 + void think(const BitBoard& board, const PlayerId& player_id,
  21 + const std::chrono::seconds& max_time);
  22 + BitPos bestMove() const;
  23 +
  24 +
  25 + private:
  26 + mutable BitPos m_best_move;
  27 + std::random_device m_rd;
  28 + std::mt19937 m_engine;
  29 + };
  30 +
  31 +} // namespace othello::monkey_ais
  32 +#endif // ORANGEMONKEY_H
... ...
utility.cpp 0 → 100644
  1 +++ a/utility.cpp
  1 +#include "utility.h"
  2 +
  3 +// stl
  4 +#include "numeric"
  5 +#include "iostream"
  6 +
  7 +namespace othello { namespace utility
  8 +{
  9 + ////////////////////
  10 + //
  11 + //
  12 + // Interface Utility
  13 + // Functions
  14 + //
  15 + //
  16 + ////////////////////
  17 +
  18 + BitPieces occupiedPositions(const BitBoard& board)
  19 + {
  20 + return othello::BitPieces(board[0] | board[1]);
  21 + }
  22 +
  23 + bool occupied(const BitPieces& pieces, const BitPos& board_pos)
  24 + {
  25 + return pieces.test(board_pos.value()); //.test checks without giving it access to modify
  26 + }
  27 +
  28 + bool occupied(const BitBoard& board, const BitPos& board_pos)
  29 + {
  30 + //return occupiedPositions(board).test(board_pos.value());
  31 +
  32 + const auto isOccupied = occupiedPositions(board);
  33 + return occupied(isOccupied, board_pos);
  34 + }
  35 +
  36 + BitPos nextPosition(const BitPos& board_pos, const MoveDirection& dir)
  37 + {
  38 + switch(dir) {
  39 + case othello::MoveDirection::N:
  40 + if(board_pos.value() < 56)
  41 + return othello::BitPos(board_pos.value() + 8);
  42 + break;
  43 + case othello::MoveDirection::NE:
  44 + if((board_pos.value() < 56) and (board_pos.value() % 8 != 0))
  45 + return othello::BitPos(board_pos.value() + 7);
  46 + break;
  47 + case othello::MoveDirection::E:
  48 + if(board_pos.value() % 8 != 0)
  49 + return othello::BitPos(board_pos.value() - 1);
  50 + break;
  51 + case othello::MoveDirection::SE:
  52 + if((board_pos.value() > 7) and (board_pos.value() % 8 != 7))
  53 + return othello::BitPos(board_pos.value() - 9);
  54 + break;
  55 + case othello::MoveDirection::S:
  56 + if(board_pos.value() > 7)
  57 + return othello::BitPos(board_pos.value() - 8);
  58 + break;
  59 + case othello::MoveDirection::SW:
  60 + if((board_pos.value() > 7) and (board_pos.value() % 8 != 7))
  61 + return othello::BitPos(board_pos.value() - 7);
  62 + break;
  63 + case othello::MoveDirection::W:
  64 + if(board_pos.value() % 8 != 7)
  65 + return othello::BitPos(board_pos.value() + 1);
  66 + break;
  67 + case othello::MoveDirection::NW:
  68 + if((board_pos.value() < 56) and (board_pos.value() % 8 != 7))
  69 + return othello::BitPos(board_pos.value() + 9);
  70 + break;
  71 + }
  72 + return BitPos::invalid();
  73 + }
  74 +
  75 + BitPosSet findBorder(const BitBoard &board)
  76 + {
  77 + BitPieces occupied_positions = occupiedPositions(board);
  78 + BitPosSet border_pieces;
  79 + for (size_t i = 0; i < detail::computeBoardSize(); ++i){
  80 + if (occupied_positions.test(i)){
  81 + for (int j=0; j < 8; ++j){
  82 + BitPos neighbor = nextPosition(BitPos {i}, static_cast <MoveDirection>(j));
  83 + if (neighbor.isValid() && !occupied(board, neighbor)){
  84 + border_pieces.insert(neighbor);
  85 + }
  86 + }
  87 + }
  88 + }
  89 + return border_pieces; //not as efficient as it goes through the whole board for every move instead of simply updating
  90 + }
  91 +
  92 + BitPos findBracketingPiece(const BitBoard& board,
  93 + const BitPos& board_pos,
  94 + const PlayerId& player_id,
  95 + const MoveDirection& dir)
  96 + {
  97 + BitPos next_position = nextPosition(board_pos, dir);
  98 +
  99 + const BitPieces& current_player_pieces = board.at(size_t(player_id));
  100 + const BitPieces& opponent_player_pieces = board.at(size_t(opponent(player_id)));
  101 +
  102 + if (not next_position.isValid() or not opponent_player_pieces.test(next_position.value())){
  103 + return BitPos::invalid();
  104 + }
  105 + next_position = nextPosition(board_pos, dir);
  106 +
  107 + while (next_position.isValid()){
  108 + if (current_player_pieces.test(next_position.value()))
  109 + return next_position;
  110 + if (not opponent_player_pieces.test(next_position.value()))
  111 + return BitPos::invalid(); // Must be an empty position
  112 +
  113 + next_position = nextPosition(board_pos, dir);
  114 +
  115 + }
  116 +
  117 + return BitPos::invalid();
  118 + }
  119 +
  120 + BitPosSet legalMoves(const BitBoard& board, const PlayerId& player_id)
  121 + {
  122 + BitPosSet legal_moves;
  123 + for (size_t i = 0; i < detail::computeBoardSize(); ++i){
  124 + if(isLegalMove(board, player_id, BitPos(i))){
  125 + legal_moves.insert(BitPos(i));
  126 + }
  127 + }
  128 + }
  129 +
  130 + bool isLegalMove(const BitBoard& board, const PlayerId& player_id,
  131 + const BitPos& board_pos)
  132 + {
  133 + for (size_t i = 0; i < 8; ++i){
  134 + auto dir = static_cast<MoveDirection>(i);
  135 + BitPos bracketing_pieces = findBracketingPiece(board, board_pos, player_id, dir);
  136 + if (bracketing_pieces.isValid())
  137 + return true;
  138 + }
  139 + return false;
  140 + }
  141 +
  142 +
  143 + void placeAndFlip(BitBoard& board, const PlayerId& player_id,
  144 + const BitPos& board_pos)
  145 + {
  146 + if(isLegalMove(board, player_id, board_pos)){
  147 + board.at(size_t(player_id)).set(board_pos.value());
  148 + for (size_t i = 0; i < 8; ++i){
  149 + auto dir = static_cast<MoveDirection>(i);
  150 + BitPos captured_piece = nextPosition(board_pos, dir);
  151 + board.at(size_t(opponent(player_id))).flip(captured_piece.value());
  152 + captured_piece = nextPosition(captured_piece, dir);
  153 + }
  154 + }
  155 + }
  156 +
  157 + PlayerId opponent(const PlayerId& player_id){
  158 + if (player_id == PlayerId::One){
  159 + return PlayerId::Two;
  160 + }
  161 + return PlayerId::One;
  162 + }
  163 +}
  164 +} // namespace othello::utility
... ...
utility.h 0 → 100644
  1 +++ a/utility.h
  1 +#ifndef UTILITY_H
  2 +#define UTILITY_H
  3 +
  4 +#include <utility_interface.h>
  5 +
  6 +namespace othello::utility
  7 +{
  8 +
  9 + BitPosSet findBorder(const BitBoard& board);
  10 + PlayerId opponent(const PlayerId& player_id);
  11 +
  12 +} // namespace othello::utility
  13 +
  14 +#endif // UTILITY_H
... ...
utility_og.cpp 0 → 100644
  1 +++ a/utility_og.cpp
  1 +#include "utility.h"
  2 +
  3 +// stl
  4 +#include "numeric"
  5 +#include "iostream"
  6 +
  7 +namespace othello::utility
  8 +{
  9 + ////////////////////
  10 + //
  11 + //
  12 + // Interface Utility
  13 + // Functions
  14 + //
  15 + //
  16 + ////////////////////
  17 +
  18 + BitPieces occupiedPositions(const BitBoard& /*board*/)
  19 + {
  20 + return {};
  21 + }
  22 +
  23 + bool occupied(const BitPieces& /*pieces*/, const BitPos& /*board_pos*/)
  24 + {
  25 + return true;
  26 + }
  27 +
  28 + bool occupied(const BitBoard& /*board*/, const BitPos& /*board_pos*/)
  29 + {
  30 + return false;
  31 + }
  32 +
  33 + BitPos nextPosition(const BitPos& /*board_pos*/, const MoveDirection& /*dir*/)
  34 + {
  35 + return {};
  36 + }
  37 +
  38 + BitPos findBracketingPiece(const BitBoard& /*board*/,
  39 + const BitPos& /*board_pos*/,
  40 + const PlayerId& /*player_id*/,
  41 + const MoveDirection& /*dir*/)
  42 + {
  43 + return {};
  44 + }
  45 +
  46 + BitPosSet legalMoves(const BitBoard& /*board*/, const PlayerId& /*player_id*/)
  47 + {
  48 + return {};
  49 + }
  50 +
  51 + bool isLegalMove(const BitBoard& /*board*/, const PlayerId& /*player_id*/,
  52 + const BitPos& /*board_pos*/)
  53 + {
  54 +
  55 + return false;
  56 + }
  57 +
  58 +
  59 + void placeAndFlip(BitBoard& /*board*/, const PlayerId& /*player_id*/,
  60 + const BitPos& /*board_pos*/)
  61 + {
  62 + }
  63 +
  64 +} // namespace othello::utility
... ...