Question: Write in Javascript //Perform depth-limited search from initial state, using defined is_goal_state //and find_successors functions //Will not examine paths longer than depth_limit (i.e. paths that
Write in Javascript
//Perform depth-limited search from initial state, using defined "is_goal_state" //and "find_successors" functions //Will not examine paths longer than "depth_limit" (i.e. paths that have "depth_limit" states in them, or "depth_limit-1" actions in them) //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 depth_limited_search(initial_state,depth_limit) {
/***Your code for depth-limited search here!***/ /***DO NOT do repeated state or loop checking!***/ /* Hint: You may implement DLS either iteratively (with open set) or recursively. In the iterative case, you will need to do similar to breadth-first search and augment the state. In addition to predecessor and action, you will also need to store depth. (You should be able to re-use your BFS code and only make a small amount of changes to accomplish this. Be sure to remove repeat checking!)
In the recursive case, you don't need the above. Building the solution path is a little trickier, but I suggest you look into the Array.unshift() function. */ }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
