本文整理汇总了Python中field.Field.kind方法的典型用法代码示例。如果您正苦于以下问题:Python Field.kind方法的具体用法?Python Field.kind怎么用?Python Field.kind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类field.Field
的用法示例。
在下文中一共展示了Field.kind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tick
# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import kind [as 别名]
def tick(self, time_diff):
"""Some time has passed; decide what to do next."""
mytanks, othertanks, flags, shots = self.bzrc.get_lots_o_stuff()
self.mytanks = mytanks
self.flags = flags
# We only care about our enemy's flag
enemy_flag = None
for flag in self.flags:
# print("flag color: %s x: %f y: %f" % (flag.color, flag.x, flag.y))
if flag.color == self.enemy:
# print("enemy found, and it is %s" % flag.color)
enemy_flag = flag
# Flag is the goal, so it creates an attractive field
obstacles = self.bzrc.get_obstacles()
fields = self.repulsive_and_tangential_fields_from_obstacles(obstacles)
# fields = []
attractive_field = Field(enemy_flag.x, enemy_flag.y, 5, 300)
attractive_field.kind = 'attractive'
for tank in self.mytanks:
# print("tank angle is %f x is %f y is %f" % (tank.angle, tank.x, tank.y))
#if this tank has the flag, then its attractive field is the home base
if tank.flag == self.enemy:
attractive_field = Field((self.base.corner1_x + self.base.corner3_x) / 2.0, (self.base.corner1_y + self.base.corner3_y) / 2.0, 5, 300)
attractive_field.kind = 'attractive'
fields.append(attractive_field)
self.bzrc.angvel(tank.index, self.calculate_angvel(tank, fields))
#speed depends on how far away we are?
#just ignore that for now, see if it works.
self.bzrc.speed(tank.index, self.calculate_speed(tank, fields))
self.bzrc.shoot(tank.index)
示例2: repulsive_and_tangential_fields_from_obstacles
# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import kind [as 别名]
def repulsive_and_tangential_fields_from_obstacles(self, obstacles):
fields = []
for obstacle in obstacles:
centroid = self.calculate_centroid(obstacle)
radius = self.calculate_radius_from_centroid(centroid, obstacle)
field = Field(centroid['x'], centroid['y'], radius, 100)
field.kind = 'repulsive'
fields.append(field)
tan_field = Field(centroid['x'], centroid['y'], radius, 100)
tan_field.kind = 'tangential'
fields.append(tan_field)
return fields