diff --git a/demo/include/demo/environment_model.hpp b/demo/include/demo/environment_model.hpp index 52ab3961..d59ccada 100644 --- a/demo/include/demo/environment_model.hpp +++ b/demo/include/demo/environment_model.hpp @@ -103,6 +103,9 @@ class EnvironmentModel { bool isWall(const Position& position) const { return maze_->isWall(position); } + Position positionConsideringTunnel(const Position& position) const { + return maze_->positionConsideringTunnel(position); + } protected: void updateEntities(const entt::Registry& registry); diff --git a/demo/src/avoid_ghost_behavior.cpp b/demo/src/avoid_ghost_behavior.cpp index 067add06..bbf80017 100644 --- a/demo/src/avoid_ghost_behavior.cpp +++ b/demo/src/avoid_ghost_behavior.cpp @@ -10,7 +10,7 @@ Command AvoidGhostBehavior::getCommand(const Time& time) { double maxDistance = -1; for (const auto& move : Move::possibleMoves()) { - auto nextPosition = pacmanPosition + move.deltaPosition; + auto nextPosition = environmentModel_->positionConsideringTunnel(pacmanPosition + move.deltaPosition); if (environmentModel_->isWall(nextPosition)) { continue; diff --git a/demo/src/chase_ghost_behavior.cpp b/demo/src/chase_ghost_behavior.cpp index 2a15e19b..907162ad 100644 --- a/demo/src/chase_ghost_behavior.cpp +++ b/demo/src/chase_ghost_behavior.cpp @@ -15,7 +15,7 @@ Command ChaseGhostBehavior::getCommand(const Time& time) { double minDistance = std::numeric_limits::max(); for (const auto& move : Move::possibleMoves()) { - auto nextPosition = pacmanPosition + move.deltaPosition; + auto nextPosition = environmentModel_->positionConsideringTunnel(pacmanPosition + move.deltaPosition); if (environmentModel_->isWall(nextPosition)) { continue;