Starting and ending the program BCK.

This map computes the state n+1, in the case of a normal move, and in the case of a backtracking move.

In[342]:=

newstate[n_] := {n, n, n} ; newstate[p_, i_, Eview_, Aview_] := If[p"Eloise", {Eview, i, i}, {i, Aview, i}] ;

This map starts the game.

In[344]:=

BCKStart[A_] := CompoundExpression[(* Initializing data . *)Initialize ... uredTree[A, PosSign] ; (* Start . *)BCK[{A, PosSign}, 2, newstate[1]] ;] ;

This map start the game after checking that A is a well-formed formula.

In[345]:=

BCK[A_] := If[WF[A], BCKStart[A], Print[A, " is not a well-formed formula"]] ;

We allow another argument x for BCK[A]. x is either a string including game parameters, or a saved play (represented by list of moves). This is the map processing the new argument x of BCK, according if x is string or a list.

In[346]:=

(* If x is a string, we initialize parameters using options in x *) BCKArg[x_String] : ... 71;(* If x is a list, then x is a saved play *)BCKArg[x_List] := (GameInput = x) ;

We allow any number of new arguments. This is the map processing any list of arguments of BCK. Here, y__ represents any list x'_, x''_, ... of one or more arguments.

In[348]:=

BCKArg[x_, y__] := CompoundExpression[BCKArg[x], BCKArg[y]] ;

We first process all new arguments of BCK, then we compute BCK[A].

In[349]:=

BCK[A_, y__] := CompoundExpression[(* default value for game input *) GameInput = {} ;  BCKArg[y] ; BCK[A] ;] ;

This map ends the game.

In[350]:=

GameEnd[] := CompoundExpression[GameTitle["END OF THE PLAY", 24, 50], ᡝ ... is the list of all moves of the play:"], Print[MatrixForm[GameHistory]] ; ] ;

We add a counter for all moves from all plays. This counter is reset to 0 once, increased by 1 after each move. It is never reset to 0.

In[351]:=

movecounter = 0 ;


Created by Mathematica  (October 17, 2006)