本文整理汇总了Python中galaxySolver.Board类的典型用法代码示例。如果您正苦于以下问题:Python Board类的具体用法?Python Board怎么用?Python Board使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Board类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCellIsFilledByOnlyOneDotOnItsEdge
def testCellIsFilledByOnlyOneDotOnItsEdge(self):
b = Board(4, 4)
b.addDot(3, 2)
self.assertTrue(b.cellContainsDot(2, 2))
self.assertTrue(b.cellContainsDot(3, 1))
self.assertTrue(b.cellContainsDot(3, 3))
self.assertTrue(b.cellContainsDot(4, 1))
示例2: testFindConcavShape
def testFindConcavShape(self):
expected = set()
expected.add((1, 1))
expected.add((1, 3))
expected.add((1, 5))
expected.add((1, 7))
expected.add((3, 7))
expected.add((5, 7))
expected.add((7, 7))
expected.add((7, 5))
expected.add((7, 3))
expected.add((7, 1))
expected.add((5, 1))
expected.add((3, 1))
expected.add((1, 1))
b = Board(4,4)
b.addWall(2, 3)
b.addWall(2, 5)
b.addWall(3, 6)
b.addWall(5, 6)
b.addWall(6, 5)
b.addWall(6, 3)
b.addWall(5, 2)
b.addWall(3, 2)
self.assertEquals(expected, b.findShapeAroundCell(1, 1, set()))
self.assertEquals(expected, b.findShapeAroundCell(7, 7, set()))
示例3: testAdjacentCellsCentralWithWall
def testAdjacentCellsCentralWithWall(self):
b = Board(2, 2)
expected = set()
expected.add((3, 1))
b.addWall(1, 2)
b.addWall(3, 2)
self.assertEquals(expected, b.adjacentCells(1, 1))
示例4: testAdjacentCellsAsym
def testAdjacentCellsAsym(self):
b = Board(4, 4)
expected = set()
expected.add((7, 3))
expected.add((7, 7))
expected.add((5, 5))
self.assertEquals(expected, b.adjacentCells(7, 5))
示例5: testMonoCellShape
def testMonoCellShape(self):
expected = set()
expected.add((1, 1))
b = Board(2,2)
b.addWall(1, 2)
b.addWall(2, 1)
self.assertEquals(expected, b.findShapeAroundCell(1, 1, set()))
示例6: testCanPutDotOutOfBounds
def testCanPutDotOutOfBounds(self):
b = Board(2, 2)
self.assertFalse(b._canPutDot(-1, 0))
self.assertFalse(b._canPutDot(2, -1))
self.assertFalse(b._canPutDot(4, 0))
self.assertFalse(b._canPutDot(1, 4))
self.assertTrue(b._canPutDot(1, 2))
示例7: testOuterShapeSimple
def testOuterShapeSimple(self):
b = Board(4, 4)
cells = set()
cells.add((3, 3))
cells.add((3, 5))
cells.add((5, 3))
cells.add((5, 5))
b.addWall(2, 3)
b.addWall(2, 5)
b.addWall(3, 2)
b.addWall(3, 6)
b.addWall(5, 2)
b.addWall(5, 6)
b.addWall(6, 3)
b.addWall(6, 5)
walls = set()
walls.add((2, 3))
walls.add((2, 5))
walls.add((3, 2))
walls.add((3, 6))
walls.add((5, 2))
walls.add((5, 6))
walls.add((6, 3))
walls.add((6, 5))
resultWalls = b.findOuterWalls(cells)
self.assertEquals(walls, resultWalls)
示例8: testOuterShapeConcav
def testOuterShapeConcav(self):
b = Board(4, 4)
cells = set()
cells.add((1, 1))
cells.add((1, 3))
cells.add((1, 5))
cells.add((1, 7))
cells.add((3, 1))
cells.add((3, 7))
cells.add((5, 1))
cells.add((5, 7))
cells.add((7, 1))
cells.add((7, 3))
cells.add((7, 5))
cells.add((7, 7))
b.addWall(2, 3)
b.addWall(2, 5)
b.addWall(3, 2)
b.addWall(3, 6)
b.addWall(5, 2)
b.addWall(5, 6)
b.addWall(6, 3)
b.addWall(6, 5)
walls = set()
walls.add((2, 3))
walls.add((2, 5))
walls.add((3, 2))
walls.add((3, 6))
walls.add((5, 2))
walls.add((5, 6))
walls.add((6, 3))
walls.add((6, 5))
walls.add((0, 1))
walls.add((0, 3))
walls.add((0, 5))
walls.add((0, 7))
walls.add((1, 0))
walls.add((1, 8))
walls.add((3, 0))
walls.add((3, 8))
walls.add((5, 0))
walls.add((5, 8))
walls.add((7, 0))
walls.add((7, 8))
walls.add((8, 1))
walls.add((8, 3))
walls.add((8, 5))
walls.add((8, 7))
resultWalls = b.findOuterWalls(cells)
self.assertEquals(walls, resultWalls)
示例9: testShapeInEmptyBoard
def testShapeInEmptyBoard(self):
expected = set()
expected.add((1, 1))
expected.add((1, 3))
expected.add((3, 1))
expected.add((3, 3))
b = Board(2,2)
self.assertEquals(expected, b.findShapeAroundCell(1, 1, set()))
示例10: testEdgessAround00Cell
def testEdgessAround00Cell(self):
b = Board(4,4)
expected = set()
expected.add((0, 1))
expected.add((1, 0))
expected.add((2, 1))
expected.add((1, 2))
self.assertEquals(b.edgesAroundCell(1, 1), expected)
示例11: testmanathanDist
def testmanathanDist(self):
b = Board(4, 4)
self.assertEquals(b.manathanDistanceBetweenPoints(1, 1, 1, 1), 0)
self.assertEquals(b.manathanDistanceBetweenPoints(1, 1, 1, 2), 1)
self.assertEquals(b.manathanDistanceBetweenPoints(1, 1, 7, 7), 12)
self.assertEquals(b.manathanDistanceBetweenPoints(1, 1, 1, 7), 6)
self.assertEquals(b.manathanDistanceBetweenPoints(1, 1, 7, 1), 6)
self.assertEquals(b.manathanDistanceBetweenPoints(7, 1, 1, 1), 6)
示例12: testIsCellWithin
def testIsCellWithin(self):
b = Board(4, 4)
self.assertTrue(b.cellIsWithinBoard(0, 0))
self.assertTrue(b.cellIsWithinBoard(1, 1))
self.assertTrue(b.cellIsWithinBoard(2, 2))
self.assertTrue(b.cellIsWithinBoard(3, 3))
self.assertFalse(b.cellIsWithinBoard(-1, 1))
self.assertFalse(b.cellIsWithinBoard(1, 10))
示例13: testMinimalBoardDots
def testMinimalBoardDots(self):
expectedDots = []
expectedDots.append({"i":0, "j":0})
b = Board(2,2)
b.addDot(0,0)
i = 0
for d in b.dots():
self.assertEquals(d, expectedDots[i])
i = i + 1
示例14: testEmptyBoardCells
def testEmptyBoardCells(self):
expectedCells = []
expectedCells.append({"i":1, "j":1})
expectedCells.append({"i":1, "j":3})
expectedCells.append({"i":3, "j":1})
expectedCells.append({"i":3, "j":3})
b = Board(2,2)
i = 0
for c in b.cells():
self.assertEquals(c, expectedCells[i])
i = i + 1
示例15: testEdgesAroundAsymCell
def testEdgesAroundAsymCell(self):
b = Board(4,4)
expected = set()
expected.add((1, 0))
expected.add((0, 1))
expected.add((0, 3))
expected.add((1, 4))
expected.add((2, 3))
expected.add((2, 1))
result = b.edgesAroundCell(1, 2)
self.assertEquals(result, expected)
self.assertEquals(len(result), len(expected))