本文整理汇总了Python中ship.Ship.is_empty方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.is_empty方法的具体用法?Python Ship.is_empty怎么用?Python Ship.is_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.is_empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestIsEmpty
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import is_empty [as 别名]
class TestIsEmpty(unittest.TestCase):
def setUp(self):
"""Set up a ship."""
self.ship0 = Ship({'p0': [(0, 0), (0, 1)]})
self.ship1 = Ship({})
def tearDown(self):
"""Clean up."""
self.ship = None
def testIsEmpty(self):
"""Test if the ship is empty."""
result = self.ship1.is_empty()
self.assertTrue(result)
def testIsNotEmpty(self):
"""Test if the ship is not empty."""
result = self.ship0.is_empty()
self.assertFalse(result)
示例2: auto_fill
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import is_empty [as 别名]
print "\n*****************PLAYER 2********************\n"
list_ships = auto_fill(player2_board)
print "\n*****************PLAYER 1********************\n"
second_ask(player1_board, player2_board, list_ships)
else:
print "\n*****************PLAYER 1********************\n"
list_ships = ask_ship(player1_board)
print "\n*****************PLAYER 2********************\n"
second_ask(player2_board, player1_board, list_ships)
player1_ships = Ship(player1_board.create_ship())
player2_ships = Ship(player2_board.create_ship())
player_shot2 = None
while (not player1_ships.is_empty()) and \
(not player2_ships.is_empty()):
print "\n*****************PLAYER 1******************************\n"
print 'Your board :'
print player1_board
print '\nOpponent board :'
print player2_board.opponent_view()
print '\n'
if type(player_shot2) == list:
sink.play()
print "your opponent sinked your %s" % \
(ship_dict[player_shot2[0][1]])
target1 = input("Player1, your target in tuple form please : ")
while type(target1) != tuple and (target1 not in \
player1_board.box):