home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / scase.zip / SCASE.Z / TTTENG.H < prev    next >
C/C++ Source or Header  |  1994-10-17  |  2KB  |  66 lines

  1. #ifndef ttteng_h_included  
  2. #define ttteng_h_included  
  3. /******************************************************************************
  4. *                         ** Company Confidential **
  5. *                  ** Copyright 1994, All rights Reserved **
  6. * %Z%%M% version %I% date:%G%
  7. ******************************************************************************/
  8.  
  9. // -MQBeg- [Module_Includes] [ttteng_h] <00000017.00000000> Retained!
  10. // -MQEnd- [Module_Includes] [ttteng_h] <00000017.00000000> 
  11.  
  12. // -MQBeg- [Module_Declarations_1] [ttteng_h] <00000017.00000000> Retained!
  13. // -MQEnd- [Module_Declarations_1] [ttteng_h] <00000017.00000000> 
  14.  
  15. // -MQBeg- [Class_Spec] [TTT_Engine] <00000000.00000001> 
  16. /******************************************************************************
  17. TTT_Engine:
  18. Implements the TicTacToe model. 
  19. Portions of this model are adapted from the TTT
  20. example in Borland's ObjectWindows library. 
  21. ******************************************************************************/
  22. class TTT_Engine 
  23. {
  24. // -MQBeg- [Declarations_1] [TTT_Engine] <00000000.00000001> Retained!
  25. // -MQEnd- [Declarations_1] [TTT_Engine] <00000000.00000001> 
  26. public:
  27.   TTT_Engine();
  28.   // Reset the TTT engine.
  29.   void Reset();
  30.   // User's request to make a move. Returns MOVE_RESULT.
  31.   int MoveRequest(int CellNumber);
  32.   // Get user and computer board maps.
  33.   void GetBoards(int& User, int& Comp);
  34. protected:
  35.   // Computer's turn.
  36.   void ComputerTurn(void);
  37. private:
  38.   // Clear the user and computer board maps.
  39.   void ClearBoard(void);
  40.   // Find the next free square for computer.
  41.   static void FreeSquare(int Mask, int i , int& TargetMask);
  42.   // Determine win, lose or draw. Set the MoveResult member.
  43.   void WinLoseDraw(void);
  44. public:
  45.   // Values for the result of a move.
  46.   enum MOVE_RESULT { LEGAL, ILLEGAL, YOUWIN, YOULOSE, DRAW } MoveResult;
  47. private:
  48.   // Bit map of user's moves. 
  49.   int UserBoard;
  50.   // Bit map of computer's moves.
  51.   int CompBoard;
  52.   // Masks for determining computer's next move.
  53.   const static int freeMasks[];
  54.   // Winning combinations.
  55.   const static int winningMasks[];
  56. // -MQBeg- [Declarations_2] [TTT_Engine] <00000000.00000001> Retained!
  57. // -MQEnd- [Declarations_2] [TTT_Engine] <00000000.00000001> 
  58. };
  59.  
  60. // -MQEnd- [Class_Spec] [TTT_Engine] <00000000.00000001> 
  61.  
  62. // -MQBeg- [Module_Declarations_2] [ttteng_h] <00000017.00000000> Retained!
  63. // -MQEnd- [Module_Declarations_2] [ttteng_h] <00000017.00000000> 
  64.  
  65. #endif
  66.