Skip to content

Commit

Permalink
We will not have ball when we both teams are close to the ball
Browse files Browse the repository at this point in the history
  • Loading branch information
Luuk committed Jun 17, 2024
1 parent 1fd0ade commit b9f5fca
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ 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;

// 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;

Expand Down

0 comments on commit b9f5fca

Please sign in to comment.