Ejemplo n.º 1
0
    def test_OR_function(self):

        # The output is implicitly set to true
        cond = solver.Conditions(a=False, b=True)
        cond.add(a=True, b=False)
        cond.add(a=True, b=True)

        solver.execute(self, start_sample.or_function, cond)
Ejemplo n.º 2
0
def do(myTime, start, stop):
    for x in range(start, stop):
        myFile = open("problems.txt", "r")
        string = myFile.readlines()[x]
        string = string[:-1]
        print(string)
        string = list(string)
        puzzle = convertor.ToList(string)
        puzzle, oldPuzzle, solved, timeTaken, d1, d2, steps = solver.execute(
            puzzle)

        print("")
        [print(i) for i in oldPuzzle]
        print("")
        [print(i) for i in puzzle]
        print("")
        print("SOLVED:", solved)
        print("problem", x + 1, "took", timeTaken, "seconds to solve")
        print("problem took", steps, "steps to solve")
        print("Sudoku's difficulty level for a human:", d1)
        print("Sudoku's difficulty level for a computer:", d2)
        print("")

        try:
            time.sleep(myTime)
        except:
            print("WARNING: THE INPUTED TIME INTERVAL DOESN'T WORK")
            time.sleep(3)
Ejemplo n.º 3
0
def execute():
    rows1 = generate(1)
    new = []
    for row in range(0, 9):
        new += rows1[row]
    print(new)
    import solver
    rows, oldRows, solved, timeTaken, d1, d2, steps = solver.execute(
        rows1, False)
    print("problem", "took", timeTaken, "seconds to solve")
    print("problem", "took", steps, "steps to solve")
    print("")
    print("Sudoku's difficulty level for a human:", d1)
    print("Sudoku's difficulty level for a computer:", d2)
    print("")
    if d1 == "insane":
        rows, pencil = pn.refresh(rows)
        for row in range(0, 9):
            for col in range(0, 9):
                if not pencil[row][col] == []:
                    oldRows[row][col] = rows1[row][col]
        rows, oldRows, solved, timeTaken, d1, d2, steps = solver.execute(
            oldRows, False)
        print("problem", "took", timeTaken, "seconds to solve")
        print("problem", "took", steps, "steps to solve")
        print("")
        print("Sudoku's difficulty level for a human:", d1)
        print("Sudoku's difficulty level for a computer:", d2)
        print("")
    for row in rows:
        print(row)
    if not d1 == "insane":
        return rows, oldRows
    else:
        rows, oldRows = execute()
        return rows, oldRows
Ejemplo n.º 4
0
				for col in range(0, 9):
					if not pencil[row][col] == "":
						renderText(pencil[row][col], "aharoni", 25, GREY, (537.5+(select.get_width()-8)*row, 91+(select.get_height()-8)*col), False)

		for event in pygame.event.get():
			if event.type == pygame.MOUSEBUTTONDOWN:
				#exit button
				if rect0.collidepoint(pygame.mouse.get_pos()):
					done = True
				#solve cell button
				if rect1.collidepoint(pygame.mouse.get_pos()):
					screen.blit(loading, (200,200))
					pygame.display.update()
					if puzzle == []:
						puzzle = copy.deepcopy(sPuzzle)
						puzzle, oldPuzzle, solved, timeTaken, d1, d2, steps = solver.execute(puzzle)
						sPuzzle[selectPos[0]][selectPos[1]] = puzzle[selectPos[0]][selectPos[1]]
						opened = True
					else:
						sPuzzle[selectPos[0]][selectPos[1]] = puzzle[selectPos[0]][selectPos[1]]
				#solve puzzle button
				if rect2.collidepoint(pygame.mouse.get_pos()):
					screen.blit(loading, (200,200))
					pygame.display.update()
					if puzzle == []:
						sPuzzle, oldPuzzle, solved, timeTaken, d1, d2, steps = solver.execute(sPuzzle)
						opened = True
					else:
						sPuzzle = copy.deepcopy(puzzle)
					sPuzzle, rawPencil = pn.refresh(sPuzzle)
					pencil = []
Ejemplo n.º 5
0
    def test_AND_3_VARIABLES_function(self):

        cond = solver.Conditions(a=True, b=True, c=True)
        solver.execute(self, start_sample.and_function_3_variables, cond)
Ejemplo n.º 6
0
    def test_XOR_function(self):

        cond = solver.Conditions(a=False, b=True)
        cond.add(a=True, b=False)

        solver.execute(self, start_sample.xor_function, cond)
Ejemplo n.º 7
0
    def test_AND_function(self):

        # The output is explicitly set to true
        cond = solver.Conditions(a=True, b=True, output=True)
        solver.execute(self, start_sample.and_function, cond)