本文整理汇总了Python中objects.Location类的典型用法代码示例。如果您正苦于以下问题:Python Location类的具体用法?Python Location怎么用?Python Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: notTowardOurGoal
def notTowardOurGoal(self, kick):
# do not kick into our goalbox
ball = self.brain.ball
inBox = (
ball.x > nogginC.GREEN_PAD_X
and ball.x < nogginC.BLUE_GOALBOX_RIGHT_X
and ball.y < nogginC.BLUE_GOALBOX_TOP_Y
and ball.y > nogginC.BLUE_GOALBOX_BOTTOM_Y
)
intoBox = (
kick.destinationX > nogginC.GREEN_PAD_X
and kick.destinationX < nogginC.BLUE_GOALBOX_RIGHT_X
and kick.destinationY < nogginC.BLUE_GOALBOX_TOP_Y
and kick.destinationY > nogginC.BLUE_GOALBOX_BOTTOM_Y
)
print "inBox returned"
if intoBox and not inBox:
return False
else:
goalCenter = Location(nogginC.FIELD_WHITE_LEFT_SIDELINE_X, nogginC.MIDFIELD_Y)
ball = Location(ball.x, ball.y)
kickDestination = Location(kick.destinationX, kick.destinationY)
return goalCenter.distTo(ball) < goalCenter.distTo(kickDestination)
示例2: searchFieldForSharedBall
def searchFieldForSharedBall(player):
"""
Searches the field for the shared ball.
"""
sharedball = Location(player.brain.sharedBall.x, player.brain.sharedBall.y)
if player.firstFrame():
player.brain.tracker.trackBall()
player.brain.tracker.repeatWideSnapPan()
player.sharedBallCloseCount = 0
player.sharedBallOffCount = 0
player.brain.nav.goTo(sharedball, precision = nav.GENERAL_AREA,
speed = speeds.SPEED_EIGHT, avoidObstacles = True,
fast = True, pb = False)
if sharedball.distTo(player.brain.loc) < 100:
player.sharedBallCloseCount += 1
else:
player.sharedBallCloseCount = 0
if not transitions.shouldFindSharedBall(player):
player.sharedBallOffCount += 1
else:
player.sharedBallOffCount = 0
player.brain.nav.updateDest(sharedball)
示例3: __init__
def __init__(self, visionBall):
Location.__init__(self, 0.0, 0.0)
self.vis = visionBall
(self.uncertX,
self.uncertY,
self.sd,
self.velX,
self.velY,
self.bearing,
self.dist,
self.uncertVelX,
self.uncertVelY,
self.heading,
self.locDist,
self.locBearing, # loc based
self.relX, # vision based
self.relY,
self.relVelX,
self.relVelY,
self.lastRelX,
self.lastRelY,
self.dx,
self.dy,
self.endY,
self.accX,
self.accY,
self.uncertAccX,
self.uncertAccY,
self.relAccX,
self.relAccY) = [0]*Constants.NUM_TOTAL_BALL_VALUES
示例4: determineChaseTime
def determineChaseTime(self):
"""
Attempt to define a time in seconds to get to the ball.
Can give penalties in certain situations.
@ return: returns a time in seconds with penalties.
Note: Don't give bonuses. It can result in negative chase times
which can screw up the math later on. --Wils (06/25/11)
"""
ballLocation = Location(self.brain.ball.x, self.brain.ball.y)
headingBallToGoal = ballLocation.headingTo(OPP_GOAL)
relLocToBall = RelRobotLocation(self.brain.ball.rel_x,
self.brain.ball.rel_y,
headingBallToGoal)
time = self.determineTimeToDest(relLocToBall)
# Give a penalty for not seeing the ball if we aren't in a kickingState
if (self.brain.ball.vis.frames_off > 45 and # TODO: unify this constant with shouldFindBall
not self.brain.player.inKickingState):
time += BALL_OFF_PENALTY
if DEBUG_DETERMINE_DEST_TIME:
print "\tChase time after ball on bonus " + str(time)
return time
示例5: pLeftDeepBack
def pLeftDeepBack(team, workingPlay):
"""position deep right back"""
workingPlay.setSubRole(PBConstants.LEFT_DEEP_BACK)
dest = Location(PBConstants.DEEP_BACK_X, PBConstants.LEFT_DEEP_BACK_Y)
h = dest.headingTo(team.brain.ball.loc)
pos = (PBConstants.DEEP_BACK_X, PBConstants.LEFT_DEEP_BACK_Y, h)
workingPlay.setPosition(pos)
示例6: obstacleAware
def obstacleAware(self, clearing=False):
motionKicksOnGoal = self.motionKicksAsapOnGoal()
if motionKicksOnGoal:
return motionKicksOnGoal
# if self.checkObstacle(1, 75):
# inScrum = self.motionKicksInScrumAsap()
# if inScrum:
# return inScrum
if not self.checkObstacle(1, 215) and not self.checkObstacle(1, 215) and not self.checkObstacle(8, 215):
goalCenter = Location(nogginC.FIELD_WHITE_RIGHT_SIDELINE_X, nogginC.MIDFIELD_Y)
ball = Location(self.brain.ball.x, self.brain.ball.y)
if ball.distTo(goalCenter) <= 400:
timeAndSpace = self.frontKicksOrbitIfSmall()
if timeAndSpace:
return timeAndSpace
elif clearing:
clear = self.frontKicksClear()
if clear:
return clear
asap = self.motionKicksAsap()
if asap:
return asap
return self.frontKickCrosses()
示例7: searchFieldForFlippedSharedBall
def searchFieldForFlippedSharedBall(player):
"""
Flips the shared ball and searches for it.
"""
sharedball = Location(-1*(player.brain.sharedBall.x-NogginConstants.MIDFIELD_X) + NogginConstants.MIDFIELD_X,
-1*(player.brain.sharedBall.y-NogginConstants.MIDFIELD_Y) + NogginConstants.MIDFIELD_Y)
if player.firstFrame():
player.brain.tracker.trackBall()
player.brain.tracker.repeatWideSnapPan()
player.sharedBallCloseCount = 0
player.brain.nav.goTo(sharedball, precision = nav.GENERAL_AREA,
speed = speeds.SPEED_EIGHT, avoidObstacles = True,
fast = True, pb = False)
if sharedball.distTo(player.brain.loc) < 100:
player.sharedBallCloseCount += 1
else:
player.sharedBallCloseCount = 0
if not transitions.shouldFindSharedBall(player):
player.sharedBallOffCount += 1
else:
player.sharedBallOffCount = 0
player.brain.nav.updateDest(sharedball)
示例8: pOffensiveMiddie
def pOffensiveMiddie(team, workingPlay):
workingPlay.setSubRole(PBConstants.OFFENSIVE_MIDDIE)
y = MyMath.clip(team.brain.ball.loc.y, PBConstants.MIN_MIDDIE_Y, PBConstants.MAX_MIDDIE_Y)
dest = Location(PBConstants.OFFENSIVE_MIDDIE_X, y)
h = dest.headingTo(team.brain.ball.loc)
pos = (PBConstants.OFFENSIVE_MIDDIE_X, y, h)
workingPlay.setPosition(pos)
示例9: pRightDeepBack
def pRightDeepBack(team, workingPlay):
"""position deep left back"""
workingPlay.setSubRole(PBConstants.RIGHT_DEEP_BACK)
dest = Location(PBConstants.DEEP_BACK_X,
PBConstants.RIGHT_DEEP_BACK_Y)
h = dest.headingTo(Location(team.brain.ball.x, team.brain.ball.y))
pos = (PBConstants.DEEP_BACK_X, PBConstants.RIGHT_DEEP_BACK_Y,h)
workingPlay.setPosition(pos)
示例10: pStopper
def pStopper(team, workingPlay):
"""position stopper"""
workingPlay.setSubRole(PBConstants.STOPPER)
x = PBConstants.STOPPER_X
y = MyMath.clip(team.brain.ball.loc.y, PBConstants.MIN_STOPPER_Y, PBConstants.MAX_STOPPER_Y)
dest = Location(x, y)
h = dest.headingTo(team.brain.ball.loc)
pos = (x, y, h)
workingPlay.setPosition(pos)
示例11: pDubDMiddie
def pDubDMiddie(team, workingPlay):
"""middie for when in dubD"""
workingPlay.setSubRole(PBConstants.DUB_D_MIDDIE)
y = MyMath.clip(team.brain.ball.loc.y, PBConstants.MIN_MIDDIE_Y, PBConstants.MAX_MIDDIE_Y)
x = PBConstants.OFFENSIVE_MIDDIE_X
dest = Location(x, y)
h = dest.headingTo(team.brain.ball.loc)
pos = (x, y, h)
workingPlay.setPosition(pos)
示例12: pPicker
def pPicker(team, workingPlay):
"""position picker"""
workingPlay.setSubRole(PBConstants.PICKER)
x = PBConstants.PICKER_X
y = PBConstants.PICKER_Y
dest = Location(x, y)
h = dest.headingTo(team.brain.ball.loc)
pos = (x,y,h)
workingPlay.setPosition(pos)
示例13: pSweeper
def pSweeper(team, workingPlay):
"""position sweeper"""
workingPlay.setSubRole(PBConstants.SWEEPER)
x = PBConstants.SWEEPER_X
y = PBConstants.SWEEPER_Y
y += PBConstants.SWEEPER_Y_OFFSET * MyMath.sign(team.brain.ball.loc.y - NogginConstants.CENTER_FIELD_Y)
dest = Location(x, y)
h = dest.headingTo(team.brain.ball.loc)
pos = (x, y, h)
workingPlay.setPosition(pos)
示例14: pGoalieSave
def pGoalieSave(team, workingPlay):
""" goalie saving """
workingPlay.setSubRole(PBConstants.GOALIE_SAVE)
dest = Location(PBConstants.GOALIE_HOME_X, PBConstants.GOALIE_HOME_Y)
h = dest.headingTo(team.brain.ball.loc)
pos = (PBConstants.GOALIE_HOME_X, PBConstants.GOALIE_HOME_Y, h)
if PBConstants.USE_FANCY_GOALIE:
pos = team.fancyGoaliePosition()
workingPlay.setPosition(pos)
示例15: pGoalieCenter
def pGoalieCenter(team, workingPlay):
"""normal goalie position in the center of the goal"""
workingPlay.setSubRole(PBConstants.GOALIE_CENTER)
dest = Location(PBConstants.GOALIE_HOME_X, PBConstants.GOALIE_HOME_Y)
h = dest.headingTo(team.brain.ball.loc)
pos = (PBConstants.GOALIE_HOME_X, PBConstants.GOALIE_HOME_Y, h)
if PBConstants.USE_FANCY_GOALIE:
pos = team.fancyGoaliePosition()
workingPlay.setPosition(pos)