Exemple #1
0
	def __init__(self):
		self.path = [1,2,]
		self.clearpath = []
		self.x = 0
		self.y = 0
		self.lab = labyrinth()
		self.randomwalk = [self.goNorth(),self.goSouth(),self.goWest(),self.goEast()]
 def __create_labyrinth(self):
     correct_input = False
     size = self.__input_size()
     while not correct_input:
         try:
             labirent = labyrinth(size)
             correct_input = True
         except:
             print 'Please write size between 1-36'
             size = self.__input_size()
     self.is_labyrinth_generated = True
     return labirent
Exemple #3
0
 def __create_labyrinth(self):
     correct_input = False
     size = self.__input_size()
     while not correct_input:
         try:
             labirent = labyrinth(size)
             correct_input = True
         except:
             print 'Please write size between 1-36'
             size = self.__input_size()
     self.is_labyrinth_generated = True
     return labirent
Exemple #4
0
 def __init__(self):
     #Using sets to track visited, visited twice and unvisited nodes...
     self.visitedtwice = set([])
     self.visited = set([])
     self.unvisited = set([])
     self.intersection = []
     self.lab = labyrinth()
     self.graph = Graph()
     self.current = (0,0)
     self.visited.add(self.current)
     #... and stack to track intersection nodes
     if self._find_intersection():
         self.intersection.append(self.current)
Exemple #5
0
#!/usr/bin/env python
from labyrinth import labyrinth
from methods import search

engine = search()


def printPath(path):
    directions = {1: 'UP', 2: 'RIGHT', 3: 'DOWN', 4: 'LEFT'}
    print('[' + str.join(', ', map(lambda d: directions[d], path)) + ']')


lab = labyrinth(4)
lab.generate()
graph = lab.getGraph()

# '1:1' -> '10:10'
lab.show()
graph.show()

path = None
while (True):
    print('\nКакой метод поиска вы хотите использовать?')
    print("1 - поиск по градиенту\n" + "2 - поиск по глубине\n" +
          "3 - поиск по равным ценам\n" + "4 - поиск по ширине\n" +
          "0 - Остановить")
    num = input()
    num = int(num)
    if num >= 1 and num <= 4:
        lab.show()
    if num == 1: