Exemplo n.º 1
0
import random

initial = [(10,10),(20,20),(30,0),(30,40),(50,40)]



#X = (random.sample(range(1, 501), 200))
#Y = (random.sample(range(1, 501), 200))
#initial = []

#i = 0
#while i < len(X):
  #  initial.append((X[i],Y[i]))
   # i+= 1

print("PointList = %s" %(initial))


initialState = AntennaState(initial,200,1,time.time())



#initialState = AntennaState([(10,10),(20,20)],200,1)

solution = astar_search(initialState)


print("Solution  is %s  " % (solution))


Exemplo n.º 2
0
 def shortest_path(self, graph, intial, goal):
     self.goal_state = goal
     self.start_state = intial
     solution = astar_search(graph, self.hueristic_fn)
     #print(str(solution.path) + "hello123")
     return solution.path
Exemplo n.º 3
0
            for cell in row:
                if cell == 0:
                    return False
        return True


    def heuristic(self):
        a = self.emptyCells / 4
        b = self.emptyCells % 4
        if b == 0:
            return a
        elif b == 3:
            return a+2
        else:
            return a+1

    ### Private methods ####

    def _createGrid(self,dimX,dimY,obstacles):
        grid = [ [0 for y in range(dimY)] for x in range(dimX) ]
        for i in range(dimX):
            for j in range(dimY):
                if (i,j) in obstacles:
                    grid[i][j] = -1
        return grid



solution = astar_search(TileState((3,4),[(1,2)]))