Initial Dijkstra algorithm for the map, but doesn't quite work right. The walls in the wall_map are not accounted for in the algorithm.
This commit is contained in:
parent
d7b1cf0bf9
commit
4d748d1f48
5 changed files with 143 additions and 1 deletions
35
tests/map.cpp
Normal file
35
tests/map.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include <catch2/catch_test_macros.hpp>
|
||||
#include "map.hpp"
|
||||
#include <fmt/core.h>
|
||||
|
||||
using namespace fmt;
|
||||
|
||||
TEST_CASE("dijkstra algo test", "[map]") {
|
||||
Matrix in_map = {
|
||||
{1, 1, 1, 0},
|
||||
{1, 0, 1, 1},
|
||||
{1, 0, 1, 1},
|
||||
{1, 1, 1, 1},
|
||||
};
|
||||
Matrix walls = {
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 1, 0},
|
||||
};
|
||||
Matrix expected = {
|
||||
{1, 1, 1, 0},
|
||||
{1, 0, 1, 1},
|
||||
{1, 0, 0, 2},
|
||||
{1, 1, 0, 3},
|
||||
};
|
||||
|
||||
Matrix res = dijkstra_map(in_map, walls);
|
||||
|
||||
println("--- EXPECTED:");
|
||||
dump_map(expected);
|
||||
println("--- RESULT:");
|
||||
dump_map(res);
|
||||
|
||||
REQUIRE(res == expected);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue