# Searching
You are to write a search state class for the river crossing problem that will be used to solve the problem. The search algorithms are given to you, but you need to write the class that describes a state in the search space.
The river crossing problem, in this variant, involves a farmer who is trying to ferry a fox, a goat and a cabbage across a river. The farmer can only bring one of those things across the river at a time. The farmer can also cross the river without carrying anything.
The problem stems from the fact that the fox and goat cannot be left alone without the farmer and the goat and cabbage cannot be left alone without the farmer. How does the farmer ferry everything over without letting that happen?
You are to write a class that describes a state in the search space of this problem. A search state indicates which side of the river each item is on (including the farmer). A search state also needs a score indicating how close it seems to be to the solution (the heuristic).
You are given the skeleton of the class that uses booleans to indicate which side of the river each item is on. You need to write three methods:
calcScore() calculates the heuristic score and stores it in the score instance variable of the class. This score should simply be how many items are on the wrong side (remember lower scores are better).
generateNextStates() returns an ArrayList of SearchStates that should have all of the valid search states that can be reached from the current state. The farmer can cross the river (to either side) by himself or carrying one item. The item he is carrying must be on the same side the farmer is on. The farmer cannot leave the fox and goat alone or the goat and cabbage. Use the given helper method, isValid(), to test whether a given arrangement is valid. Only add valid search states to the ArrayList. Create the new search states using the constructor that takes an ancestor state. Return the ArrayList when you have added all of the valid states that can be reached from the current state.
isGoal() should return true if the current state is the goal state and false otherwise.
See the accompanying SlidePuzzle8.java file for an example of a search state class for another puzzle.
Sample Output:```Best-first Search:Found!States Generated:20 States Evaluated:10 Remaining Stack Size:10History (Size 7) :Farmer:Left Fox:Left Goat:Left Cabbage:LeftFarmer:Right Fox:Left Goat:Right Cabbage:LeftFarmer:Left Fox:Left Goat:Right Cabbage:LeftFarmer:Right Fox:Right Goat:Right Cabbage:LeftFarmer:Left Fox:Right Goat:Left Cabbage:LeftFarmer:Right Fox:Right Goat:Left Cabbage:RightFarmer:Left Fox:Right Goat:Left Cabbage:RightFarmer:Right Fox:Right Goat:Right Cabbage:Right```