本文整理汇总了Python中objects.Location.inCenterCenter方法的典型用法代码示例。如果您正苦于以下问题:Python Location.inCenterCenter方法的具体用法?Python Location.inCenterCenter怎么用?Python Location.inCenterCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类objects.Location
的用法示例。
在下文中一共展示了Location.inCenterCenter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: flipLocFilter
# 需要导入模块: from objects import Location [as 别名]
# 或者: from objects.Location import inCenterCenter [as 别名]
def flipLocFilter(self):
"""
Check where the goalie sees the ball and where we do.
Record if we're generally correct, or if our flipped location
is generally correct, or if neither one agrees with the goalie.
NOTE: ignore whenever the ball is in the middle 2x2 meter box.
"""
# Get goalie data
for mate in self.teamMembers:
if mate.isDefaultGoalie() and mate.active:
if mate.ballOn and self.ball.vis.on:
# calculate global ball coordinates
# note: assume goalie is in center of goal.
goalie_x = Constants.FIELD_WHITE_LEFT_SIDELINE_X
goalie_y = Constants.MIDFIELD_Y
ball_x = goalie_x + (mate.ballDist * math.cos(mate.ballBearing))
ball_y = goalie_y + (mate.ballDist * math.sin(mate.ballBearing))
goalie_ball_location = Location(ball_x, ball_y)
# check against my data
my_ball_location = Location(self.ball.x, self.ball.y)
flipped_ball_location = Location(Constants.FIELD_GREEN_WIDTH - self.ball.x,
Constants.FIELD_GREEN_HEIGHT - self.ball.y)
if (mate.ballDist < 250 and
self.loc.x > Constants.MIDFIELD_X and
self.ball.x > Constants.MIDFIELD_X):
# I'm probably flipped!
self.updateFlipFilters(-1)
print "Goalie saw the ball close, and I think I and it are far."
print "Goalie sees ball at: " + str(goalie_ball_location)
break
if (goalie_ball_location.inCenterCenter() or
my_ball_location.inCenterCenter()):
# Ball is too close to the middle of the field. Risky.
self.updateFlipFilters(0)
break
if my_ball_location.distTo(goalie_ball_location) < 70:
# I'm probably in the right place!
self.updateFlipFilters(1)
elif flipped_ball_location.distTo(goalie_ball_location) < 70:
# I'm probably flipped!
self.updateFlipFilters(-1)
else:
# I don't agree with the goalie. Ignore.
self.updateFlipFilters(0)
# If I've decided I should flip enough times, actually do it.
if (len(self.flipFilter) == 10 and
sum(self.flipFilter) > 6):
self.flipLoc()
# Reset filters! Don't want to flip again next frame.
self.noFlipFilter = []
self.flipFilter = []