Question: class State ( object ) : def _ _ init _ _ ( self , preceding _ action ) : Initialize the
class Stateobject:
def initself precedingaction:
Initialize the State object.
# each state MUST store the action that created it
# if you want to be able to actually see your solutions
self.action precedingaction
pass
def strself:
A string representation of the State
return
def eqself other:
Allows states to be compared"""
return False
class Problemobject:
The Problem class defines aspects of the problem.
One of the important definitions is the transition model for states.
To interact with search classes, the transition model is defined by:
isgoals: returns true if the state is a goal state.
actionss: returns a list of all legal actions in state s
resultsa: returns a new state, the result of doing action a in state s
def initself goal:
The problem is defined by a target value. We want to measure that many
liters of water.
:param goal: the number of liters of water we want to measure
self.goal goal
# INSERT WHATEVER ELSE YOU NEED HERE
def createinitialstateself:
returns an initial state
return None
def isgoalself astate:State:
Determine whether astate is a goal state"""
return False
def actionsself astate:State:
Returns all the actions that are legal in the given state.
return
def resultself astate:State, anaction:
Implements the transition function.
Given a state and an action, return the resulting state.
return None
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
