Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
5.1 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1991, 1992 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. computer.h
  7. This file contains the class declarations and manifest constants
  8. necessary for implementing the 'computer' object.
  9. FILE HISTORY:
  10. KeithMo 01-Mar-1992 Created from JimH's PLAYER.H.
  11. ****************************************************************************/
  12. #include "card.h"
  13. #include "player.h"
  14. #ifndef _COMPUTER_H_
  15. #define _COMPUTER_H_
  16. //
  17. // These constants are used for indexing the _CardVectors array.
  18. //
  19. // Note that this ordering *must* match the ordering used for the
  20. // card ID values!!
  21. //
  22. #define INDEX_CLUBS 0
  23. #define INDEX_DIAMONDS 1
  24. #define INDEX_HEARTS 2
  25. #define INDEX_SPADES 3
  26. //
  27. // These constants represent the values returned from the
  28. // CardToVector() function.
  29. //
  30. // Note that this ordering *must* match the ordering used for the
  31. // card ID values!!
  32. //
  33. #define VECTOR_ACE 0x0001
  34. #define VECTOR_2 0x0002
  35. #define VECTOR_3 0x0004
  36. #define VECTOR_4 0x0008
  37. #define VECTOR_5 0x0010
  38. #define VECTOR_6 0x0020
  39. #define VECTOR_7 0x0040
  40. #define VECTOR_8 0x0080
  41. #define VECTOR_9 0x0100
  42. #define VECTOR_10 0x0200
  43. #define VECTOR_JACK 0x0400
  44. #define VECTOR_QUEEN 0x0800
  45. #define VECTOR_KING 0x1000
  46. //
  47. // These constants define various combinations of cards.
  48. //
  49. #define LOW_CARDS (VECTOR_2 | VECTOR_3 | VECTOR_4 | VECTOR_5 \
  50. | VECTOR_6 | VECTOR_7)
  51. #define HIGH_CARDS (VECTOR_8 | VECTOR_9 | VECTOR_10 \
  52. | VECTOR_JACK | VECTOR_QUEEN | VECTOR_KING \
  53. | VECTOR_ACE)
  54. #define QKA_CARDS (VECTOR_QUEEN | VECTOR_KING | VECTOR_ACE)
  55. #define JQKA_CARDS (VECTOR_JACK | VECTOR_QUEEN | VECTOR_KING \
  56. | VECTOR_ACE)
  57. /****************************************************************************
  58. computer
  59. ****************************************************************************/
  60. class computer : public player
  61. {
  62. private:
  63. static int _VectorPriority[13];
  64. static int _SuitPriority[4];
  65. int _CardVectors[4];
  66. int CardToSuit( int nCard ) const
  67. { return nCard % 4; }
  68. int CardToValue( int nCard ) const
  69. { return nCard / 4; }
  70. int CardToVector( int nCard ) const
  71. { return 1 << CardToValue( nCard ); }
  72. int CountBits( int x ) const;
  73. void AddCard( int nCard )
  74. { _CardVectors[CardToSuit(nCard)] |= CardToVector(nCard); }
  75. void RemoveCard( int nCard )
  76. { _CardVectors[CardToSuit(nCard)] &= ~CardToVector(nCard); }
  77. BOOL TestCard( int nCard ) const
  78. { return (_CardVectors[CardToSuit(nCard)] & CardToVector(nCard)) != 0; }
  79. int QueryClubsVector( void ) const
  80. { return _CardVectors[INDEX_CLUBS]; }
  81. int QueryDiamondsVector( void ) const
  82. { return _CardVectors[INDEX_DIAMONDS]; }
  83. int QueryHeartsVector( void ) const
  84. { return _CardVectors[INDEX_HEARTS]; }
  85. int QuerySpadesVector( void ) const
  86. { return _CardVectors[INDEX_SPADES]; }
  87. void ComputeVectors( void );
  88. void PassCardsInVector( int nVector, int nSuit, int * pcPassed );
  89. // comp2.cpp helper functions and data
  90. int BestSuitToDump(BOOL bIncludeHearts = TRUE);
  91. int BestSuitToLose(BOOL bIncludeHearts = TRUE);
  92. SLOT CardBelow(SLOT s);
  93. int CardsAbove(SLOT s);
  94. int CardsAboveLow(int suit);
  95. int CardsBelowLow(int suit);
  96. SLOT MidSlot(int suit);
  97. SLOT SafeCard(handinfotype &h);
  98. SLOT SelectLeadCard(handinfotype &h);
  99. SLOT SelectNonLeadCard(handinfotype &h);
  100. void Setup(handinfotype &h);
  101. int SureLossSuit(BOOL bIncludeHearts);
  102. BOOL bFirst; // am I leading?
  103. BOOL bLast; // am I last?
  104. card *cardled;
  105. int nSuitLed;
  106. int nValueLed;
  107. int currentval; // current winning value
  108. int nPoints; // points currently in hand
  109. SLOT sBlackLady; // non-EMPTY if in hand
  110. SLOT sHighCard[MAXSUIT]; // highest and lowest cards by suit
  111. int nHighVal[MAXSUIT];
  112. SLOT sLowCard[MAXSUIT];
  113. int nLowVal[MAXSUIT];
  114. SLOT sHighestCard; // highest and lowest regardless of suit
  115. int nHighestVal;
  116. SLOT sLowestCard;
  117. int nLowestVal;
  118. int nAvailable[MAXSUIT][KING+2]; // cards unaccounted for this hand
  119. public:
  120. computer(int n);
  121. virtual void NotifyEndHand(handinfotype &h);
  122. virtual void NotifyNewRound(void);
  123. virtual void SelectCardsToPass(void);
  124. virtual void SelectCardToPlay(handinfotype &h, BOOL bCheating);
  125. virtual void UpdateStatus(void) { }
  126. virtual void UpdateStatus(int stringid) { status = stringid; }
  127. virtual void UpdateStatus(const TCHAR *string) { }
  128. }; // class computer
  129. #endif // _COMPUTER_H_