Question: Do in javascript // Complete the following two functions //Check if the given state is a goal state //Returns: true if is goal state, false

Do in javascript

// Complete the following two functions

//Check if the given state is a goal state //Returns: true if is goal state, false otherwise function is_goal_state(state) { ++helper_eval_state_count; //Keep track of how many states are evaluated (DO NOT REMOVE!) return /***Your code to check for goal state here!***/; }

//Find the list of actions that can be performed from the given state and the new //states that result from each of those actions //Returns: Array of successor objects (where each object has a valid actionID member and corresponding resultState member) function find_successors(state) { ++helper_expand_state_count; //Keep track of how many states are expanded (DO NOT REMOVE!) var successors=[];

/***Your code to generate successors here!***/

//Hint: Javascript objects are passed by reference, so don't modify "state" directy. //Make copies instead: // var newState={ // grid : state.grid.map(x => x.slice(0)) //Deep copy of grid // }; //Remember to make a new copy for each new state you make!

//Hint: Add new elements to the successor list like so: // successors.push({ // actionID : /*ID*/, // resultState : newState // });

return successors; }

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!