Romania Map - Change Eforie to Constanza - Constanza to Tulcea = 169 - Hirsova to Tulcea = 98 - Tulcea(570,375) class Problem __init__(initial, goal=None) actions(state) - returns actions that can be executed in given state result(state,action) - new state goal_test(state) - are we there yet? path_cost(c, state1, action, state2) - cost of getting there, including current cost value(state) - for optimization problems class Node - a node in a search tree __init__(state, parent, action, path_cost) __repr__() __lt__(node) - comparison - overrides < expand(problem) - list of nearest reachable nodes child_node(problem, action) - generates next node solution() - sequence of actions to get to goal path() - list of nodes so far __eq__(node) - overrides == two nodes have the same state __hash__() class SimpleProblemSolvingAgentProgram __init__(initial_state) __call__(percept) - populate self.seq actions to get to goal update_state(state, percept) formulate_goal(state) search(problem) ### Uninformed Search Algorithms breadth_first_tree_search(problem) depth_first_tree_search(problem) depth_first_graph_search(problem) breadth_first_graph_search(problem) best_first_graph_search(problem, f) where f is the function to minimize uniform_cost_search(problem) depth_limited_search(problem, limit=50) iterative_deepening_search(problem) ### Bidirectional Search bidirectional_search(problem) - extend() - find_min() - find_key() ### Informed (Heuristic) Search greedy_best_first_graph_search = best_first_graph_search astar_search(problem, h=None) ### A* heuristics class EightPuzzle(Problem) __init__() find_blank_square() actions() result() goal_test() check_solvability() h() class PlanRoute(Problem) __init__() actions() result() goal_test() h() ### Other Search algorithms recursive_best_first_search() hill_climbing() exp_schedule() simulated_annealing() simulated_annealing_full() and_or_graph() class PeakFindingProblem() __initII() actions() result() value() class OnlineDFSAgent __init__() __call__() update_state() class OnlineSearchProblem(Problem) __init__() actions() output() h() c() update_state() goal_test() class LRTAStarAgent __init__() __call__() LRTA_cost() ### Genetic Algorithm genetic_search() genetic_algorithm() fitness_threshold() init_population() select() recombine() mutate() ############################################# class Graph __init__() make_undirected() connect() connect1() get() notes UndirectedGraph() RandomGraph() romania_map = UndirectedGraph(dict(...)) vacuum_world = Graph(dict(...)) one_dim_state_space = Graph(dict(...)) one_dim_state_space.least_costs = dict(...) australia_map = UndirectedGraph(dict(...)) austalia_map.locations class GraphProblem(Problem) __init__() actions() result() path_cost() find_min_edge() h() class GraphProblemStochastic(GraphProblem) result() path_cost() class NQueensProblem(Problem) __init__() actions() result() conflicted() conflict() goal_test() h() ## Inverse Boggle random_boggle() print_boggle() boggle_neighbors() exact_sqrt() class Wordlist __init__() lookup() __contains__() __len__() class BoggleFinder __init__() set_board() find() words() score() __len__() boggle_hill_climbing() mutate_boggle() ## compare searchers class InstrumentedProblem(Problem) __init__() actions() result() goal_test() path_cost() compare_searchers() compare_graph_searchers()