Question
//Perform breadth-first search from initial state, using defined is_goal_state and find_successors functions //Returns: null if no goal state found //Returns: object with two members, actions
//Perform breadth-first search from initial state, using defined "is_goal_state" and "find_successors" functions
//Returns: null if no goal state found
//Returns: object with two members, "actions" and "states", where:
// actions: Sequence(Array) of action ids required to reach the goal state from the initial state
// states: Sequence(Array) of states that are moved through, ending with the reached goal state (and EXCLUDING the initial state)
// The actions and states arrays should both have the same length.
function astar_search(initial_state) {
let open = new FastPriorityQueue(function(a,b) { return a.estimated_total_cost < b.estimated_total_cost; });
let closed = new Set();
let fixed_step_cost = 1; //Assume action cost is constant
/***Your code for A* search here***/
/* Hint: A* is very similar to BFS, you should only need to make a few small modifications to your BFS code. You will need to add values to your augmented state for path cost and estimated total cost. I suggest you use the member name "estimated_total_cost" so that the above priority queue code will work. Call function calculate_heuristic(state) (provided for you) to calculate the heuristic value for you. See (included) FastPriorityQueue.js for priority queue usage example. */
//No solution found
return null;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started