Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure compatibility with GCC #1

Merged
merged 7 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,6 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

# Visual Studio Code directory
.vscode
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#######################################
# CMake File for the Central64 Examples
#######################################
#########################################################
# CMake File for the Central64 Examples and Analysis Code
#########################################################
cmake_minimum_required(VERSION 3.10)
project(Central64)

Expand All @@ -13,7 +13,7 @@ if(MSVC)
string(REGEX REPLACE "/Z[iI7]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7 /bigobj")
else()
set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces -Wno-ignored-attributes -Wignored-qualifiers -Woverloaded-virtual -Winline")
set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces -Wno-ignored-attributes -Wignored-qualifiers -Woverloaded-virtual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -pedantic-errors -std=c++${CMAKE_CXX_STANDARD} ${WARNING_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS}")
endif(MSVC)
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The Central64 library is intended to be fast and flexible. All combinations of t
- *Search Method:* Choose between **A\* Search**, **Jump Point Search**, **Bounded Jump Point Search**, **Mixed A\***, and **Mixed Jump Point Search**.
- *Smoothing Method:* Choose between **No Smoothing**, **Greedy Smoothing**, and **Tentpole Smoothing**.

The library was also designed to support an empirical comparison of these path planning techniques. Based on the results of the study, **16-Neighbor Bounded Jump Point Search with Tentpole Smoothing** is recommended as the combined method that provides the best overall balance of quality and speed. See the [Central64 Technical Report](report/00-index.md) ([PDF](report/central64-technical-report.pdf)) for details.
The library was also designed to support an empirical comparison of these path planning techniques. Based on the results of the study, **16-Neighbor Central Bounded Jump Point Search with Tentpole Smoothing** is recommended as the combined method that provides the best overall balance of quality and speed. See the [Central64 Technical Report](report/00-index.md) ([PDF](report/central64-technical-report.pdf)) for details.

## How to Use

Expand Down Expand Up @@ -199,7 +199,9 @@ The following instructions regenerate the PDF version of the report using Visual

### Build Instructions

