Esempio n. 1
0
def main():
    """
    Do whatever you want in here; this is for you.
    The examples below shows how your functions might be used.
    """

    # initialize a random transition array of length 8

    import time
    t = time.time()
    ta = TArray(9)
    # compute path using bfs
    #bfs_path = bfs(ta)
    #print(len(bfs_path))
    #print(time.time() - t)
    #t = time.time()
    #ta = TileGame(3)
    #pathAStar = astar(ta, tilegame_heuristic)
    #print("Path of A star")
    #TArray.print_path(pathAStar)
    #print(len(pathAStar))
    # display path

    pathBfs = bfs(ta)
    print("Path of BFS")
    TArray.print_path(pathBfs)

    #pathDfs = dfs(ta)
    #print("Path of dFS")
    #TArray.print_path(pathDfs)
    #print(time.time() - t)

    #pathIds = ids(ta)
    #print("Path of IDS")
    #TArray.print_path(pathIds)
    #print(time.time() - t)

    goal_state = (0, 1, 2, 3, 4, 5, 6, 7, 8)
    pathBds = bds(ta, goal_state)
    print("Path of BDS")
    TArray.print_path(pathBds)
    print(time.time() - t)

    # initialize a random 3x3 TileGame problem
    #simple_problem = ((1,2,3),(4,5,6),(7,8,9))
    goal_state = ((1, 2, 3), (4, 5, 6), (7, 8, 9))
    tg = TileGame(3)
    path = astar(tg, tilegame_heuristic)
    TileGame.print_pretty_path(path)
Esempio n. 2
0
def main():
    """
	Do whatever you want in here; this is for you.
	An example below shows how your functions might be used.
	"""
    # sys.setrecursionlimit(100000)
    # initialize a random 3x3 TileGame problem
    tg = TileGame(3)
    # print(TileGame.board_to_pretty_string(tg.get_start_state()))
    # compute path
    # path = bfs(tg)
    # path = dfs(tg)
    # path = ids(tg)
    path = bds(tg, ((1, 2, 3), (4, 5, 6), (7, 8, 9)))
    # path = bds(tg, ((1,2),(3,4)))
    # path = astar(tg, tilegame_heuristic)
    # display path
    TileGame.print_pretty_path(path)
    print(len(path))

    # an example with DGraphs:
    small_dgraph = DGraph([[None, 1], [1, None]], {1})
    print(bfs(small_dgraph))
Esempio n. 3
0
def main():
    """
  Do whatever you want in here; this is for you.
  An example below shows how your functions might be used.
  """
    # initialize a random 3x3 TileGame problem
    tg = TileGame(3)
    print TileGame.board_to_pretty_string(tg.get_start_state())
    # compute path
    # path1 = bfs(tg)
    # print len(path1)
    # path2 = ids(tg)
    # print len(path2)
    # path3 = bds(tg, tg.goal_state)
    # print len(path3)
    path4 = astar(tg, tilegame_heuristic)
    # display path
    TileGame.print_pretty_path(path4)
    print len(path4)

    # an example with DGraphs:
    small_dgraph = DGraph([[None, None, 1], [1, None, 1], [1, 1, None]], {1})
    print ids(small_dgraph)