Question: Write in Javascript //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

Write in Javascript

//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) {

var open = new FastPriorityQueue(function(a,b) { return a.estimated_total_cost < b.estimated_total_cost; });

var closed = new Set();

var 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!