Building the Central64 project is necessary only to run the examples or analyze the various methods. Otherwise, simply include the header files in your project as outlined in the [How to Use](#how-to-use) section. Below are instructions for building the examples and analysis code using CMake and Visual Studio 2019:
Building the Central64 project is necessary only to run the examples or analyze the various methods. Otherwise, simply include the header files in your project as outlined in the [How to Use](#how-to-use) section.

Below are instructions for building the examples and analysis code using [CMake](https://cmake.org/) and Visual Studio 2019:

* Open a command prompt and go to the root directory of the project.
* `mkdir build`
Expand All @@ -209,6 +211,15 @@ Building the Central64 project is necessary only to run the examples or analyze
* Build the solution.
* Run `Debug/Central64Examples.exe` or `Release/Central64Examples.exe` to test. The output should match [results/examples.txt](results/examples.txt).

Below are instructions for building the examples and analysis code using [CMake](https://cmake.org/), [Make](https://www.gnu.org/software/make/), and GCC (using 64-bit [TDM-GCC](https://jmeubank.github.io/tdm-gcc/)) on Windows:

* Open a command prompt and go to the root directory of the project.
* `mkdir build`
* `cd build`
* `cmake -G "MinGW Makefiles" ..`
* `make`
* Run `Central64Examples.exe` to test. The output should match [results/examples.txt](results/examples.txt).

### Analysis Instructions

Below are additional instructions for analyzing the *Dragon Age: Origins* maps and scenarios [distributed by the Moving AI Lab](https://movingai.com/benchmarks/grids.html) with permission from [BioWare](https://www.bioware.com/). Other Moving AI Lab benchmarks can be analyzed in a similar manner.
Expand Down
3 changes: 1 addition & 2 deletions analysis/AnalyzeBenchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BenchmarkResult AnalyzeBenchmark(const std::filesystem::path& mapFilePath,
if (!inputCells.empty() && !scenarios.empty()) {
auto planner = PathPlanner<L>{ inputCells, alignment, searchMethod, smoothingMethod, centralize };
if (scenarioIndex >= 0) {
if (scenarioIndex >= scenarios.size()) {
if (scenarioIndex >= int(scenarios.size())) {
printf("Warning: Scenario index %d must be less than number of scenarios (%d)\n", scenarioIndex, int(scenarios.size()));
printf("\n");
}
Expand Down Expand Up @@ -111,7 +111,6 @@ BenchmarkResult AnalyzeBenchmark(const std::filesystem::path& mapFilePath,
int validPaths = 0;
int totalScenarios = 0;
for (const auto& scen : scenarios) {
auto tA = std::chrono::steady_clock::now();
if (totalScenarios%25 == 0) {
auto tA = std::chrono::steady_clock::now();
planner.SearchAllNodes(scen.first);
Expand Down
23 changes: 11 additions & 12 deletions include/central64/PathPlanner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class PathPlanner

int NeighborhoodSize() const { return L; } ///< Get the neighborhood size.

const Grid2D<L>& Grid() const { return grid_; } ///< Obtain a const reference to the grid.
const Grid2D<L>& Grid() const { return searchPtr_->Grid(); } ///< Obtain a const reference to the grid.
AbstractSearch<L>& Search() { return *searchPtr_; } ///< Obtain a reference to the path search object.
AbstractSmoothing<L>& Smoothing() { return *smoothingPtr_; } ///< Obtain a reference to the path smoothing object.

Expand All @@ -72,7 +72,6 @@ class PathPlanner
PathPlanner(const PathPlanner&) = delete;
PathPlanner& operator=(const PathPlanner&) = delete;

Grid2D<L> grid_;
std::unique_ptr<AbstractSearch<L>> searchPtr_{};
std::unique_ptr<AbstractSmoothing<L>> smoothingPtr_{};
bool centralize_;
Expand All @@ -86,21 +85,21 @@ PathPlanner<L>::PathPlanner(const std::vector<std::vector<bool>>& inputCells,
SmoothingMethod smoothingMethod,
bool centralize,
bool fromSource)
: grid_{ inputCells, alignment }
, centralize_{ centralize }
: centralize_{ centralize }
, fromSource_{ fromSource }
{
Grid2D<L> grid{ inputCells, alignment };
switch (searchMethod) {
case SearchMethod::AStar: searchPtr_ = std::make_unique< AStarSearch<L>>(grid_); break;
case SearchMethod::JumpPoint: searchPtr_ = std::make_unique< JumpPointSearch<L>>(grid_); break;
case SearchMethod::BoundedJumpPoint: searchPtr_ = std::make_unique< JumpPointSearch<L>>(grid_, PathCost(8)); break;
case SearchMethod::MixedAStar: searchPtr_ = std::make_unique< MixedAStarSearch<L>>(grid_); break;
case SearchMethod::MixedJumpPoint: searchPtr_ = std::make_unique<MixedJumpPointSearch<L>>(grid_); break;
case SearchMethod::AStar: searchPtr_ = std::make_unique< AStarSearch<L>>(grid); break;
case SearchMethod::JumpPoint: searchPtr_ = std::make_unique< JumpPointSearch<L>>(grid); break;
case SearchMethod::BoundedJumpPoint: searchPtr_ = std::make_unique< JumpPointSearch<L>>(grid, PathCost(8)); break;
case SearchMethod::MixedAStar: searchPtr_ = std::make_unique< MixedAStarSearch<L>>(grid); break;
case SearchMethod::MixedJumpPoint: searchPtr_ = std::make_unique<MixedJumpPointSearch<L>>(grid); break;
}
switch (smoothingMethod) {
case SmoothingMethod::No: smoothingPtr_ = std::make_unique< NoSmoothing<L>>(grid_); break;
case SmoothingMethod::Greedy: smoothingPtr_ = std::make_unique< GreedySmoothing<L>>(grid_); break;
case SmoothingMethod::Tentpole: smoothingPtr_ = std::make_unique<TentpoleSmoothing<L>>(grid_); break;
case SmoothingMethod::No: smoothingPtr_ = std::make_unique< NoSmoothing<L>>(grid); break;
case SmoothingMethod::Greedy: smoothingPtr_ = std::make_unique< GreedySmoothing<L>>(grid); break;
case SmoothingMethod::Tentpole: smoothingPtr_ = std::make_unique<TentpoleSmoothing<L>>(grid); break;
}
assert(searchPtr_);
assert(smoothingPtr_);
Expand Down
4 changes: 2 additions & 2 deletions include/central64/grid/Array2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Array2D

void Fill(const T& value); ///< Set every element to `value`.

Offset2D Dims() const { return dims_; } ///< Get the dimensions.
Offset2D Size() const { return dims_.X()*dims_.Y(); } ///< Get the total number of elements.
Offset2D Dims() const { return dims_; } ///< Get the dimensions.
int Size() const { return dims_.X()*dims_.Y(); } ///< Get the total number of elements.

bool Contains(Offset2D coords) const; ///< Check whether coordinates `coords` are within the array.

Expand Down
11 changes: 8 additions & 3 deletions include/central64/grid/Grid2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class Grid2D
Offset2D Dims() const { return gridGraph_.Dims(); } ///< Get the number of vertices in each dimension.
CellAlignment Alignment() const { return alignment_; } ///< Get the cell alignment.

const Array2D<bool>& CenterCells() { return centerCells_; } ///< Obtain a const reference to the array of center-aligned cells.
const Array2D<bool>& CornerCells() { return cornerCells_; } ///< Obtain a const reference to the array of corner-aligned cells.
const Array2D<Connections<L>>& GridGraph() { return gridGraph_; } ///< Obtain a const reference to the array of sets of connections.

bool CenterCell(Offset2D coords) const { return centerCells_[coords]; } ///< Check whether the center-aligned cell at coordinates `coords` is obstructed.
bool CornerCell(Offset2D coords) const { return cornerCells_[coords]; } ///< Check whether the corner-aligned cell at coordinates `coords` is obstructed.

Expand Down Expand Up @@ -74,7 +78,7 @@ Grid2D<L>::Grid2D(const std::vector<std::vector<bool>>& inputCells,
// Store the centered-aligned grid cells.
centerCells_ = Array2D<bool>{ {nx, ny}, false };
for (int y = 0; y < ny; ++y) {
assert(inputCells[y].size() == nx);
assert(int(inputCells[y].size()) == nx);
for (int x = 0; x < nx; ++x) {
centerCells_[{x, y}] = inputCells[y][x];
}
Expand Down Expand Up @@ -104,7 +108,7 @@ Grid2D<L>::Grid2D(const std::vector<std::vector<bool>>& inputCells,
centerCells_ = Array2D<bool>{ {nx, ny}, true };
cornerCells_ = Array2D<bool>{ {nx - 1, ny - 1}, false };
for (int y = 0; y < ny - 1; ++y) {
assert(inputCells[y].size() == nx - 1);
assert(int(inputCells[y].size()) == nx - 1);
for (int x = 0; x < nx - 1; ++x) {
cornerCells_[{x, y}] = inputCells[y][x];
centerCells_[{x, y}] = centerCells_[{x, y}] && inputCells[y][x];
Expand Down Expand Up @@ -327,7 +331,8 @@ inline std::string ToString(const Grid2D<L>& grid, const std::vector<Offset2D>&
// Each path vertex is assigned the last digit of its index.
// All grid vertices that are not part of the path are set to -1.
Array2D<int> path2D{ grid.Dims(), -1 };
for (int i = 0; i < pathVertices.size(); ++i) {
int vertexCount = int(pathVertices.size());
for (int i = 0; i < vertexCount; ++i) {
path2D[pathVertices[i]] = i%10;
}

Expand Down
Loading