diff options
33 files changed, 638 insertions, 431 deletions
diff --git a/CMakeFiles/Makefile2 b/CMakeFiles/Makefile2 index 8c45535..123b2dd 100644 --- a/CMakeFiles/Makefile2 +++ b/CMakeFiles/Makefile2 @@ -92,12 +92,12 @@ clean: CMakeFiles/sdl_test.dir/clean CMakeFiles/sdl_test.dir/all: $(MAKE) $(MAKESILENT) -f CMakeFiles\sdl_test.dir\build.make CMakeFiles/sdl_test.dir/depend $(MAKE) $(MAKESILENT) -f CMakeFiles\sdl_test.dir\build.make CMakeFiles/sdl_test.dir/build - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles --progress-num=1,2,3,4,5,6,7,8,9,10,11,12,13,14 "Built target sdl_test" + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir=C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles --progress-num=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 "Built target sdl_test" .PHONY : CMakeFiles/sdl_test.dir/all # Build rule for subdir invocation for target. CMakeFiles/sdl_test.dir/rule: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles 14 + $(CMAKE_COMMAND) -E cmake_progress_start C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles 15 $(MAKE) $(MAKESILENT) -f CMakeFiles\Makefile2 CMakeFiles/sdl_test.dir/all $(CMAKE_COMMAND) -E cmake_progress_start C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles 0 .PHONY : CMakeFiles/sdl_test.dir/rule diff --git a/CMakeFiles/progress.marks b/CMakeFiles/progress.marks index 8351c19..60d3b2f 100644 --- a/CMakeFiles/progress.marks +++ b/CMakeFiles/progress.marks @@ -1 +1 @@ -14 +15 diff --git a/CMakeFiles/sdl_test.dir/CXX.includecache b/CMakeFiles/sdl_test.dir/CXX.includecache index 72f0a59..44aa3c5 100644 --- a/CMakeFiles/sdl_test.dir/CXX.includecache +++ b/CMakeFiles/sdl_test.dir/CXX.includecache @@ -630,421 +630,143 @@ vector SDL2/SDL.h - -C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h -vector -- +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h string - -iostream +vector - -../umath/vec2.h -C:/Users/jaksk/Desktop/dev/_cpp/age/umath/vec2.h - -C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h -entity.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/engine.h iostream - -algorithm -- string - vector - -functional +limits - -random +cmath - -ground.h +../ground.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h -entity.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h -tile.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/tile.h -player.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/player.h -tech.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/tech.h - -C:/Users/jaksk/Desktop/dev/_cpp/age/game/load.cpp +../gst.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h +action.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h +tactic.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/tactic.h +generator.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/generator.h +evaluator.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/evaluator.h +performer.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/performer.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/evaluator.h iostream - -fstream +string - vector - -load.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/load.h -nlohmann/json.hpp -C:/Users/jaksk/Desktop/dev/_cpp/age/game/nlohmann/json.hpp - -C:/Users/jaksk/Desktop/dev/_cpp/age/game/load.h -gst.h +../ground.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h +../gst.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/menu.h -vector -- -string -- -../umath/vec2.h -C:/Users/jaksk/Desktop/dev/_cpp/age/umath/vec2.h -tech.h -C:/Users/jaksk/Desktop/dev/_cpp/age/game/tech.h - -C:/Users/jaksk/Desktop/dev/_cpp/age/game/nlohmann/json.hpp -algorithm -- -cstddef -- -functional -- -initializer_list -- -iosfwd -- -iterator -- -memory -- -numeric +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/generator.h +iostream - string - -utility -- vector - -type_traits -- -utility -- -algorithm -- -array -- -forward_list -- -iterator -- -map -- -string -- -tuple -- -type_traits -- -unordered_map -- -utility -- -valarray -- -exception -- -stdexcept +../ground.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h +../gst.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h +action.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h +tactic.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/tactic.h +performer.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/performer.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/performer.h +iostream - string - vector - -array -- -cstddef -- -cstdint -- -string -- -string -- -utility -- -stdint.h -- -stdint.h -- -cstdlib -- -cassert -- -cstddef -- -cstddef -- -type_traits -- -utility -- -limits -- -type_traits -- -utility -- -tuple -- -iterator -- -type_traits -- -cstdint -- -map -- -memory -- +../ground.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h +../gst.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h +action.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h +tactic.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/tactic.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/tactic.h string - vector - -algorithm -- -iterator -- -string -- -tuple -- -type_traits -- -utility -- -valarray -- +action.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h vector - -cstddef -- -iterator -- string - -tuple -- -utility -- -cstdint -- -tuple -- -utility -- -cstdint -- -cstddef +iostream - -functional +../umath/vec2.h +C:/Users/jaksk/Desktop/dev/_cpp/age/umath/vec2.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h +entity.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h +iostream - algorithm - -array -- -cmath -- -cstddef -- -cstdint -- -cstdio -- -cstring -- -iterator -- -limits -- -string -- -utility -- -vector -- -array -- -cstddef -- -cstring -- -iterator -- -memory -- -numeric -- -string -- -type_traits -- -utility -- -cstdio -- -istream -- -cstddef -- -string -- -utility -- -vector -- -array -- -clocale -- -cstddef -- -cstdio -- -cstdlib -- -initializer_list -- string - -utility -- vector - -cstdint -- -utility -- -string -- -cmath -- -cstdint -- functional - -string -- -utility -- -vector -- -cstddef -- -limits -- -iterator -- -type_traits -- -cstddef -- -iterator -- -utility -- -algorithm -- -cctype -- -limits -- -numeric -- -string -- -utility -- -vector -- -initializer_list -- -utility -- -algorithm -- -array -- -cmath -- -cstdint -- -cstring -- -limits -- -string -- -utility -- -algorithm -- -cstddef -- -iterator -- -memory -- -string +random - +ground.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h +entity.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h +tile.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/tile.h +player.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/player.h +tech.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/tech.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/load.h +gst.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h + +C:/Users/jaksk/Desktop/dev/_cpp/age/game/menu.h vector - -ios -- -ostream -- -algorithm -- -array -- -clocale -- -cmath -- -cstddef -- -cstdint -- -cstdio -- -limits -- string - -type_traits -- -utility -- -array -- -cmath -- -cstdint -- -cstring -- -limits -- -type_traits -- -functional -- -initializer_list -- -iterator -- -memory -- -stdexcept -- -type_traits -- -utility -- -vector -- -string_view -- +../umath/vec2.h +C:/Users/jaksk/Desktop/dev/_cpp/age/umath/vec2.h +tech.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/tech.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/player.h vector @@ -1141,6 +863,10 @@ game/tile.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/tile.h game/load.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/load.h +game/ai/engine.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/engine.h +game/ai/performer.h +C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/performer.h C:/Users/jaksk/Desktop/dev/_cpp/age/timing/timing.h SDL2/SDL.h diff --git a/CMakeFiles/sdl_test.dir/DependInfo.cmake b/CMakeFiles/sdl_test.dir/DependInfo.cmake index 35df139..47792b8 100644 --- a/CMakeFiles/sdl_test.dir/DependInfo.cmake +++ b/CMakeFiles/sdl_test.dir/DependInfo.cmake @@ -5,6 +5,7 @@ set(CMAKE_DEPENDS_LANGUAGES # The set of files for implicit dependencies of each language: set(CMAKE_DEPENDS_CHECK_CXX "C:/Users/jaksk/Desktop/dev/_cpp/age/commands/commands.cpp" "C:/Users/jaksk/Desktop/dev/_cpp/age/CMakeFiles/sdl_test.dir/commands/commands.cpp.obj" + "C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.cpp" "C:/Users/jaksk/Desktop/dev/_cpp/age/CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj" "C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.cpp" "C:/Users/jaksk/Desktop/dev/_cpp/age/CMakeFiles/sdl_test.dir/game/entity.cpp.obj" "C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.cpp" "C:/Users/jaksk/Desktop/dev/_cpp/age/CMakeFiles/sdl_test.dir/game/ground.cpp.obj" "C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.cpp" "C:/Users/jaksk/Desktop/dev/_cpp/age/CMakeFiles/sdl_test.dir/game/gst.cpp.obj" diff --git a/CMakeFiles/sdl_test.dir/build.make b/CMakeFiles/sdl_test.dir/build.make index fae8077..0fee87f 100644 --- a/CMakeFiles/sdl_test.dir/build.make +++ b/CMakeFiles/sdl_test.dir/build.make @@ -257,6 +257,20 @@ CMakeFiles/sdl_test.dir/game/tech.cpp.s: cmake_force @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/sdl_test.dir/game/tech.cpp.s" C:\MinGW64\bin\g++.exe $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S C:\Users\jaksk\Desktop\dev\_cpp\age\game\tech.cpp -o CMakeFiles\sdl_test.dir\game\tech.cpp.s +CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj: CMakeFiles/sdl_test.dir/flags.make +CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj: CMakeFiles/sdl_test.dir/includes_CXX.rsp +CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj: game/ai/action.cpp + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles --progress-num=$(CMAKE_PROGRESS_14) "Building CXX object CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj" + C:\MinGW64\bin\g++.exe $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles\sdl_test.dir\game\ai\action.cpp.obj -c C:\Users\jaksk\Desktop\dev\_cpp\age\game\ai\action.cpp + +CMakeFiles/sdl_test.dir/game/ai/action.cpp.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/sdl_test.dir/game/ai/action.cpp.i" + C:\MinGW64\bin\g++.exe $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E C:\Users\jaksk\Desktop\dev\_cpp\age\game\ai\action.cpp > CMakeFiles\sdl_test.dir\game\ai\action.cpp.i + +CMakeFiles/sdl_test.dir/game/ai/action.cpp.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/sdl_test.dir/game/ai/action.cpp.s" + C:\MinGW64\bin\g++.exe $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S C:\Users\jaksk\Desktop\dev\_cpp\age\game\ai\action.cpp -o CMakeFiles\sdl_test.dir\game\ai\action.cpp.s + # Object files for target sdl_test sdl_test_OBJECTS = \ "CMakeFiles/sdl_test.dir/main.cpp.obj" \ @@ -271,7 +285,8 @@ sdl_test_OBJECTS = \ "CMakeFiles/sdl_test.dir/game/menu.cpp.obj" \ "CMakeFiles/sdl_test.dir/game/tile.cpp.obj" \ "CMakeFiles/sdl_test.dir/game/load.cpp.obj" \ -"CMakeFiles/sdl_test.dir/game/tech.cpp.obj" +"CMakeFiles/sdl_test.dir/game/tech.cpp.obj" \ +"CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj" # External object files for target sdl_test sdl_test_EXTERNAL_OBJECTS = @@ -289,11 +304,12 @@ build/sdl_test.exe: CMakeFiles/sdl_test.dir/game/menu.cpp.obj build/sdl_test.exe: CMakeFiles/sdl_test.dir/game/tile.cpp.obj build/sdl_test.exe: CMakeFiles/sdl_test.dir/game/load.cpp.obj build/sdl_test.exe: CMakeFiles/sdl_test.dir/game/tech.cpp.obj +build/sdl_test.exe: CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj build/sdl_test.exe: CMakeFiles/sdl_test.dir/build.make build/sdl_test.exe: CMakeFiles/sdl_test.dir/linklibs.rsp build/sdl_test.exe: CMakeFiles/sdl_test.dir/objects1.rsp build/sdl_test.exe: CMakeFiles/sdl_test.dir/link.txt - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles --progress-num=$(CMAKE_PROGRESS_14) "Linking CXX executable build\sdl_test.exe" + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=C:\Users\jaksk\Desktop\dev\_cpp\age\CMakeFiles --progress-num=$(CMAKE_PROGRESS_15) "Linking CXX executable build\sdl_test.exe" $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles\sdl_test.dir\link.txt --verbose=$(VERBOSE) # Rule to build all files generated by this target. diff --git a/CMakeFiles/sdl_test.dir/cmake_clean.cmake b/CMakeFiles/sdl_test.dir/cmake_clean.cmake index a60d8f5..cabfeec 100644 --- a/CMakeFiles/sdl_test.dir/cmake_clean.cmake +++ b/CMakeFiles/sdl_test.dir/cmake_clean.cmake @@ -1,5 +1,6 @@ file(REMOVE_RECURSE "CMakeFiles/sdl_test.dir/commands/commands.cpp.obj" + "CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj" "CMakeFiles/sdl_test.dir/game/entity.cpp.obj" "CMakeFiles/sdl_test.dir/game/ground.cpp.obj" "CMakeFiles/sdl_test.dir/game/gst.cpp.obj" diff --git a/CMakeFiles/sdl_test.dir/depend.internal b/CMakeFiles/sdl_test.dir/depend.internal index 7277f69..5edf746 100644 --- a/CMakeFiles/sdl_test.dir/depend.internal +++ b/CMakeFiles/sdl_test.dir/depend.internal @@ -50,6 +50,9 @@ CMakeFiles/sdl_test.dir/commands/commands.cpp.obj C:/MinGW_libs/include/SDL2/close_code.h C:/Users/jaksk/Desktop/dev/_cpp/age/commands/commands.cpp C:/Users/jaksk/Desktop/dev/_cpp/age/commands/commands.h +CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.cpp + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h CMakeFiles/sdl_test.dir/game/entity.cpp.obj C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.cpp C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h @@ -227,6 +230,12 @@ CMakeFiles/sdl_test.dir/main.cpp.obj C:/MinGW_libs/include/SDL2/begin_code.h C:/MinGW_libs/include/SDL2/close_code.h C:/Users/jaksk/Desktop/dev/_cpp/age/commands/commands.h + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/action.h + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/engine.h + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/evaluator.h + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/generator.h + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/performer.h + C:/Users/jaksk/Desktop/dev/_cpp/age/game/ai/tactic.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/entity.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/ground.h C:/Users/jaksk/Desktop/dev/_cpp/age/game/gst.h diff --git a/CMakeFiles/sdl_test.dir/depend.make b/CMakeFiles/sdl_test.dir/depend.make index 2e68f12..0d1b776 100644 --- a/CMakeFiles/sdl_test.dir/depend.make +++ b/CMakeFiles/sdl_test.dir/depend.make @@ -50,6 +50,9 @@ CMakeFiles/sdl_test.dir/commands/commands.cpp.obj: C:/MinGW_libs/include/SDL2/cl CMakeFiles/sdl_test.dir/commands/commands.cpp.obj: commands/commands.cpp CMakeFiles/sdl_test.dir/commands/commands.cpp.obj: commands/commands.h +CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj: game/ai/action.cpp +CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj: game/ai/action.h + CMakeFiles/sdl_test.dir/game/entity.cpp.obj: game/entity.cpp CMakeFiles/sdl_test.dir/game/entity.cpp.obj: game/entity.h CMakeFiles/sdl_test.dir/game/entity.cpp.obj: umath/vec2.h @@ -226,6 +229,12 @@ CMakeFiles/sdl_test.dir/main.cpp.obj: C:/MinGW_libs/include/SDL2/SDL_video.h CMakeFiles/sdl_test.dir/main.cpp.obj: C:/MinGW_libs/include/SDL2/begin_code.h CMakeFiles/sdl_test.dir/main.cpp.obj: C:/MinGW_libs/include/SDL2/close_code.h CMakeFiles/sdl_test.dir/main.cpp.obj: commands/commands.h +CMakeFiles/sdl_test.dir/main.cpp.obj: game/ai/action.h +CMakeFiles/sdl_test.dir/main.cpp.obj: game/ai/engine.h +CMakeFiles/sdl_test.dir/main.cpp.obj: game/ai/evaluator.h +CMakeFiles/sdl_test.dir/main.cpp.obj: game/ai/generator.h +CMakeFiles/sdl_test.dir/main.cpp.obj: game/ai/performer.h +CMakeFiles/sdl_test.dir/main.cpp.obj: game/ai/tactic.h CMakeFiles/sdl_test.dir/main.cpp.obj: game/entity.h CMakeFiles/sdl_test.dir/main.cpp.obj: game/ground.h CMakeFiles/sdl_test.dir/main.cpp.obj: game/gst.h diff --git a/CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj b/CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj Binary files differnew file mode 100644 index 0000000..43e20d4 --- /dev/null +++ b/CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/game/ground.cpp.obj b/CMakeFiles/sdl_test.dir/game/ground.cpp.obj Binary files differindex dfa13e1..616413a 100644 --- a/CMakeFiles/sdl_test.dir/game/ground.cpp.obj +++ b/CMakeFiles/sdl_test.dir/game/ground.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/game/gst.cpp.obj b/CMakeFiles/sdl_test.dir/game/gst.cpp.obj Binary files differindex 03b1070..9bbba82 100644 --- a/CMakeFiles/sdl_test.dir/game/gst.cpp.obj +++ b/CMakeFiles/sdl_test.dir/game/gst.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/game/load.cpp.obj b/CMakeFiles/sdl_test.dir/game/load.cpp.obj Binary files differindex 9b284fb..5db0ae0 100644 --- a/CMakeFiles/sdl_test.dir/game/load.cpp.obj +++ b/CMakeFiles/sdl_test.dir/game/load.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/game/playercontrol.cpp.obj b/CMakeFiles/sdl_test.dir/game/playercontrol.cpp.obj Binary files differindex 37123b3..7488c27 100644 --- a/CMakeFiles/sdl_test.dir/game/playercontrol.cpp.obj +++ b/CMakeFiles/sdl_test.dir/game/playercontrol.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/main.cpp.obj b/CMakeFiles/sdl_test.dir/main.cpp.obj Binary files differindex ee5598b..ef57964 100644 --- a/CMakeFiles/sdl_test.dir/main.cpp.obj +++ b/CMakeFiles/sdl_test.dir/main.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/objects.a b/CMakeFiles/sdl_test.dir/objects.a Binary files differindex 9b2f400..6599889 100644 --- a/CMakeFiles/sdl_test.dir/objects.a +++ b/CMakeFiles/sdl_test.dir/objects.a diff --git a/CMakeFiles/sdl_test.dir/objects1.rsp b/CMakeFiles/sdl_test.dir/objects1.rsp index f355c18..764058d 100644 --- a/CMakeFiles/sdl_test.dir/objects1.rsp +++ b/CMakeFiles/sdl_test.dir/objects1.rsp @@ -1 +1 @@ -CMakeFiles/sdl_test.dir/main.cpp.obj CMakeFiles/sdl_test.dir/graphics/graphics.cpp.obj CMakeFiles/sdl_test.dir/commands/commands.cpp.obj CMakeFiles/sdl_test.dir/timing/timing.cpp.obj CMakeFiles/sdl_test.dir/game/entity.cpp.obj CMakeFiles/sdl_test.dir/game/ground.cpp.obj CMakeFiles/sdl_test.dir/game/playercontrol.cpp.obj CMakeFiles/sdl_test.dir/game/gst.cpp.obj CMakeFiles/sdl_test.dir/game/view.cpp.obj CMakeFiles/sdl_test.dir/game/menu.cpp.obj CMakeFiles/sdl_test.dir/game/tile.cpp.obj CMakeFiles/sdl_test.dir/game/load.cpp.obj CMakeFiles/sdl_test.dir/game/tech.cpp.obj +CMakeFiles/sdl_test.dir/main.cpp.obj CMakeFiles/sdl_test.dir/graphics/graphics.cpp.obj CMakeFiles/sdl_test.dir/commands/commands.cpp.obj CMakeFiles/sdl_test.dir/timing/timing.cpp.obj CMakeFiles/sdl_test.dir/game/entity.cpp.obj CMakeFiles/sdl_test.dir/game/ground.cpp.obj CMakeFiles/sdl_test.dir/game/playercontrol.cpp.obj CMakeFiles/sdl_test.dir/game/gst.cpp.obj CMakeFiles/sdl_test.dir/game/view.cpp.obj CMakeFiles/sdl_test.dir/game/menu.cpp.obj CMakeFiles/sdl_test.dir/game/tile.cpp.obj CMakeFiles/sdl_test.dir/game/load.cpp.obj CMakeFiles/sdl_test.dir/game/tech.cpp.obj CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj diff --git a/CMakeFiles/sdl_test.dir/progress.make b/CMakeFiles/sdl_test.dir/progress.make index 4f6e68a..1029366 100644 --- a/CMakeFiles/sdl_test.dir/progress.make +++ b/CMakeFiles/sdl_test.dir/progress.make @@ -12,4 +12,5 @@ CMAKE_PROGRESS_11 = 11 CMAKE_PROGRESS_12 = 12 CMAKE_PROGRESS_13 = 13 CMAKE_PROGRESS_14 = 14 +CMAKE_PROGRESS_15 = 15 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a6bab2..ed7acb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,11 @@ add_executable(sdl_test game/tech.cpp game/tech.h game/player.h game/constants.h + game/ai/action.cpp game/ai/action.h + game/ai/generator.h + game/ai/engine.h + game/ai/evaluator.h + game/ai/tactic.h umath/vec2.h) target_include_directories(sdl_test PUBLIC "C:/MinGW_libs/include") @@ -168,6 +168,33 @@ commands/commands.cpp.s: $(MAKE) $(MAKESILENT) -f CMakeFiles\sdl_test.dir\build.make CMakeFiles/sdl_test.dir/commands/commands.cpp.s .PHONY : commands/commands.cpp.s +game/ai/action.obj: game/ai/action.cpp.obj + +.PHONY : game/ai/action.obj + +# target to build an object file +game/ai/action.cpp.obj: + $(MAKE) $(MAKESILENT) -f CMakeFiles\sdl_test.dir\build.make CMakeFiles/sdl_test.dir/game/ai/action.cpp.obj +.PHONY : game/ai/action.cpp.obj + +game/ai/action.i: game/ai/action.cpp.i + +.PHONY : game/ai/action.i + +# target to preprocess a source file +game/ai/action.cpp.i: + $(MAKE) $(MAKESILENT) -f CMakeFiles\sdl_test.dir\build.make CMakeFiles/sdl_test.dir/game/ai/action.cpp.i +.PHONY : game/ai/action.cpp.i + +game/ai/action.s: game/ai/action.cpp.s + +.PHONY : game/ai/action.s + +# target to generate assembly for a file +game/ai/action.cpp.s: + $(MAKE) $(MAKESILENT) -f CMakeFiles\sdl_test.dir\build.make CMakeFiles/sdl_test.dir/game/ai/action.cpp.s +.PHONY : game/ai/action.cpp.s + game/entity.obj: game/entity.cpp.obj .PHONY : game/entity.obj @@ -504,6 +531,9 @@ help: @echo ... commands/commands.obj @echo ... commands/commands.i @echo ... commands/commands.s + @echo ... game/ai/action.obj + @echo ... game/ai/action.i + @echo ... game/ai/action.s @echo ... game/entity.obj @echo ... game/entity.i @echo ... game/entity.s diff --git a/build/sdl_test.exe b/build/sdl_test.exe Binary files differindex 9cf847e..2e2e670 100644 --- a/build/sdl_test.exe +++ b/build/sdl_test.exe diff --git a/game/ai/action.cpp b/game/ai/action.cpp new file mode 100644 index 0000000..63218ba --- /dev/null +++ b/game/ai/action.cpp @@ -0,0 +1,76 @@ +#include "action.h" + +bool ai::compare_action(ai::action a, ai::action b) { + return (a.heuristic < b.heuristic); +} + +std::string ai::action::to_string () { + if (type == actype::attack) { + if (abs(x-mx)+abs(y-my) != 0) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " move " + + "[" + std::to_string(mx) + ", " + std::to_string(my) + "]" + + " attack " + + "[" + std::to_string(tx) + ", " + std::to_string(ty) + "]"; + } else { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " attack " + + "[" + std::to_string(tx) + ", " + std::to_string(ty) + "]"; + } + } + if (type == actype::heal) { + if (abs(x-mx)+abs(y-my) != 0) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " move " + + "[" + std::to_string(mx) + ", " + std::to_string(my) + "]" + + " heal " + + "[" + std::to_string(tx) + ", " + std::to_string(ty) + "]"; + } else { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " heal " + + "[" + std::to_string(tx) + ", " + std::to_string(ty) + "]"; + } + } + if (type == actype::convert) { + if (abs(x-mx)+abs(y-my) != 0) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " move " + + "[" + std::to_string(mx) + ", " + std::to_string(my) + "]" + + " convert " + + "[" + std::to_string(tx) + ", " + std::to_string(ty) + "]"; + } else { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " convert " + + "[" + std::to_string(tx) + ", " + std::to_string(ty) + "]"; + } + } + if (type == actype::move) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " move " + + "[" + std::to_string(mx) + ", " + std::to_string(my) + "]"; + } + if (type == actype::build) { + if (abs(x-mx)+abs(y-my) != 0) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + + "]" + " move " + + "[" + std::to_string(mx) + ", " + std::to_string(my) + + "]" + " build " + + std::to_string(v); + } else { + return "[" + std::to_string(mx) + ", " + std::to_string(my) + + "]" + " build " + + std::to_string(v); + } + } + if (type == actype::train) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " train " + std::to_string(v); + } + if (type == actype::trade) { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]" + + " trade " + std::to_string(v); + } + if (type == actype::tech) { + return "tech " + std::to_string(v); + } +}
\ No newline at end of file diff --git a/game/ai/action.h b/game/ai/action.h new file mode 100644 index 0000000..12da451 --- /dev/null +++ b/game/ai/action.h @@ -0,0 +1,52 @@ +#ifndef ACTION_H +#define ACTION_H + +#include <string> +#include <vector> + +namespace ai { + +enum actype { + attack, heal, convert, build, train, trade, move, tech +}; + +class action { + public: + action (actype type, int v) : + type(type), v(v) {} + action (actype type, int x, int y, int v) : + type(type), x(x), y(y), v(v) {} + action (actype type, int x, int y, int mx, int my) : + type(type), x(x), y(y), mx(mx), my(my) {} + action (actype type, int x, int y, int mx, int my, int v) : + type(type), x(x), y(y), mx(mx), my(my), v(v) {} + action (actype type, int x, int y, int mx, int my, int tx, int ty) : + type(type), x(x), y(y), mx(mx), my(my), tx(tx), ty(ty) {} + action (actype type, int x, int y, int mx, int my, int tx, int ty, int v) : + type(type), x(x), y(y), mx(mx), my(my), tx(tx), ty(ty), v(v) {} + + action (const action& rhs) { + type = rhs.type; x = rhs.x; y = rhs.y; mx = rhs.mx; my = rhs.my; + tx = rhs.tx; ty = rhs.ty; v = rhs.v; + } + action& operator=(const action& rhs) { + type = rhs.type; x = rhs.x; y = rhs.y; mx = rhs.mx; my = rhs.my; + tx = rhs.tx; ty = rhs.ty; v = rhs.v; + } + + actype type; + int x, y; // start + int mx, my; // moved + int tx, ty; // target + int v; // value (id of trainee, building or f/g trade, or tech id) + + float heuristic { 0 }; + + std::string to_string (); +}; + +bool compare_action(action a, action b); + +} + +#endif
\ No newline at end of file diff --git a/game/ai/engine.h b/game/ai/engine.h new file mode 100644 index 0000000..d3755e1 --- /dev/null +++ b/game/ai/engine.h @@ -0,0 +1,66 @@ +#ifndef ENGINE_H +#define ENGINE_H + +#include <iostream> + +#include <string> +#include <vector> +#include <limits> +#include <cmath> + +#include "../ground.h" +#include "../gst.h" + +#include "action.h" +#include "tactic.h" +#include "generator.h" +#include "evaluator.h" +#include "performer.h" + +namespace ai { + +class engine { + public: + engine (Gst &gst) : init(gst) {} + Gst &init; + + tactic get_best () { + tactic t { search(init, 4) }; + std::cout << t.to_string(); + return t; + } + + tactic search (Gst &gst, int depth) { + generator gen { gst }; + std::vector<tactic> tactics = gen.tactics(); + tactic best; best.eval = std::numeric_limits<float>::lowest(); + for (tactic t : tactics) { + performer perf { gst }; + Gst next { perf.apply(t) }; + t.eval = negamax(next, depth, gst.turn); + std::cout << "depth " << depth << " eval " << t.eval << "\n"; + if (t.eval > best.eval) best = t; + } + return best; + } + + float negamax (Gst gst, int depth, int player) { + //for (int i=0; i<3-depth; i++) std::cout << " "; std::cout << depth << "\n"; + if (depth == 0) { + evaluator eval { gst }; + return eval.eval(player); + } + float value = std::numeric_limits<float>::lowest(); + generator gen { gst }; + auto tactics = gen.tactics(); + for (tactic t : tactics) { + performer perf { gst }; + Gst next { perf.apply(t) }; + value = fmax(value, negamax(next, depth-1, -player)); + } + return -value; + } +}; + +} +#endif
\ No newline at end of file diff --git a/game/ai/evaluator.h b/game/ai/evaluator.h new file mode 100644 index 0000000..75684de --- /dev/null +++ b/game/ai/evaluator.h @@ -0,0 +1,30 @@ +#ifndef EVALUATOR_H +#define EVALUATOR_H + +#include <iostream> + +#include <string> +#include <vector> + +#include "../ground.h" +#include "../gst.h" + +namespace ai { + +class evaluator { + public: + evaluator (Gst gst) : gst(gst) {} + Gst gst; + + float eval (int player) { + float val = 0; + for (Entity &ent : gst.entities) { + int own = (int)(ent.owner != player)*2-1; + val += own*(ent.info->cost[0] + ent.info->cost[1])*(ent.hp/100.0f); + } + return val; + } +}; + +} +#endif
\ No newline at end of file diff --git a/game/ai/generator.h b/game/ai/generator.h new file mode 100644 index 0000000..c6cb288 --- /dev/null +++ b/game/ai/generator.h @@ -0,0 +1,102 @@ +#ifndef GENERATOR_H +#define GENERATOR_H + +#include <iostream> + +#include <string> +#include <vector> + +#include "../ground.h" +#include "../gst.h" +#include "action.h" +#include "tactic.h" +#include "performer.h" + +namespace ai { + +const int maxiter = 100000; + + +class generator { + public: + generator (Gst &gst) : init(gst) {} + Gst &init; + + std::vector<action> valid_actions (Gst &gst) { + Ground &gr = gst.inv->ground; + std::vector<action> acts; + for (Entity &ent : gst.entities) { + if (ent.done) continue; + if (ent.owner != gst.turn) continue; + + std::vector<action> ent_acts; + + std::vector<int> moves = gr.move_area(gst, ent); + for (auto move : moves) { + int mx = move%gr.sizex, my = move/gr.sizex; + action act { actype::move, ent.x, ent.y, mx, my }; + + performer perf { gst }; + Gst next { gst }; + next = perf.act(next, act); + Entity &matk = next.get_at(mx, my); + std::vector<int> atks = gr.attack_targets(next, matk); + for (auto atk : atks) { + int tx = atk%gr.sizex, ty = atk/gr.sizex; + action act_atk { actype::attack, ent.x, ent.y, + mx, my, tx, ty }; + Entity &mdef = next.get_at(tx, ty); + + BattleResult res = gst.battle_res(matk, mdef); + float heur = (mdef.hp-res.def_hp); + heur *= (mdef.info->cost[0] + mdef.info->cost[1]); + act_atk.heuristic = heur; + ent_acts.push_back(act_atk); + } + + int dist = 999999; + int pos = gst.get_nearest_enemy(ent, dist); + float heur = 1.0f/dist; + act.heuristic = heur; + ent_acts.push_back(act); + } + std::sort(ent_acts.begin(), ent_acts.end(), compare_action); + for (int i=0; i<3 && i<ent_acts.size(); i++) { + acts.push_back(ent_acts[i]); + } + } + std::sort(acts.begin(), acts.end(), compare_action); + return acts; + } + + tactic valid_tactic (int &n) { + tactic t; + Gst gst { init }; + for (int i=0; i<ai::maxiter; i++) { + std::vector<action> acts { valid_actions(gst) }; + if (acts.size() == 0) break; + performer perf { gst }; + int j = n % (acts.size()); + n /= acts.size(); + action &act = acts[j]; + gst = perf.act(gst, act); + t.acts.push_back(act); + //std::cout << act.to_string() << std::endl; + } + return t; + } + + std::vector<tactic> tactics () { + std::vector<tactic> ts; + for (int i=0; i<3; i++) { + int n = i; + tactic t = valid_tactic(n); + if (n > 0) break; + ts.push_back(t); + } + return ts; + } +}; + +} +#endif
\ No newline at end of file diff --git a/game/ai/performer.h b/game/ai/performer.h new file mode 100644 index 0000000..472773b --- /dev/null +++ b/game/ai/performer.h @@ -0,0 +1,49 @@ +#ifndef PERFORMER_H +#define PERFORMER_H + +#include <iostream> + +#include <string> +#include <vector> + +#include "../ground.h" +#include "../gst.h" +#include "action.h" +#include "tactic.h" + +namespace ai { + +class performer { + public: + performer (Gst &gst) : init(gst) {} + Gst &init; + + Gst apply (tactic t) { + Gst next { init }; + for (action a : t.acts) { + next = act(next, a); + } + next.end_day(); + return next; + } + + Gst& act (Gst &gst, action a) { + if (a.type == actype::move) { + Entity &ent = gst.get_at(a.x, a.y); + ent.x = a.mx; ent.y = a.my; + ent.moved = 1; ent.done = true; + } + if (a.type == actype::attack) { + Entity &ent = gst.get_at(a.x, a.y); + ent.x = a.mx; ent.y = a.my; + ent.moved = 1; + Entity &def = gst.get_at(a.tx, a.ty); + gst.battle(ent, def); + ent.done = true; + } + return gst; + } +}; + +} +#endif
\ No newline at end of file diff --git a/game/ai/tactic.h b/game/ai/tactic.h new file mode 100644 index 0000000..7eefef9 --- /dev/null +++ b/game/ai/tactic.h @@ -0,0 +1,32 @@ +#ifndef TACTIC_H +#define TACTIC_H + +#include <string> +#include <vector> + +#include "action.h" + +namespace ai { + +class tactic { + public: + tactic () { } + + std::vector<action> acts; + float eval = 0; + + // copy constructor + tactic (const tactic& rhs) { acts = rhs.acts; eval = rhs.eval; } + tactic& operator=(const tactic& rhs) { acts = rhs.acts; eval = rhs.eval; } + + std::string to_string () { + std::string str = "tactic eval= " + std::to_string(eval) + "\n"; + for (action act : acts) { + str += act.to_string() + "\n"; + } + return str; + } +}; + +} +#endif
\ No newline at end of file diff --git a/game/entity.h b/game/entity.h index 62e352e..a15ebdb 100644 --- a/game/entity.h +++ b/game/entity.h @@ -50,22 +50,32 @@ namespace EntityClass { class Entity { public: - Entity(int x, int y, EntityInfo *info, int owner) + Entity (int x, int y, EntityInfo *info, int owner) : x(x), y(y), info(info), owner(owner) { moved = 0; hp = 100; } + // copy constructor + Entity (const Entity& rhs) { + building = rhs.building; hp = rhs.hp; x = rhs.x; y = rhs.y; + done = rhs.done; moved = rhs.moved; info = rhs.info; + fights = rhs.fights; owner = rhs.owner; + } + Entity& operator=(const Entity& rhs) { + building = rhs.building; hp = rhs.hp; x = rhs.x; y = rhs.y; + done = rhs.done; moved = rhs.moved; info = rhs.info; + fights = rhs.fights; owner = rhs.owner; + }; bool operator==(Entity oth) { return x == oth.x && y == oth.y && info->unit == oth.info->unit; } int building { 0 }; - float hp; /**/ + float hp; int x, y; bool done = false; int moved; EntityInfo *info; int fights { 0 }; - int owner; }; diff --git a/game/ground.cpp b/game/ground.cpp index 5f58717..cd67751 100644 --- a/game/ground.cpp +++ b/game/ground.cpp @@ -65,23 +65,25 @@ std::vector<int> Ground::move_area (Gst &gst, Entity &ent) { int movecost = gst.inv->tiles[tiles[t]].move_cost; if (movecost > maxcost) movecost = maxcost; int walkedm = maxf.m - movecost; - bool obstructed = false; + bool obs_enemy = false, obs_friend = false; for (Entity &e : gst.entities) { - if (e.owner != ent.owner && at(e.x, e.y) == t) { - obstructed = true; + if (at(e.x, e.y) == t) { + if (e.owner != ent.owner) obs_enemy = true; + else obs_friend = true; break; } } - if (walkedm >= 0 && !obstructed) { + if (walkedm >= 0 && !obs_enemy) { frontier.emplace_back(t, walkedm); - moves.push_back(t); + if (!obs_friend) { + moves.push_back(t); + } } } } visited.push_back(maxf.pos); } - std::cout << "iters: " << iter; return moves; } diff --git a/game/gst.cpp b/game/gst.cpp index 52dfe81..334844a 100644 --- a/game/gst.cpp +++ b/game/gst.cpp @@ -261,8 +261,8 @@ BattleResult Gst::battle_res (Entity &atk, Entity &def) { } void Gst::battle (Entity &atk, Entity &def) { - std::cout << "! attack " << atk.info->name << "(hp:" << atk.hp << "), " - << def.info->name << "(hp:" << def.hp << ") \n"; + /*std::cout << "! attack " << atk.info->name << "(hp:" << atk.hp << "), " + << def.info->name << "(hp:" << def.hp << ") \n";*/ auto result = battle_res(atk, def); atk.hp = result.atk_hp; @@ -271,8 +271,8 @@ void Gst::battle (Entity &atk, Entity &def) { if (atk.info->unit == 1) atk.fights += 1; if (def.info->unit == 1) def.fights += 1; - std::cout << "! result " << atk.info->name << "(hp:" << atk.hp << "), " - << def.info->name << "(hp:" << def.hp << ") \n"; + /*std::cout << "! result " << atk.info->name << "(hp:" << atk.hp << "), " + << def.info->name << "(hp:" << def.hp << ") \n";*/ clear_dead(); } @@ -320,6 +320,20 @@ void Gst::convert (Entity &atk, Entity &def) { } +int Gst::get_nearest_enemy (Entity &ent, int &mindist) { + auto &ground = inv->ground; + int pos = -1; mindist = 9999999; + for (Entity &oth : entities) { + if (oth.owner == ent.owner) continue; + int dist = abs(oth.x-ent.x) + abs(oth.y-ent.y); + if (dist < mindist) { + mindist = dist; + pos = ground.at(oth.x, oth.y); + } + } +} + + std::vector<int> Gst::get_possible_trains (Entity &ent) { Player &player = get_player(ent.owner); auto &cls = ent.info->train_class; @@ -68,11 +68,20 @@ class Gst { public: Gst(Inv *inv) : inv(inv) { } + // copy constructor + Gst (const Gst& rhs) { + inv = rhs.inv; entities = rhs.entities; players = rhs.players; + turn = rhs.turn; day = rhs.day; + } + Gst& operator=(const Gst& rhs) { + inv = rhs.inv; entities = rhs.entities; players = rhs.players; + turn = rhs.turn; day = rhs.day; + }; + Inv *inv; std::vector<Entity> entities; std::vector<Player> players; - int turn { 0 }; int day { 0 }; @@ -97,6 +106,8 @@ class Gst { void heal (Entity &atk, Entity &def); void convert (Entity &atk, Entity &def); + int get_nearest_enemy (Entity &ent, int &mindist); + std::vector<int> get_possible_trains (Entity &ent); std::vector<int> get_possible_builds (Entity &ent); diff --git a/game/load.cpp b/game/load.cpp index 9f58c7d..ea4e9e7 100644 --- a/game/load.cpp +++ b/game/load.cpp @@ -145,8 +145,6 @@ void load_json (Inv &inv) { tech.bonus.aff_all = b["aff_all"]; } } - - std::cout << tech.id << tech.bonus.to_string() << std::endl; inv.techs.push_back(tech); } }
\ No newline at end of file @@ -13,38 +13,9 @@ #include "game/tile.h" #include "game/load.h" -// state representation -/* - ground matrix - . tile: { - name - range bonus - travel cost - defence bonus - sight penalty - } - units list - . unit: { - name - type - attack - defence - life - move points - sight - (morale?) - ability list - . abilities: [ ] - } - builds - . build: { - same as unit - trainees list - } - tech - resources (food, gold) - trade bonus -*/ +#include "game/ai/engine.h" +#include "game/ai/performer.h" + int main () { Graphics graphics (900, 600); @@ -56,8 +27,9 @@ int main () { float ts = 16; Inv inv; - inv.ground.build(15,15); + load_json(inv); + inv.ground.build(15,15); inv.ground.tiles[1] = 1; inv.ground.tiles[8] = 1; inv.ground.tiles[11] = 2; @@ -69,13 +41,11 @@ int main () { for (int i=0; i<2000; i+=71) { inv.ground.tiles[i%(inv.ground.sizex*inv.ground.sizey)] = 1; } - inv.ground.resources.emplace_back(inv.ground.at(3, 4), Resource::Type::gold); inv.ground.resources.emplace_back(inv.ground.at(4, 4), Resource::Type::food); - Gst gst { &inv }; - load_json(inv); + Gst gst { &inv }; gst.players.emplace_back(255, 0, 0, 0); gst.players[0].res = std::vector<float> { 1500, 1500 }; @@ -83,8 +53,6 @@ int main () { gst.players[1].res = std::vector<float> { 1500, 1500 }; gst.players[0].level = 2; - - gst.entities.emplace_back(5, 1, inv.get_info("Town Center"), 0); gst.entities.emplace_back(6, 1, inv.get_info("Barracks"), 0); gst.entities.emplace_back(5, 0, inv.get_info("Stable"), 0); @@ -124,20 +92,19 @@ int main () { timing.process(); while (timing.check_process()) { com.process_clicks(); - // input detection - // turn fsm or ai - // turn tick calculations - /* - economy - tech - upgrades - win condition - */ view.process(gst, graphics.cam.pos, mousepos, com.mheld); if (com.check_key(SDL_SCANCODE_ESCAPE)) { view.back = 1; } + if (com.check_key(SDL_SCANCODE_SPACE)) { + ai::engine eng { gst }; + auto best = eng.get_best(); + + ai::performer perf { gst }; + gst = perf.apply(best); + } + control.process(gst, view); com.process_keys(); } |