本文整理汇总了Python中ship.Ship.random_ship方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.random_ship方法的具体用法?Python Ship.random_ship怎么用?Python Ship.random_ship使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.random_ship方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_ships
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import random_ship [as 别名]
def generate_ships():
"""This generates ships non-strategically for testing purposes."""
# Let's get some ships
ships = []
ships.append(Ship("M", 5, 5, "H"))
ships.append(Ship.random_ship("D"))
ships.append(Ship.random_ship("D"))
ships.append(Ship.random_ship("P"))
ships.append(Ship.random_ship("P"))
return ships
示例2: setup
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import random_ship [as 别名]
def setup(self):
print "Init ships"
ships = []
main_ship = Ship.random_ship("M")
for i in range (8):
temp_ship = Ship.random_ship("D")
while not self.ship_space_free(temp_ship):
temp_ship = Ship.random_ship("D")
ships.append(temp_ship)
for i in range(10):
temp_ship = Ship.random_ship("P")
while not self.ship_space_free(temp_ship):
temp_ship = Ship.random_ship("P")
ships.append(temp_ship)
return (main_ship, ships)