home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
scase.zip
/
SCASE.Z
/
TTTENG.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-17
|
2KB
|
66 lines
#ifndef ttteng_h_included
#define ttteng_h_included
/******************************************************************************
* ** Company Confidential **
* ** Copyright 1994, All rights Reserved **
* %Z%%M% version %I% date:%G%
******************************************************************************/
// -MQBeg- [Module_Includes] [ttteng_h] <00000017.00000000> Retained!
// -MQEnd- [Module_Includes] [ttteng_h] <00000017.00000000>
// -MQBeg- [Module_Declarations_1] [ttteng_h] <00000017.00000000> Retained!
// -MQEnd- [Module_Declarations_1] [ttteng_h] <00000017.00000000>
// -MQBeg- [Class_Spec] [TTT_Engine] <00000000.00000001>
/******************************************************************************
TTT_Engine:
Implements the TicTacToe model.
Portions of this model are adapted from the TTT
example in Borland's ObjectWindows library.
******************************************************************************/
class TTT_Engine
{
// -MQBeg- [Declarations_1] [TTT_Engine] <00000000.00000001> Retained!
// -MQEnd- [Declarations_1] [TTT_Engine] <00000000.00000001>
public:
TTT_Engine();
// Reset the TTT engine.
void Reset();
// User's request to make a move. Returns MOVE_RESULT.
int MoveRequest(int CellNumber);
// Get user and computer board maps.
void GetBoards(int& User, int& Comp);
protected:
// Computer's turn.
void ComputerTurn(void);
private:
// Clear the user and computer board maps.
void ClearBoard(void);
// Find the next free square for computer.
static void FreeSquare(int Mask, int i , int& TargetMask);
// Determine win, lose or draw. Set the MoveResult member.
void WinLoseDraw(void);
public:
// Values for the result of a move.
enum MOVE_RESULT { LEGAL, ILLEGAL, YOUWIN, YOULOSE, DRAW } MoveResult;
private:
// Bit map of user's moves.
int UserBoard;
// Bit map of computer's moves.
int CompBoard;
// Masks for determining computer's next move.
const static int freeMasks[];
// Winning combinations.
const static int winningMasks[];
// -MQBeg- [Declarations_2] [TTT_Engine] <00000000.00000001> Retained!
// -MQEnd- [Declarations_2] [TTT_Engine] <00000000.00000001>
};
// -MQEnd- [Class_Spec] [TTT_Engine] <00000000.00000001>
// -MQBeg- [Module_Declarations_2] [ttteng_h] <00000017.00000000> Retained!
// -MQEnd- [Module_Declarations_2] [ttteng_h] <00000017.00000000>
#endif