コード例 #1
0
import puzzle
import sys
import math

puzzleString = 3
puzzleArray = puzzleString.split(" ")
p = puzzle.TilePuzzle(int(math.sqrt(len(puzzleArray))))
p.readPuzzle(puzzleString)
p.parseMoveSequence(10)
print(p.checkPuzzle())
コード例 #2
0
ファイル: tilepuzzle.py プロジェクト: akeme/icomp8puzzle
# encoding: utf-8
# encoding: iso-8859-1
# encoding: win-1252

import puzzle 
import sys
import searches

#t=puzzle.TilePuzzle(int(sys.argv[1]))
#t.permute(int(sys.argv[2]))

t=puzzle.TilePuzzle(3)
num = int(raw_input("Qual a quantidade de permutacoes? "))
t.permute(num)

t.printPuzzle()
s=searches.Search(t)


print "Considerando Best First: ", s.bestFirst() 
print "Considerando Busca em Profundidade: ", s.iterativeDeepening()
print "Considerando Busca Gulosa 1: ", s.greedy(0)
print "Considerando Busca Gulosa 2: ", s.greedy(1)
print "Considerando A* 1:", s.aSearch(0)
print "Considerando A* 2:", s.aSearch(1)
コード例 #3
0
ファイル: BFSsearch.py プロジェクト: amazingclaude/8Puzzle
    else:
        return 0

def check_visited(lists,visited_nodes):
    if lists.puzzle in visited_nodes.values():
        return 1
    else:
        return 0

start=time.time()

i = 0
q = queue.Queue()  # define queue data structure
visited = 0

matrix = puzzle.TilePuzzle(int(3))
goal = copy.deepcopy(matrix.puzzle)

matrix.permute(int(3))  # the complexity of the initial state
initial = copy.deepcopy(matrix.puzzle)

matrix.printPuzzle()

print('\n')

print('Goal State:')
display(goal)
print('Initial State:')
display(initial)
print('the coordinate of Initial Zero is:', matrix.zero, '\n')
コード例 #4
0
import puzzle 
import sys
import searches

t=puzzle.TilePuzzle(int(sys.argv[1]))
t.permute(int(sys.argv[2]))
t.printPuzzle()
s=searches.Search(t)

print "Considering Best First:", s.bestFirst()
print "Considering Iterative Deepening Search:", s.iterativeDeepening()
print "Considering Greedy 1 Search:", s.greedy(0)
print "Considering Greedy 2 Search:", s.greedy(1)
print "Considering A* 1 Search:", s.aSearch(0)
print "Considering A* 2 Search:", s.aSearch(1)