Representation of Search State Space and Search Operators
game of chess we can not possibly enumerate the search tree for all possible games of chess, so we define a successor node search operator that given a board position
represented by a node in the search tree calculates all possible moves for either the white or black pieces. The possible chess moves are calculated by a successor
node search operator and are represented by newly calculated nodes that are linked to the previous node. Note that even when it is simple to fully enumerate a search
tree, as in the game maze example, we still might want to generate the search tree dynamically as we will do in this chapter.
For calculating a search tree we use a graph. We will represent graphs as node with links between some of the nodes. For solving puzzles and for game related search,
we will represent positions in the search space with Java objects called nodes. Nodes contain arrays of references to both child and parent nodes. A search space using
this node representation can be viewed as a directed graph or a tree. The node that has no parent nodes is the root node and all nodes that have no child nodes a called
leaf nodes.
Search operators are used to move from one point in the search space to another. We deal with quantized search spaces in this chapter, but search spaces can also be
continuous in some applications. Often search spaces are either very large or are infinite. In these cases, we implicitly define a search space using some algorithm
for extending the space from our reference position in the space. Figure 2.1 shows representations of search space as both connected nodes in a graph and as a two-
dimensional grid with arrows indicating possible movement from a reference point denoted by R.
When we specify a search space as a two-dimensional array, search operators will move the point of reference in the search space from a specific grid location to
an adjoining grid location. For some applications, search operators are limited to moving updownleftright and in other applications operators can additionally move
the reference location diagonally.
When we specify a search space using node representation, search operators can move the reference point down to any child node or up to the parent node. For
search spaces that are represented implicitly, search operators are also responsible for determining legal child nodes, if any, from the reference point.
Note that I use different libraries for the maze and graph search examples.