- Actions are an enumerated type defined in
Actions.hh
- be sure to include Actions.hh in the State
class definition
- Percepts are Percept Objects
- use methods in Percept.hh and Percept.cc
- be sure to include Percept.hh in the State
class definition
- Objects are an enumerated type defined in
ObjectTypes.hh
- be sure to include ObjectTypes.hh in the
State class definition
- Actor States (i.e., DEAD, ALIVE,
VICTORIOUS) are an enumerated type
defined in ActorStates.hh
- be sure to include ActorStates.hh in the
State class definition
Available Information
- The Player class provides Percepts and
Actions
- PerceptDLList perceptList;
- ActionDLList actionList;
- The Agent's state
- The number of Gold pieces held
- The number of Arrows the Agent has
- The Agent's score
What's not available
- Locations and orientations
Code for determining the new location and
orientation from: the old location and orientation,
and the current action.
void State::move(Action action)
{
switch ( action)
{
case TURN_LEFT:
switch ( currentOrientation )
{
case UP: currentOrientation = LEFT;
break;
case DOWN: currentOrientation = RIGHT;
break;
case LEFT: currentOrientation = DOWN;
break;
case RIGHT: currentOrientation = UP; break;
}
break;
case TURN_RIGHT:
switch ( currentOrientation )
{
case UP: currentOrientation = RIGHT;
break;
case DOWN: currentOrientation = LEFT;
break;
case LEFT: currentOrientation = UP;
break;
case RIGHT: currentOrientation = DOWN; break;
}
break;
case GOFORWARD:
if (isValid(currentLocation +
currentOrientation))
{
currentLocation=(currentLocation +
currentOrientation);
}
break;
}
}
int State::isValid(Point location)
{
if(location.x() >= 0 && location.y() >= 0)
return 1;
else
return 0;
}
Chapter 4: Informed search methods
Informed search methods
- In many domains we can estimate the goodness of a node and use this to guide our search.
- We can use an evaluation function that returns a number representing the desirability of expanding that node.
- When nodes are ordered (in the queue) so that the one with the best evaluation is expanded first (is at the front of the queue) the resulting search strategy is best-first search
Best-first search
- So far we have only used path cost as a measure of goodness; now explore the idea of guessing how good the node is in terms of how close it is to the goal state (as opposed to how it is far from the start --- path cost); the best or closest node is then expanded first
- “best-first” is a misnomer; don’t know what is “best”; we look at different kinds of guesses, or heuristics
Heuristics
- In search, a heuristic is a function that provides an estimate of the solution cost from the current node
- Examples:
- Missionaries and cannibals: the number of people on the left bank
- 8-puzzle: the number of tiles out of place
- travel routes: the straight line distance to the destination