home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / units / magic.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.5 KB  |  53 lines

  1. {$A+,B-,D-,F+,G+,I+,K+,L-,N-,P-,Q-,R-,S+,T+,V-,W+,X+,Y-}
  2. unit MAGIC;
  3. {
  4.     File: MAGIC.PAS
  5.   Author: Bob Swart (bobs@dragons.nest.nl)
  6.  
  7.   From the article entitled 'Tic-tac-toe, Borland Pascal, C++ and
  8.                                           Visual Basic make it so'
  9.   written by Bob Swart, Jeroen Pluimers and Hans van der Veeke to
  10.   appear in a future issue of Dr.Dobbs (Algorithm Alley column).
  11.   ----------------------------------------------------------------
  12.   This file contains the interface code to the MAGIC.DLL (with the
  13.   magic square tic-tac-toe algorithm).
  14. }
  15. interface
  16. Const
  17.   NoneID = 0;
  18.   UserID = 1;
  19.   CompID = 2;
  20.  
  21. Type
  22.   TPlayer = NoneID..CompID;
  23.  
  24. Const
  25.   NilPlace   = 0; { move impossible }
  26.   FirstPlace = 1;
  27.   LastPlace  = 9;
  28.  
  29. Type
  30.   TPlace = FirstPlace..LastPlace;
  31.   TMove  = NilPlace..LastPlace;
  32.  
  33. Type
  34.   HGame = Word; { Handle to a game }
  35.  
  36.   function NewGame: HGame;
  37.   procedure EndGame(Game: HGame);
  38.   procedure MakeMove(Game: HGame; ID: TPlayer; Place: TPlace);
  39.   function NextMove(Game: HGame; ID: TPlayer): TMove;
  40.   function IsWinner(Game: HGame): TPlayer;
  41.   function GetValue(Game: HGame; Place: TPlace): TPlayer;
  42.  
  43. implementation
  44.  
  45.   function NewGame;   external 'MAGIC' index 1;
  46.   procedure EndGame;  external 'MAGIC' index 2;
  47.   procedure MakeMove; external 'MAGIC' index 3;
  48.   function NextMove;  external 'MAGIC' index 4;
  49.   function IsWinner;  external 'MAGIC' index 5;
  50.   function GetValue;  external 'MAGIC' index 6;
  51.  
  52. end.
  53.