Courses/CS 460/Code Comments
From CSWiki
This pages discusses the Code on the website associated with Russell and Norvig.
If you have clarifying comments about how to use the code, please feel free to add them to this page.
[edit] Search
[edit] ReadMe wiki page
This page describes how to use the search framework. It describes what you have to do to run it with a new problem.
[edit] Seeing a trace of the states as well as the moves
As written, the code will display the steps taken from the starting point to a solution but not the intermediate states. To see the states through which a search passes, in aima.search.framework.Node initialize action as follows.
private String action = "Start";
Normally the action of a node is set when the node is created. At the start node, there is no "action". So action is not set, and the initial value "Start" remains.
Also modify aima.search.framework,searchUtils.actionsFromNodes() to be as follows
public static List<String> actionsFromNodes(List<Node> nodeList) { List<String> actionList = new ArrayList<String>(); for (Node node: nodeList) { actionList.add(node.getAction() + " ==>\n" + node.getState()); } return actionList; }
Instead of returning just a list of actions this will now return a list of actions followed by the state to which the action moves.
Then the output for Greedy Best First Search in aima.search.demos.EightPuzzleDemo will be as follows. (I also modified aima.search.eightpuzzleEightPuzzleBoard.toString() to print "_" instead of "0".)
EightPuzzleDemo Greedy Best First Search (MisplacedTileHeursitic)--> Start ==> 1 2 5 3 4 _ 6 7 8 Up ==> 1 2 _ 3 4 5 6 7 8 Left ==> 1 _ 2 3 4 5 6 7 8 Left ==> _ 1 2 3 4 5 6 7 8 pathCost : 3.0 nodesExpanded : 3 queueSize : 5 maxQueueSize : 6

