本文整理汇总了Python中Board.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python Board.setValue方法的具体用法?Python Board.setValue怎么用?Python Board.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.setValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestValidationFunctions
# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
class TestValidationFunctions(unittest.TestCase):
def setUp(self):
self.board=Board()
#fill the board with values that will
#make for both valid and invalid situations
self.board.setValue(0,0,4)
self.board.setValue(4,0,7)
self.board.setValue(0,1,5)
def test_horizontal1(self):
self.assertTrue(self.board.horizontal_validation(0,6))
def test_horizontal2(self):
self.assertFalse(self.board.horizontal_validation(0,4))
def test_vertical1(self):
self.assertTrue(self.board.vertical_validation(0,9))
def test_vertical2(self):
self.assertFalse(self.board.vertical_validation(0,7))
def test_block1(self):
self.assertTrue(self.board.block_validation(2,2,7))
def test_block2(self):
self.assertFalse(self.board.block_validation(2,2,5))
def test_validation1(self):
self.assertTrue(self.board.validate(2,2,8))
def test_validation2(self):
self.assertFalse(self.board.validate(7,0,7))
示例2: read
# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
def read(self, config_file):
config=open("ConfigFiles/"+config_file)
board=Board()
row=0
col=0
for line in config:
for item in line:
if item !="\n":
if item != ".":
board.setValue(row,col,int(item))
col+=1
row+=1
col=0
return board
示例3: TestValidationFunctions
# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
class TestValidationFunctions(unittest.TestCase):
def setUp(self):
self.board=Board()
#fill the board with values that will
#make for both valid and invalid situations
self.board.setValue(0,0,4)
self.board.setValue(0,1,5)
def test_horizontal1(self):
self.assertTrue(self.board.horizontal_validation(0,6))
def test_horizontal2(self):
self.assertFalse(self.board.horizontal_validation(0,4))
示例4: TestBasicFunctions
# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
class TestBasicFunctions(unittest.TestCase):
# creates an empty board
def setUp(self):
self.board = Board()
# Ensures each slot in a fresh grid is occupied with None
def test_clear(self):
for row in range(9):
for col in range(9):
self.assertEqual(None, self.board.grid[row][col])
# Ensures that a value is added to a specific row,col
def test_add1(self):
self.board.setValue(1, 1, 4)
self.assertEqual(4, self.board.grid[1][1])
# Ensures that a value is added to a specific row,col
def test_add2(self):
self.board.setValue(7, 5, 4)
self.assertEqual(4, self.board.grid[7][5])
# Ensures that an added value is removed from the specific row,col
def test_remove1(self):
self.board.setValue(1, 1, 4)
self.assertEqual(4, self.board.grid[1][1])
# will remove and assert None
self.board.removeValue(1, 1)
self.assertEqual(None, self.board.grid[1][1])
# Ensures that an added value is removed from the specific row,col
def test_remove2(self):
self.board.setValue(7, 5, 4)
self.assertEqual(4, self.board.grid[7][5])
# will remove and assert None
self.board.removeValue(7, 5)
self.assertEqual(None, self.board.grid[7][5])