From 3d42291717f9d967e3ee6c2a112faed37a4557d5 Mon Sep 17 00:00:00 2001 From: moophy Date: Tue, 15 Sep 2015 03:46:09 +1200 Subject: [PATCH] Revert "fixed #7 (y,x) to (x,y)" This reverts commit b0daa4297b64d3cc5bf2c1b9982f1c7b4f4af3a6. --- planning/UnitTests/test_astar_sel.cpp | 4 ++-- planning/UnitTests/test_node.cpp | 12 ++++++------ planning/lib/node.hpp | 24 ++++++++++++------------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/planning/UnitTests/test_astar_sel.cpp b/planning/UnitTests/test_astar_sel.cpp index ab139e3..0d2dc15 100644 --- a/planning/UnitTests/test_astar_sel.cpp +++ b/planning/UnitTests/test_astar_sel.cpp @@ -45,8 +45,8 @@ namespace UnitTests astar({ "", { 0, 0 }, { 8, 12 } }, validate); Assert::AreEqual(44u, astar.last_run.max_q_size); - Assert::AreEqual(34u, astar.last_run.expansions.size()); - Assert::AreEqual(string{ "788887888688" }, astar.last_run.final_path); + Assert::AreEqual(32u, astar.last_run.expansions.size()); + Assert::AreEqual(string{ "588885888838" }, astar.last_run.final_path); Assert::IsTrue(100 < (int)astar.last_run.run_time && 1000 > (int)astar.last_run.run_time); Assert::IsTrue(astar.last_run.is_found); } diff --git a/planning/UnitTests/test_node.cpp b/planning/UnitTests/test_node.cpp index 90e93d5..151f160 100644 --- a/planning/UnitTests/test_node.cpp +++ b/planning/UnitTests/test_node.cpp @@ -17,12 +17,12 @@ namespace UnitTests auto const c = State{ 1u, 1u }; Assert::IsTrue(State{ 0u, 0u } == GOES.at('1')(c)); - Assert::IsTrue(State{ 1u, 0u } == GOES.at('2')(c)); - Assert::IsTrue(State{ 2u, 0u } == GOES.at('3')(c)); - Assert::IsTrue(State{ 0u, 1u } == GOES.at('4')(c)); - Assert::IsTrue(State{ 2u, 1u } == GOES.at('5')(c)); - Assert::IsTrue(State{ 0u, 2u } == GOES.at('6')(c)); - Assert::IsTrue(State{ 1u, 2u } == GOES.at('7')(c)); + Assert::IsTrue(State{ 0u, 1u } == GOES.at('2')(c)); + Assert::IsTrue(State{ 0u, 2u } == GOES.at('3')(c)); + Assert::IsTrue(State{ 1u, 0u } == GOES.at('4')(c)); + Assert::IsTrue(State{ 1u, 2u } == GOES.at('5')(c)); + Assert::IsTrue(State{ 2u, 0u } == GOES.at('6')(c)); + Assert::IsTrue(State{ 2u, 1u } == GOES.at('7')(c)); Assert::IsTrue(State{ 2u, 2u } == GOES.at('8')(c)); } diff --git a/planning/lib/node.hpp b/planning/lib/node.hpp index b73844a..fe9dda9 100644 --- a/planning/lib/node.hpp +++ b/planning/lib/node.hpp @@ -24,19 +24,19 @@ namespace search // struct State { - Integer x, y; + Integer y, x; auto to_string() const -> string { using std::to_string; - return "[" + to_string(x) + "," + to_string(y) + "]"; + return "[" + to_string(y) + "," + to_string(x) + "]"; } auto is_within_grid(State s1, State s2) const -> bool { - auto xmax = max(s1.x, s2.x); - auto xmin = min(s1.x, s2.x); auto ymax = max(s1.y, s2.y); auto ymin = min(s1.y, s2.y); + auto xmax = max(s1.x, s2.x); + auto xmin = min(s1.x, s2.x); return x >= xmin && x <= xmax && y >= ymin && y <= ymax; } @@ -57,14 +57,14 @@ namespace search { Goes() { - (*this)['1'] = [](State s) -> State { return{ s.x - 1, s.y - 1 }; }; - (*this)['2'] = [](State s) -> State { return{ s.x - 0, s.y - 1 }; }; - (*this)['3'] = [](State s) -> State { return{ s.x + 1, s.y - 1 }; }; - (*this)['4'] = [](State s) -> State { return{ s.x - 1, s.y - 0 }; }; - (*this)['5'] = [](State s) -> State { return{ s.x + 1, s.y + 0 }; }; - (*this)['6'] = [](State s) -> State { return{ s.x - 1, s.y + 1 }; }; - (*this)['7'] = [](State s) -> State { return{ s.x - 0, s.y + 1 }; }; - (*this)['8'] = [](State s) -> State { return{ s.x + 1, s.y + 1 }; }; + (*this)['1'] = [](State s) -> State { return{ s.y - 1, s.x - 1 }; }; + (*this)['2'] = [](State s) -> State { return{ s.y - 1, s.x - 0 }; }; + (*this)['3'] = [](State s) -> State { return{ s.y - 1, s.x + 1 }; }; + (*this)['4'] = [](State s) -> State { return{ s.y - 0, s.x - 1 }; }; + (*this)['5'] = [](State s) -> State { return{ s.y + 0, s.x + 1 }; }; + (*this)['6'] = [](State s) -> State { return{ s.y + 1, s.x - 1 }; }; + (*this)['7'] = [](State s) -> State { return{ s.y + 1, s.x - 0 }; }; + (*this)['8'] = [](State s) -> State { return{ s.y + 1, s.x + 1 }; }; } } const GOES; //