本文整理汇总了Python中board.Board.fill方法的典型用法代码示例。如果您正苦于以下问题:Python Board.fill方法的具体用法?Python Board.fill怎么用?Python Board.fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类board.Board
的用法示例。
在下文中一共展示了Board.fill方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import fill [as 别名]
def main():
width = input("Enter WIDTH for your board >> ")
height = input("Enter HEIGHT for your board >> ")
boarD = Board(int(width), int(height))
boarD.NAME = input("Enter your name >> ")
boarD.fill()
while boarD.TIME > 0:
print_board(boarD)
x = input("enter X > ")
y = input("enter Y > ")
if "exit" in (x, y):
break
boarD.kill_the_group_for(int(x), int(y))
boarD.TIME -= 1
print(boarD.NAME + ": ", boarD.POINTS, "[ time:", boarD.TIME, "]")
boarD.save_classification()
print(' '*10, "END OF GAME!!!")
print("Points:", boarD.POINTS)
classification = boarD.classification()
count = 1
for elem in classification:
id, name, points = elem
print(count, "|", name, "|", points)
count += 1
示例2: main
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import fill [as 别名]
def main():
if len(sys.argv) <= 1:
print("Write username :)")
print("python3 start.py 'your_username'")
sys.exit(1)
username = sys.argv[1]
the_board = Board(10, 10)
the_board.fill()
示例3: BoardTest
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import fill [as 别名]
class BoardTest(unittest.TestCase):
def setUp(self):
self.boarD = Board(8, 3)
def test_start_all_positions(self):
answer = [
[None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None],
[None, None, None, None, None, None, None, None]
]
self.assertEqual(self.boarD.all_positions, answer)
def test_fill(self):
self.boarD.fill()
answer = len([[Ball(TypeBall.simple, 'red')] * 8] * 3)
self.assertEqual(len(self.boarD.all_positions), answer)
def test_fill_in(self):
self.boarD.fill()
answer = len(([[Ball(TypeBall.simple, 'red')] * 8] * 3)[1])
self.assertEqual(len(self.boarD.all_positions[0]), answer)
def test_is_not_valid_coords_False(self):
self.assertFalse(self.boarD._is_not_valid_coords(2, 7))
def test_is_not_valid_coords_True(self):
self.assertTrue(self.boarD._is_not_valid_coords(7, 2))
def test_neighbours_for(self):
self.boarD.fill()
neighbours = self.boarD.neighbours_for(2, 5)
answer = [ (1, 5), (2, 4), (2, 6)]
self.assertEqual(neighbours, set(answer))
def test_neighbours_for_1_1(self):
b = Board(5, 5)
b.fill()
neighbours = b.neighbours_for(1, 1)
answer = [(0, 1), (1, 0), (1, 2), (2, 1)]
self.assertEqual(neighbours, set(answer))
def test_neighbours_for_2_2(self):
b = Board(4, 3)
b.fill()
neighbours = b.neighbours_for(2, 2)
answer = {(1, 2), (2, 1), (2, 3)}
self.assertEqual(neighbours, answer)
示例4: test_neighbours_for_2_2
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import fill [as 别名]
def test_neighbours_for_2_2(self):
b = Board(4, 3)
b.fill()
neighbours = b.neighbours_for(2, 2)
answer = {(1, 2), (2, 1), (2, 3)}
self.assertEqual(neighbours, answer)
示例5: test_neighbours_for_1_1
# 需要导入模块: from board import Board [as 别名]
# 或者: from board.Board import fill [as 别名]
def test_neighbours_for_1_1(self):
b = Board(5, 5)
b.fill()
neighbours = b.neighbours_for(1, 1)
answer = [(0, 1), (1, 0), (1, 2), (2, 1)]
self.assertEqual(neighbours, set(answer))