def closestToTeamBall(): teamBall = blackboard.localisation.teamBall if teamBall.contributors == 0: return False myPos = blackboard.localisation.robotPos turnAngle = abs(FieldGeometry.angleToTeamBallToGoal(teamBall.pos, myPos)) myDist = math.hypot(teamBall.pos.x - myPos.x, teamBall.pos.y - myPos.y) + turnAngle*(1000.0/math.pi) otherDist = minWeightedDistanceToTeamBall()[0] return myDist < (otherDist * 1.4)
def closestToTeamBall(): teamBall = blackboard.localisation.teamBall if teamBall.contributors == 0: return False myPos = blackboard.localisation.robotPos turnAngle = abs(FieldGeometry.angleToTeamBallToGoal(teamBall.pos, myPos)) myDist = math.hypot(teamBall.pos.x - myPos.x, teamBall.pos.y - myPos.y) + turnAngle * (1000.0 / math.pi) otherDist = minWeightedDistanceToTeamBall()[0] return myDist < (otherDist * 1.4)
def minWeightedDistanceToTeamBall(): incapacitated = blackboard.receiver.incapacitated minDist = robot.FULL_FIELD_LENGTH minDistPlayer = blackboard.gameController.player_number teamData = blackboard.receiver.data teamBallPos = blackboard.localisation.teamBall.pos for i in xrange(robot.ROBOTS_PER_TEAM): robotPos = teamData[i].robotPos lostCount = teamData[i].lostCount if (i+1) != blackboard.gameController.player_number and not incapacitated[i] and i+1 != 1: if not math.isnan(robotPos.x): turnAngle = abs(FieldGeometry.angleToTeamBallToGoal(teamBallPos, robotPos)) weightedDist = math.hypot(teamBallPos.x - robotPos.x, teamBallPos.y - robotPos.y) + turnAngle*(1000.0/math.pi) if weightedDist < minDist: minDist = weightedDist minDistPlayer = i+1 return minDist, minDistPlayer
def minWeightedDistanceToTeamBall(): incapacitated = blackboard.receiver.incapacitated minDist = robot.FULL_FIELD_LENGTH minDistPlayer = blackboard.gameController.player_number teamData = blackboard.receiver.data teamBallPos = blackboard.localisation.teamBall.pos for i in xrange(robot.ROBOTS_PER_TEAM): robotPos = teamData[i].robotPos lostCount = teamData[i].lostCount if (i + 1 ) != blackboard.gameController.player_number and not incapacitated[ i] and i + 1 != 1: if not math.isnan(robotPos.x): turnAngle = abs( FieldGeometry.angleToTeamBallToGoal(teamBallPos, robotPos)) weightedDist = math.hypot( teamBallPos.x - robotPos.x, teamBallPos.y - robotPos.y) + turnAngle * (1000.0 / math.pi) if weightedDist < minDist: minDist = weightedDist minDistPlayer = i + 1 return minDist, minDistPlayer