-
Notifications
You must be signed in to change notification settings - Fork 1
/
EasyB.h
319 lines (288 loc) · 10 KB
/
EasyB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
//----------------------------------------------------------------------------------------
//
// This file and all other Easy Bridge source files are copyright (C) 2002 by Steven Han.
// Use of this file is governed by the GNU General Public License.
// See the files COPYING and COPYRIGHT for details.
//
//----------------------------------------------------------------------------------------
// EasyB.h : main header file for the EASYB application
//
#ifndef __EASYB_H__
#define __EASYB_H__
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "defines.h" // other global info
#include "globals.h"
#include "ObjectWithProperties.h"
#include "EventProcessor.h"
class CPlayer;
class CGIB;
class CConventionSet;
class CSplashWnd;
class CNeuralNet;
extern const LPCTSTR szSuitName[];
/////////////////////////////////////////////////////////////////////////////
// CEasyBApp:
// See EasyB.cpp for the implementation of this class
//
#define DllImport __declspec( dllimport )
class CEasyBApp : public CWinApp, public CObjectWithProperties, public CEventProcessor
{
public:
enum { PLAY_NORMAL, PLAY_MANUAL, PLAY_MANUAL_DEFEND, PLAY_FULL_AUTO, PLAY_FULL_AUTO_EXPRESS };
// public routines
public:
// property get/set operations
LPVOID GetValuePV(int nItem, int nIndex1=0, int nIndex2=0, int nIndex3=0);
LPCTSTR GetValueString(int nItem, int nIndex1=0, int nIndex2=0, int nIndex3=0);
double GetValueDouble(int nItem, int nIndex1=0, int nIndex2=0, int nIndex3=0);
int GetValue(int nItem, int nIndex1=0, int nIndex2=0, int nIndex3=0);
int SetValuePV(int nItem, LPVOID value, int nIndex1=0, int nIndex2=0, int nIndex3=0);
int SetValue(int nItem, double fValue, int nIndex1=0, int nIndex2=0, int nIndex3=0);
int SetValue(int nItem, LPCTSTR szValue=NULL, int nIndex1=0, int nIndex2=0, int nIndex3=0);
int SetValue(int nItem, int nValue, int nIndex1=0, int nIndex2=0, int nIndex3=0);
int SetValueDouble(int nItem, double fValue, int nIndex1=0, int nIndex2=0, int nIndex3=0);
void RefreshProperties();
// Event Processor
bool Notify(long lCode, long param1=0, long param2=0, long param3=0) { return false; }
//
CString GetProgramTitle() { return m_strProgTitle; }
CString GetProgramVersionString();
CString GetFullProgramVersionString();
CWnd* GetFrame() { return m_pMainWnd; }
int GetMinimumOpeningValue(CPlayer* pPlayer=NULL) const;
// inline functions
BOOL IsDebugModeActive() const { return m_bDebugMode; }
BOOL AreCardsFaceUp() const;
void SetCardsFaceUp(BOOL bFaceUp);
int GetLHO(int nPos) const { return GetNextPlayer(nPos); }
int GetRHO(int nPos) const { return GetPrevPlayer(nPos); }
int GetCurrentConvention() const { return m_nCurrConventionSet; }
int GetSuitSequence(int nIndex) const { return m_nSuitSequence[nIndex]; }
void SetSuitSequence(int nIndex, int nValue) { m_nSuitSequence[nIndex] = nValue; }
int GetDummySuitSequence(int nIndex) const { return m_nDummySuitSequence[nIndex]; }
void InitDummySuitSequence(int nTrumpSuit, int nDummyPosition=NONE);
void InitPointCountRequirements();
void InitHonorsValuations();
double GetBiddingAgressiveness() const { return m_fBiddingAggressiveness; }
int GetSuitSequenceOption() const { return m_nSuitSeqOption; }
LPCTSTR GetSuitName(int nSuit) const { return szSuitName[nSuit]; }
BOOL InExpressAutoPlay() const { return (m_nPlayMode == PLAY_FULL_AUTO_EXPRESS); }
BOOL IsBiddingInProgress() const { return m_bBiddingInProgress; }
BOOL IsGameInProgress() const { return m_bGameInProgress; }
BOOL IsRubberInProgress() const { return m_bRubberInProgress; }
BOOL IsUsingDuplicateScoring() const { return m_bDuplicateScoring; }
BOOL IsAutoHintEnabled() const { return (m_nAutoHintMode > 0); }
int GetAutoHintLevel() const { return m_nAutoHintMode; }
int GetNumAcesRequiredForSlam(int nIndex) const { return m_numAcesForSlam[nIndex]; }
int GetNumKingsRequiredForSlam(int nIndex) const { return m_numKingsForSlam[nIndex]; }
void SetNumAcesRequiredForSlam(int nIndex, int nCount) { m_numAcesForSlam[nIndex] = nCount; }
void SetNumKingsRequiredForSlam(int nIndex, int nCount) { m_numKingsForSlam[nIndex] = nCount; }
double GetHonorValue() const;
CGIB* GetGIB() { return m_pGIBWrapper; }
// CNeuralNet* GetNeuralNet() { return m_pNeuralNet; }
// static data
public:
//
static double m_fDefaultMajorSuitGamePts;
static double m_fDefaultMinorSuitGamePts;
static double m_fDefaultNTGamePts;
static double m_fDefault4LevelPts;
static double m_fDefault3LevelPts;
static double m_fDefault2LevelPts;
static double m_fDefaultSlamPts;
static double m_fDefaultGrandSlamPts;
//
static double m_fMajorSuitGamePts;
static double m_fMinorSuitGamePts;
static double m_fNTGamePts;
static double m_f4LevelPts;
static double m_f3LevelPts;
static double m_f2LevelPts;
static double m_fSlamPts;
static double m_fGrandSlamPts;
//
static double m_fHonorValue[15];
// pricate data
private:
// prog info
CString m_strProgTitle;
CString m_strProgPath;
CString m_strProgDirectory;
int m_nProgVersion[4];
int m_nProgMajorVersion;
int m_nProgMinorVersion;
int m_nProgIncrementVersion;
int m_nProgBuildNumber;
CString m_strProgCopyright;
CString m_strProgBuildDate;
CString m_strSpecialBuildCode;
//
CDocument* m_pActiveDocument;
//
int m_nCurrConventionSet;
int m_numConventionSets;
int m_nSuitSeqList[5][4];
int m_nSuitSequence[4];
int m_nDummySuitSequence[4];
int m_nSuitSeqOption;
BOOL m_bLowResOption;
BOOL m_bToggleResolutionMode;
BOOL m_bLayoutFollowsDisplayOrder;
BOOL m_bShowDummyTrumpsOnLeft;
//
// program status
//
int m_nGameMode; // 0=practice, 1=rubber
BOOL m_bBiddingInProgress; // bidding
BOOL m_bGameInProgress; // playing tricks
BOOL m_bRubberInProgress; // playing rubber?
BOOL m_bDuplicateScoring; // duplicate scoring?
int m_nAutoHintMode; // Auto Hint in effect?
int m_nAutoHintTraceLevel; // Auto Hint trace level
BOOL m_bFirstTimeRunning; // first time running?
// debug options
BOOL m_bDebugMode; // debug mode
int m_nTestMode;
BOOL m_bShowCardsFaceUp;
BOOL m_bManualPlayMode;
int m_nPlayMode;
BOOL m_bPlayModeLocked;
BOOL m_bAutoTestMode;
// display options
BOOL m_bAutoAlignDialogs;
BOOL m_bShowStartupAnimation;
BOOL m_bShowSplashWindow;
BOOL m_bEnableSpokenBids;
BOOL m_bSaveIntermediatePositions;
BOOL m_bExposePBNGameCards;
BOOL m_bShowBackgroundBitmap;
BOOL m_bShowDailyTipDialog;
BOOL m_bShowScreenSizeWarning;
int m_nBitmapDisplayMode;
BOOL m_bScaleLargeBitmaps;
int m_nBackgroundColor;
BOOL m_bUseSuitSymbols;
BOOL m_bCollapseGameReviewDialog;
BOOL m_bCollapseRoundFinishedDialog;
// game options
BOOL m_bAutoBidStart;
BOOL m_bAutoJumpCursor;
BOOL m_bAutoPlayLastCard;
BOOL m_bEnableAnalysisTracing;
BOOL m_bEnableAnalysisDuringHints;
int m_nAnalysisTraceLevel;
BOOL m_bShowCommentIdentifiers;
BOOL m_bInsertBiddingPause;
int m_nBiddingPauseLength;
BOOL m_bInsertPlayPause;
int m_nPlayPauseLength;
BOOL m_bComputerCanClaim;
BOOL m_bShowPassedHands;
BOOL m_bAllowRebidPassedHands;
int m_nPassedHandWaitInterval;
BOOL m_bAutoShowBidHistory;
BOOL m_bAutoShowPlayHistory;
BOOL m_bAutoHideBidHistory;
BOOL m_bAutoHidePlayHistory;
BOOL m_bAutoShowNNetOutputWhenTraining;
BOOL m_bShowLayoutOnEdit;
// bidding config
double m_fBiddingAggressiveness;
BOOL m_bManualBidding; // transient
/*
int m_nBiddingEngine;
BOOL m_bNNetTrainingMode;
int m_numNNetHiddenLayers;
int m_numNNetNodesPerHiddenLayer;
CString m_strNeuralNetFile;
CNeuralNet* m_pNeuralNet;
*/
// counting options
int m_nHonorsValuationMode;
double m_fAceValue;
double m_fKingValue;
double m_fQueenValue;
double m_fJackValue;
double m_fTenValue;
double m_fCustomAceValue;
double m_fCustomKingValue;
double m_fCustomQueenValue;
double m_fCustomJackValue;
double m_fCustomTenValue;
BOOL m_bAcelessPenalty;
BOOL m_b4AceBonus;
BOOL m_bPenalizeUGHonors;
BOOL m_bCountShortSuits;
// deal options
int m_nReqPointsGame[4][2];
int m_nReqPointsSlam[3][2];
int m_nPointsAbsGameLimits[4][2];
int m_nPointsAbsSlamLimits[3][2];
BOOL m_bBalanceTeamHands;
BOOL m_bGiveSouthBestHandInPartnership;
BOOL m_bGiveSouthBestHandInGame;
int m_nMinCardsInMajor;
int m_nMinCardsInMinor;
int m_nMinSuitDistTable[2][4][2];
int m_nMinSuitDist[2];
int m_nMinTopMajorCard;
int m_nMinTopMinorCard;
int m_nMaxImbalanceForNT;
BOOL m_bNeedTwoBalancedTrumpHands;
int m_numAcesForSlam[3];
int m_numKingsForSlam[3];
BOOL m_bEnableDealNumbering;
// scoring options
BOOL m_bScoreHonorsBonuses;
// GIB options
CGIB* m_pGIBWrapper;
CString m_strGIBPath;
BOOL m_bEnableGIBForDeclarer;
BOOL m_bEnableGIBForDefender;
int m_nGIBAnalysisTime;
int m_nGIBSampleSize;
BOOL m_bShowGIBOutput;
//
// Platform info
//
int m_nWinMajorVer; // Windows Platform Major Version #
int m_nWinMinorVer; // Windows Platform Minor Version #
int m_nWinBuildNum; // Windows Platform Build #
int m_nWinMode; // 0 = NT, 1 = Chicago, 2 = Win32s
BOOL m_bWin32; // Win32 flag
//
CSplashWnd* m_pSplash;
DWORD m_dwSplashTime;
// internal routines
public:
CEasyBApp();
private:
void Initialize();
void Terminate();
void InitSettings();
void InitNeuralNet();
void CloseNeuralNet();
void SetSuitSequence(int nSeq);
// helpful functions
int MinimumOpeningValue(CPlayer* pPlayer=NULL);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CEasyBApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CEasyBApp)
afx_msg void OnAppAbout();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
extern CEasyBApp theApp;
extern CConventionSet* pConventionSet[];
extern CConventionSet* pCurrConvSet;
#endif