Project 3
=========

<img align=left src="http://www.celebrities-galore.com/assets/styles/theme152/images/tools/numerology/number-3.jpg"
height=200>

In the this project you will semantics to the StageText language; specifically:
_sub-routines_ and _demons_.

<br clear=all>

Sub-routines
------------

+ The StageText graph will divide into N sub-graphs, one called main,
  and others called from main.

Example: 
        
+ Suppose the nodes in _main_ are "something old", "something new",
          "something burrow", "something blue". 
+ Suppose further you have a sub-graph called _acquire_
          that has nodes "beg", "burrow", or "steal"
+ Then _main_ could call _acquire_ four times (once for each of
		  _old,new,burrow,blue_ and _acquire_ could prompt the user 
		  for these items using the strategies _beg,burrow_ and, if all
		  else fails, _steal_ (e.g. print out, "look, over there, its Halley's
		  comet" and while they are distracted, teleport their wallet out
		  from the user's jeans).

Demons
------

An _Env_(ironment) variable will be added to the StateText interpreter
  that will carry around an updatable dictionary of values. To call a sub-graph:
     + Copy the _Env_
	 + Push some local variables onto _Env_ (to be used in the sub-graph)
	 + Pass the _Env_ to the sub-graph
	 
Each StageText node will have extra slots that test or  change the working memory:

+ _add_  : a list of items that this StateText adds to a working memory
            + Defaults to `nil`
+ _delete_ : a list of items items that this State will delete from working memory 
            + Defaults to `nil`.

### Node Demons

Using the above above, we will add the following
demons to each StageText node:

+ _OnEntry_ : code to be fired when first arriving at a node. Defaults to nil.
+ _OnExit_ : code to be fired when leaving a node. Defaults to nil.
+ _When_ : code to check that it is legal to enter this node.
         +  _Ok_ is an arbitrary combinations
            of _ands_, _ors_, _nots_ that query some working memory. 
	     + Defaults to `t`

### Edge Demons

Edges now alos have demons.

+ _If_ : code to check if this edge is currently relevant.
			
Note also that description text can contain arbitrary code in `(brackets}`
allowing for customization of the description text.

So a StateText node now looks like this

    SampleNode
    :when (have ('happy}}
    :onEntry (if (' trace} (say "what is going on?"))
    I am some description text about (who) want to do (what).
    > Beach :if (and (have (' time)) (not (have 'sand))) Surf's up dude?
