home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / Extras / TicTacToe / Engine.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.0 KB  |  60 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ///////////////////////////////////////////////////////////////
  22. // Engine.h: The brains of the tic-tac-toe game
  23. ///////////////////////////////////////////////////////////////
  24. #ifndef ENGINE_H
  25. #define ENGINE_H
  26.  
  27. #include "Board.h"
  28.  
  29. class TicTacToe;
  30. class MoveGenerator;
  31.  
  32. class Engine {
  33.     
  34.   protected:
  35.     
  36.     TicTacToe       *_game;
  37.     markType         _whoseMove;     // Remember whose turn it is
  38.     Board           *_board;         // Internal game state
  39.     MoveGenerator   *_moveGenerator; // Picks next move
  40.     int              _gameOver;      // True is game has ended
  41.     void   checkForWin();            // Check and report the winner
  42.     
  43.   public:
  44.     
  45.     Engine ( TicTacToe * ); 
  46.     virtual ~Engine();
  47.     void recordMove ( int square ); 
  48.     void reset();                    // Start over
  49.     void quit();
  50.     virtual const char *const className() { return "Engine"; }
  51. };
  52. #define NEWGAMEMSG     "New Game. Choose an X square"
  53. #define ILLEGALMOVEMSG "Illegal Move, Choose an other X square"
  54. #define USERSMOVEMSG   "Choose an X square"
  55. #define XWINSMSG       "X Wins!"
  56. #define OWINSMSG       "O Wins!"
  57. #define TIEGAMEMSG     "Tie Game"
  58. #define GAMEISOVERMSG  "Sorry, the game is over"
  59. #endif
  60.