DEFINITION MODULE thinker; (*$R-V-*) (* Range checking OFF, overflow checking OFF *) (* The Thinker! This is the meat and potatoes of Attacks. Here is *) (* where the computer does all of its thinking. This is also where the *) (* most improvements can be made to the program. EvalMove is the routine *) (* that assigns a value to a given board. It works recursively. Check *) (* it out. It's easily the most complex and sophisticated procedure I've *) (* ever written (that's saying a lot for a CS grad from UT). But I think *) (* it's still understandable. *) FROM header IMPORT movetype, boardtype, playertype; (************************************************************************) PROCEDURE OtherPlayer (player : playertype) : playertype; (* Simply returns the other player *) (************************************************************************) PROCEDURE LegalMove (move : movetype) : BOOLEAN; (* This simply checks to see if the given move is a valid move, con- *) (* sidering the current state of the game. It is NOT assumed that *) (* the initial component of the move is valid. It does NOT assume *) (* both of the move components are valid locations. But it does as- *) (* sume that the board has been properly initialized so that the outer *) (* edges are blocks. It operates using the global variable, state. *) (********************************************************) PROCEDURE GoodMovePossible (board : boardtype; player : playertype) : BOOLEAN; (* This procedure returns TRUE only if on the given board, player has *) (* has a legal move available. It returns FALSE otherwise. *) (***********************************************************************) PROCEDURE DoMove (move : movetype) : BOOLEAN; (* This does the necessary changes to facilitate a move in the *) (* game. It involves, finding out if the piece grows or jumps, alter- *) (* ing the board to reflect this, update the history, and change the *) (* graphics. Lastly, don't forget to change the player's turn! Oh *) (* yeah, I did in fact forget. Change the colors of all the opponents *) (* who are adjacent to the new blob! *) (* This routine returns TRUE if there's a move available. It *) (* will return FALSE when the game is over. *) (**************************************************************************) PROCEDURE DoComputerMove() : BOOLEAN; (* This is the computer equivalent of the procedure, DoMove. It exe- *) (* cutes a computer's move, assuming that the computer already has a le- *) (* gitate move possible. It utilizes the global variable, state. Also *) (* note that this assumes that the current turn is the computer's turn. *) (* It's up to the caller to make sure that it is indeed time to play the *) (* computer. *) (* *) (* INPUT *) (* n/a *) (* *) (* OUTPUT *) (* The state and the screen will be changed to reflect the *) (* move execute by the computer. *) END thinker.