From b9f5fca9679061bbea3f27cee4c85e3756dd30af Mon Sep 17 00:00:00 2001 From: Luuk Date: Mon, 17 Jun 2024 11:22:46 +0200 Subject: [PATCH] We will not have ball when we both teams are close to the ball --- .../stp/evaluations/global/WeWillHaveBallGlobalEvaluation.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/roboteam_ai/src/stp/evaluations/global/WeWillHaveBallGlobalEvaluation.cpp b/roboteam_ai/src/stp/evaluations/global/WeWillHaveBallGlobalEvaluation.cpp index 8e6ba2333..60290a531 100644 --- a/roboteam_ai/src/stp/evaluations/global/WeWillHaveBallGlobalEvaluation.cpp +++ b/roboteam_ai/src/stp/evaluations/global/WeWillHaveBallGlobalEvaluation.cpp @@ -6,6 +6,7 @@ namespace rtt::ai::stp::evaluation { uint8_t WeWillHaveBallGlobalEvaluation::metricCheck(const world::World* world, const Field*) const noexcept { auto& us = world->getWorld()->getUs(); auto& them = world->getWorld()->getThem(); + auto ballPosition = world->getWorld()->getBall()->get()->position; // If the opponent has no robot, we will get the ball if (them.empty()) return constants::FUZZY_TRUE; @@ -13,6 +14,8 @@ uint8_t WeWillHaveBallGlobalEvaluation::metricCheck(const world::World* world, c // If we have no bots, we will not get the ball if (us.empty()) return constants::FUZZY_FALSE; + if (world->getWorld()->getRobotClosestToBall(world::them)->get()->getPos().dist(ballPosition) < constants::ROBOT_RADIUS * 1.3 && world->getWorld()->getRobotClosestToBall(world::us)->get()->getPos().dist(ballPosition) < constants::ROBOT_RADIUS * 1.3) return false; + // If any of our robots has the ball, we will get the ball if (std::any_of(us.begin(), us.end(), [](auto& robot) { return robot->hasBall(); })) return constants::FUZZY_TRUE;