home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1992-04-16 | 4.4 KB | 99 lines |
- DEFINITION MODULE header;
-
- (* This holds all the types, constants, and global variables to *)
- (* be used for the ataxx program. Everything must therefore explicit- *)
- (* ly import these types as needed. Data hiding is not used here, but *)
- (* the types are organized in a decent way. *)
-
-
- (****************************************)
- CONST
- (****************************************)
-
- boardsize = 7; (* Dimensions of the square playing area *)
-
- maxmovetypemoves = 200; (* Maximum number of moves in movetype *)
-
-
- (****************************************)
- TYPE
- (****************************************)
-
- squaretype = (empty, block, red, blue); (* All the possible states *)
- (* of a single square. *)
-
- playertype = [red..blue]; (* The players. *)
-
- boardrange = [-1..boardsize + 2]; (* Limits the values of the board *)
- (* locations. *)
-
- boardtype = ARRAY [-1..boardsize + 2], [-1..boardsize + 2] OF squaretype;
-
- histnodeptrtype = POINTER TO histnodetype; (* points of a history node *)
-
- histnodetype = RECORD (* Each node contains the board of *)
- board : boardtype; (* before the move, a pointer to *)
- turn : playertype; (* the node that shows the board *)
- previous : histnodeptrtype; (* before that move, after that *)
- next : histnodeptrtype; (* move (if any), and whose turn *)
- END; (* it was at that move. *)
-
- historytype = RECORD (* The main variable for a list of *)
- currentmove : histnodeptrtype; (* boards. They are strung out *)
- nummoves : CARDINAL; (* in reverse order (most recent *)
- END; (* is pointed at). *)
-
- statetype = RECORD (* This describes the current state *)
- board : boardtype; (* of the game: the status of all *)
- turn : playertype; (* the squares on the board, whose *)
- history : historytype; (* turn it is to move, and all the *)
- END; (* previous moves. *)
-
- movetype = RECORD (* This describes an actual move, *)
- fromX, toX, (* not a board position. *)
- fromY, toY : boardrange;
- END;
-
- allmovestype = RECORD (* Holds LOTS of moves! *)
- nummoves : CARDINAL;
- moves : ARRAY [1..maxmovetypemoves] OF movetype;
- END;
-
- pointercode = (RedCircle, BlueCircle, (* These are the codes for the *)
- RedPointer, BluePointer, (* possible pointers for the *)
- EmptySquare, BlockSquare, (* routine, ChangePointer in *)
- DefaultPointer); (* ataxxgraphics module. *)
-
- thinkertype = (human, computer); (* The two types of players. *)
-
- printmsgtype = (GameOver, Thinking); (* Message to print at top of *)
- (* screen. *)
-
- (****************************************)
- (* GLOBALS *)
- (****************************************)
-
- VAR
-
- state : statetype; (* Many things will access this. It *)
- (* describes the current state of the *)
- (* game. *)
-
- gameover : BOOLEAN; (* Indicates when the game is over (or *)
- (* that there are no more moves left *)
- (* to play). *)
-
- currentpointer : pointercode; (* which pointer is being displayed. *)
-
- difficulty : CARDINAL; (* This tells how nasty the compter is *)
- (* to play. 0 is easiest, and the *)
- (* higher the number, the harder! *)
-
- whoisred, (* These tell who is playing what *)
- whoisblue : thinkertype; (* color--human, or the computer. *)
-
- backedup : BOOLEAN; (* Is true when the player just backed *)
- (* up a move. *)
-
- END header.
-