[comp.sources.games] v01i044: othello1 - othello game in Modula-II, Part02/02

games-request@tekred.TEK.COM (06/09/87)

Submitted by: cwruecmp!rsilvers@hawk.CS.Ulowell.Edu (Robert Silvers)
Comp.sources.games: Volume 1, Issue 44
Archive-name: othello1/Part02

	[As I said in Part01, I have no way to try this, so you're
	 on your own.   -br]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 2)."
# Contents:  InOutExtensions.def move.def othello.def regis.def
#   types.mod
# Wrapped by billr@tekred on Mon Jun  8 13:58:02 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f InOutExtensions.def -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"InOutExtensions.def\"
else
echo shar: Extracting \"InOutExtensions.def\" \(2406 characters\)
sed "s/^X//" >InOutExtensions.def <<'END_OF_InOutExtensions.def'
XDEFINITION MODULE InOutExtensions ;
X
X(* written by 		   *)
X(*    Jesse M. Heines	   *)
X(*    University of Lowell *)
X
X(* Version 1.2     1/28/87 *)
X
X
X
XEXPORT QUALIFIED
X   GetEscapeSequence, GetOneChar, ReadLn, ReadLine, WriteFormattedReal ;
X
X
X
XPROCEDURE GetEscapeSequence
X   (VAR c : ARRAY OF CHAR ) ;   (* characters read from the terminal *)
X
X(* This procedure is designed to read as escape sequnce from the terminal   *)
X(* without waiting for the user to press RETURN.  It begins by reading a    *)
X(* single from the terminal.  If the character read is ESCape, a second     *)
X(* character is read.  If the second characters is '[', a third character   *)
X(* is read.  Any characters not read are set to 0C.                         *)
X
X
XPROCEDURE GetOneChar
X   (VAR c : CHAR ) ;   (* character read from terminal *)
X
X(* This procedure gets a single character from the terminal without *)
X(* waiting for the user to press RETURN.                            *)
X
X
XPROCEDURE ReadLn ;
X
X(* This procedure reads data from the current input stream until an end  *)
X(* of line character (EOL), a null character (0C), or a CTRL/D character *)
X(* (4C) is read.  The data read is not saved.  The purpose of this       *)
X(* procedure is to skip the rest of the current line to prepare for      *)
X(* reading the next line of input.                                       *)
X
X
XPROCEDURE ReadLine
X   (VAR line : ARRAY OF CHAR) ;   (* the line read *)
X
X(* This procedure reads a line of data from the current input stream.     *)
X(* Reading is terminated when the end of line character (EOL) is reached, *)
X(* the array into which characters are being read becomes full, a null    *)
X(* character is read, or a CTRL/D (4C) character (4C) is read.            *)
X
X
XPROCEDURE WriteFormattedReal
X   (r              : REAL ;         (* the real number to write *)
X    width          : CARDINAL ;     (* size of output field *)
X    ndecimalplaces : CARDINAL ) ;   (* number of decimal places to write *)
X
X(* This procedure writes a real number to the output stream and places that *)
X(* number in a field "width" spaces wide.  The field will be filled with    *)
X(* blanks to pad it to the appropriate size.  (The number is right justi-   *)
X(* fied in the field.)  WriteFormattedReal will output numbers in standard  *)
X(* format with the specified number of decimal places.                      *)
X
X
XEND InOutExtensions.
END_OF_InOutExtensions.def
if test 2406 -ne `wc -c <InOutExtensions.def`; then
    echo shar: \"InOutExtensions.def\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f move.def -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"move.def\"
else
echo shar: Extracting \"move.def\" \(1734 characters\)
sed "s/^X//" >move.def <<'END_OF_move.def'
XDEFINITION MODULE move;
X
X(*************************************************************************)
X(*                                                                       *)
X(* OTHELLO.  (c) 1987 Robert Silvers.  All rights reserved.              *)
X(*                                                                       *)
X(* This module handles most of the players moves.                        *)
X(*                                                                       *)
X(*************************************************************************)
X
XFROM types   IMPORT
X   PIECES, TEMP, BOARD;
X
XFROM othello IMPORT
X   ShowMoves, GameOver;
X
XEXPORT       QUALIFIED
X   GetMove, Validate, Move, Count, HowMany, CanPass;
X
X
XPROCEDURE Move (player: PIECES; VAR xcords, ycords: INTEGER);
X
XPROCEDURE FindBest (player: PIECES; VAR xcords, ycords: INTEGER);
X
XPROCEDURE GetMove (player: PIECES; VAR xcords, ycords: INTEGER);
X
XPROCEDURE Value (player: PIECES; x, y: INTEGER): INTEGER;
X
XPROCEDURE CanPass (player: PIECES ): BOOLEAN;
X
XPROCEDURE Corner  (x,   y: INTEGER): BOOLEAN;
X
XPROCEDURE Edge    (x,   y: INTEGER): BOOLEAN;
X
XPROCEDURE TwoAway (x,   y: INTEGER): BOOLEAN;
X
XPROCEDURE NextToCorner (x, y: INTEGER): BOOLEAN;
X
XPROCEDURE Validate (player: PIECES; xcords, ycords: INTEGER): BOOLEAN;              
XPROCEDURE Check (player: PIECES; xcords, ycords, xdirection, ydirection:
X                 INTEGER) : BOOLEAN; 
X
XPROCEDURE Count (VAR White, Black: INTEGER);
X
XPROCEDURE HowMany(player : PIECES; xcords, ycords: INTEGER; VAR count, weight:
X		  INTEGER);       
X
XPROCEDURE NumFlips(player : PIECES; xcords, ycords, xdir, ydir: INTEGER;
X		   VAR count, weight: INTEGER);       
X
XPROCEDURE CopyToTemp;
X
XPROCEDURE CopyBack;
X
X 
XEND move.
END_OF_move.def
if test 1734 -ne `wc -c <move.def`; then
    echo shar: \"move.def\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f othello.def -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"othello.def\"
