Esempio n. 1
0
	def getMapOfBlocksNotLinked(self, solution, ways: list = []):
		solver = Solve(Board.parse(TestLinks1))
		solver.Ways = ways

		linkingMap = solver.getMapOfBlocksNotLinked()
		for y in range(len(linkingMap)):
			for x in range(len(linkingMap[0])):
				self.assertEqual(
					linkingMap[y][x],
					solution[y][x],
					"Block on x:{} and y:{} is {}".format(
						x,
						y,
						"not linked" if solution[y][x] else "linked"
					)
				)
Esempio n. 2
0
	def test_checkOnlyOneMove_withWays(self):
		board = Board.parse(TestLinks1)
		solver = Solve(board)
		solver.Ways = [
			[(2,1), (0,1), (0,2)],
			[(3,1), (1,3)]
		]
		solver.checkOnlyOneMove()
		self.assertEqual(
			sorted(tuple( tuple(line) for line in solver.checkOnlyOneMove() )),
			sorted((
				((2,3), (3,2)),
				((1,3), (1,2)),
				((2,2), (2,3))
			))
		)
Esempio n. 3
0
	def test_commitWay(self):
		board = Board.parse(TestLinks1)
		solver = Solve(Board.parse(TestLinks1))
		solver.Ways = [
			[(2,0), (2,1), (0,1)],
			[(2,3), (3,2), (3,1)],
		]
		solver.commitWay(solver.Ways[0])
		solver.commitWay(solver.Ways[1])
		board._map[1][2].Value = 5
		board._map[3][2].Value = 9
		board._map[2][3].Value = 10

		self.assertEqual(
			solver.Board.getValuesMatrix(),
			board.getValuesMatrix()
		)
Esempio n. 4
0
	def test_addConnectionPointsToWays_withWays(self):
		board = Board.parse(TestLinks1)
		solver = Solve(board)
		points = [
			[(1,2), (1,1)],
			[(0,1), (2,2)],
			[(3,3), (2,0)],
		]
		solver.Ways = [
			[(1,3), (2,3), (1,0), (0,1)],
			[(3,0), (3,1), (3,2), (3,3)]
		]
		solver.addConnectionPointsToWays(points)
		self.assertEqual(
			solver.Ways,
			[
				[(1,3), (2,3), (1,0), (0,1), (2,2)],
				[(3,0), (3,1), (3,2), (3,3), (2,0)],
				[(1,2), (1,1)]
			]
		)