Go backward to Using lookahead search.
Go up to Using lookahead search.
Go forward to Operator application.

State copying
-------------

In a lookahead search, the original state can not be used because it will be
destructively modified during the search, making additional lookahead
impossible.  Only by creating a copy of the state can the state be preserved.
In creating a copy, it is usually the case that a complete duplicate of the
original state is not necessary.  Only those aspects of the state that will
be modified need to be copied.  By augmenting the problem space with a
description of those aspects of the state that need to be copied, a set of
general copying productions can be used for many different tasks.  Without
this information, there would have to be domain-specific productions to
perform the copying.

To support the most common types of state representations, there are default
productions that will automatically create a copy of the top one or two
levels of the state (see Section See State copying for more details).  To
enable these productions, the original problem space should be augmented with
^default-state-copy yes.  For states that follow the guidelines described in
Section See State representation issues on page *Note State
representation issues::, all of the dynamic data, which can change through
operator application, is organized together as augmentations of the state in
the object-dynamic structures.

In order for the default productions to correctly copy a state, they must
know which aspects of the state must be copied and whether any substructure
must be copied.  If an attribute of the state has a value that can be copied
directly, it is called a one-level-attribute. The values of the
object-dynamic attributes can not be copied directly because their
substructure will be modified by operators in the lookahead.  Such an
attribute is called a two-level-attribute.  Instead, a new object-dynamic
structure must be created and all of the augmentations of the original
object-dynamic structures must be copied.  Although this is rather
complicated in general, for the state structure used in our example, all that
is necessary is to augment the problem space with ^default-state-copy yes and
^two-level-attributes object-dynamic as shown below:

(sp blocks-world*elaborate*problem-space*blocks-world
    (goal <g> ^name build-tower ^problem-space.name blocks-world)
    -->
    (<p> ^default-state-copy yes
         ^default-operator-copy no
         ^two-level-attributes object-dynamic + &))


This production also augments the problem space with
^default-operator-copy no.  As with states, it is possible for the lookahead search to add
augmentations to an operator when it is being instantiated for the state.
These augmentations may use values from the copied state instead of the
original, so that it is necessary to also create a copy of the operator.