else
echo shar: Extracting \"othello.def\" \(1031 characters\)
sed "s/^X//" >othello.def <<'END_OF_othello.def'
XDEFINITION MODULE othello;
X
X(*************************************************************************)
X(*                                                                       *)
X(* OTHELLO.  (c) 1987 Robert Silvers.  All rights reserved.              *)
X(*                                                                       *)
X(* Handles most of the game routines.                                    *)
X(*                                                                       *)
X(*************************************************************************)
X
XFROM types IMPORT
X   PIECES, BOARD, TEMP;
X
XEXPORT     QUALIFIED
X   InitBoard, DrawBoard, Flip, ReDraw, Menu, GameOver, ShowMoves;
X
X
XPROCEDURE InitBoard;
X
XPROCEDURE Menu(VAR choice: CHAR);
X
XPROCEDURE DrawBoard;
X
XPROCEDURE GameOver(computer: BOOLEAN): BOOLEAN;
X
XPROCEDURE Flip (player: PIECES; xcords, ycords: INTEGER);
X
XPROCEDURE Flipper (player: PIECES; xcords, ycords, xdir, ydir: INTEGER);
X
XPROCEDURE ShowMoves (player: PIECES);
X
XPROCEDURE ReDraw ();
X
X 
XEND othello.
X
END_OF_othello.def
if test 1031 -ne `wc -c <othello.def`; then
    echo shar: \"othello.def\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f regis.def -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"regis.def\"
else
echo shar: Extracting \"regis.def\" \(1079 characters\)
sed "s/^X//" >regis.def <<'END_OF_regis.def'
XDEFINITION MODULE regis;
X(* This module contains lo-level graphic commands.                    *)
X
X
XEXPORT QUALIFIED
XClearScreen, Reset, Position, Circle, Plot, DrawTo, WriteText, TextSize,
XWriteNum, SetFill, UnsetFill, Box, Color, BGColor, Pattern, TextSlant,
XWriteChr, Scroll, TextDirection, ExitGr;
X
X
XTYPE
X   CoorinatePair= RECORD
X                     x,y:INTEGER;
X                  END;
XTYPE 
X   String= ARRAY [0..80] OF CHAR;
X
X
XPROCEDURE Reset;
X
XPROCEDURE ExitGr;
X
XPROCEDURE Color(Color: CHAR);
X
XPROCEDURE BGColor(Color: CHAR);
X
XPROCEDURE Box(width, height: INTEGER);
X
XPROCEDURE Position(x,y:INTEGER);
X
XPROCEDURE Circle(x,y:INTEGER);
X
XPROCEDURE Plot(x,y:INTEGER);
X
XPROCEDURE DrawTo(x,y:INTEGER);
X
XPROCEDURE WriteText(message:String);
X
XPROCEDURE Pattern(p :String);
X
XPROCEDURE WriteNum(num: INTEGER);
X
XPROCEDURE WriteChr(chr: CHAR);
X
XPROCEDURE Scroll(dx, dy: INTEGER);
X
XPROCEDURE TextSize(size :INTEGER);
X
XPROCEDURE TextSlant(angle :INTEGER);
X
XPROCEDURE TextDirection(dir :INTEGER);
X
XPROCEDURE SetFill(y:INTEGER);
X
XPROCEDURE UnsetFill;
X
XPROCEDURE ClearScreen;
X
X
XEND regis.
X
X
END_OF_regis.def
if test 1079 -ne `wc -c <regis.def`; then
    echo shar: \"regis.def\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f types.mod -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"types.mod\"
else
echo shar: Extracting \"types.mod\" \(247 characters\)
sed "s/^X//" >types.mod <<'END_OF_types.mod'
XIMPLEMENTATION MODULE types;
X(**************************************)
X(*                                    *)
X(* Dummy module.                      *)
X(*                                    *)
X(**************************************)
X
XEND types.
X
END_OF_types.mod
if test 247 -ne `wc -c <types.mod`; then
    echo shar: \"types.mod\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0