Skip to content

Commit 124b0bf

Browse files
committed
v2.3.4 - fix forfeit issue
1 parent 5aefe6c commit 124b0bf

File tree

19 files changed

+88
-162
lines changed

19 files changed

+88
-162
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Cinnamon is a chess program for Windows, Linux, Mac OS, Android and Raspberry Pi
66

77
Version
88
----------
9-
2.3.3
9+
2.3.4
1010

1111
News
1212
----------

src/Eval.cpp

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ Eval::~Eval() {
3131
evalHash = nullptr;
3232
}
3333

34-
template<int side>
35-
void Eval::openFile() {
36-
structureEval.openFile = 0;
37-
structureEval.semiOpenFile[side] = 0;
38-
39-
for (u64 side_rooks = chessboard[ROOK_BLACK + side]; side_rooks; RESET_LSB(side_rooks)) {
40-
const int o = BITScanForward(side_rooks);
41-
if (!(FILE_[o] & (chessboard[WHITE] | chessboard[BLACK])))
42-
structureEval.openFile |= FILE_[o];
43-
else if (FILE_[o] & chessboard[side ^ 1])
44-
structureEval.semiOpenFile[side] |= FILE_[o];
45-
}
46-
}
47-
4834
/**
4935
* evaluate pawns for color at phase
5036
* 1. if no pawns returns -NO_PAWNS
@@ -313,7 +299,7 @@ int Eval::evaluateQueen(const u64 enemies) {
313299
*/
314300

315301
template<int side, Eval::_Tphase phase>
316-
int Eval::evaluateKnight(const u64 enemiesPawns, const u64 notMyBits) {
302+
int Eval::evaluateKnight(const u64 notMyBits) {
317303
INC(evaluationCount[side]);
318304
u64 knight = chessboard[KNIGHT_BLACK + side];
319305
if (!knight) return 0;
@@ -469,21 +455,12 @@ int Eval::evaluateKing(int side, u64 squares) {
469455
ADD(SCORE_DEBUG.DISTANCE_KING[side], DISTANCE_KING_OPENING[pos_king]);
470456
result = DISTANCE_KING_OPENING[pos_king];
471457
}
472-
u64 POW2_king = POW2[pos_king];
458+
473459
//mobility
474460
ASSERT(bitCount(squares & NEAR_MASK1[pos_king]) < (int) (sizeof(MOB_KING[phase]) / sizeof(int)))
475461
result += MOB_KING[phase][bitCount(squares & NEAR_MASK1[pos_king])];
476462
ADD(SCORE_DEBUG.MOB_KING[side], MOB_KING[phase][bitCount(squares & NEAR_MASK1[pos_king])]);
477-
if (phase != OPEN) {
478-
if ((structureEval.openFile & POW2_king) || (structureEval.semiOpenFile[side ^ 1] & POW2_king)) {
479-
ADD(SCORE_DEBUG.END_OPENING_KING[side], -END_OPENING);
480-
result -= END_OPENING;
481-
if (bitCount(RANK[pos_king]) < 4) {
482-
ADD(SCORE_DEBUG.END_OPENING_KING[side], -END_OPENING);
483-
result -= END_OPENING;
484-
}
485-
}
486-
}
463+
487464
ASSERT(pos_king < 64)
488465
if (!(NEAR_MASK1[pos_king] & chessboard[side])) {
489466
ADD(SCORE_DEBUG.PAWN_NEAR_KING[side], -PAWN_NEAR_KING);
@@ -547,9 +524,6 @@ short Eval::getScore(const u64 key, const int side, const int alpha, const int b
547524
structureEval.posKingBit[WHITE] = POW2[structureEval.posKing[WHITE]];
548525
structureEval.kingAttackers[WHITE] = structureEval.kingAttackers[BLACK] = 0;
549526

550-
openFile<WHITE>();
551-
openFile<BLACK>();
552-
553527
_Tresult Tresult;
554528
switch (phase) {
555529
case OPEN :
@@ -596,12 +570,6 @@ short Eval::getScore(const u64 key, const int side, const int alpha, const int b
596570
} else {
597571
cout << " END\n";
598572
}
599-
cout << "|OPEN FILE: ";
600-
if (!structureEval.openFile)cout << "none";
601-
else
602-
for (int i = 0; i < 8; i++) if (POW2[i] & structureEval.openFile)cout << (char) (65 + i) << " ";
603-
cout << "\n";
604-
605573

606574
cout << "|VALUES:";
607575
cout << "\tPAWN: " << (double) constants::VALUEPAWN / 100.0;
@@ -737,9 +705,7 @@ short Eval::getScore(const u64 key, const int side, const int alpha, const int b
737705
cout << "| distance: " << setw(10) <<
738706
(double) (SCORE_DEBUG.DISTANCE_KING[WHITE]) / 100.0 << setw(10) <<
739707
(double) (SCORE_DEBUG.DISTANCE_KING[BLACK]) / 100.0 << "\n";
740-
cout << "| open file: " << setw(10) <<
741-
(double) (SCORE_DEBUG.END_OPENING_KING[WHITE]) / 100.0 << setw(10) <<
742-
(double) (SCORE_DEBUG.END_OPENING_KING[BLACK]) / 100.0 << "\n";
708+
743709
cout << "| pawn near: " << setw(10) <<
744710
(double) (SCORE_DEBUG.PAWN_NEAR_KING[WHITE]) / 100.0 << setw(10) <<
745711
(double) (SCORE_DEBUG.PAWN_NEAR_KING[BLACK]) / 100.0 << "\n";

src/Eval.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ class Eval: public GenMoves {
4545
return lazyEvalSide<side>() - lazyEvalSide<side ^ 1>();
4646
}
4747

48-
#ifdef DEBUG_MODE
49-
unsigned lazyEvalCuts;
50-
#endif
48+
DEBUG(unsigned lazyEvalCuts)
5149

5250
protected:
5351
STATIC_CONST int FUTIL_MARGIN = 154;
@@ -68,7 +66,6 @@ class Eval: public GenMoves {
6866
STATIC_CONST int ENEMY_NEAR_KING = 2;
6967
STATIC_CONST int FRIEND_NEAR_KING = 1;
7068
STATIC_CONST int HALF_OPEN_FILE_Q = 3;
71-
STATIC_CONST int END_OPENING = 6;
7269
STATIC_CONST int BONUS2BISHOP = 18;
7370
STATIC_CONST int BISHOP_PAWN_ON_SAME_COLOR = 5;
7471
STATIC_CONST int CONNECTED_ROOKS = 7;
@@ -107,7 +104,6 @@ class Eval: public GenMoves {
107104
int KING_SECURITY_KNIGHT[2];
108105
int KING_SECURITY_ROOK[2];
109106
int DISTANCE_KING[2];
110-
int END_OPENING_KING[2];
111107
int PAWN_NEAR_KING[2];
112108
int MOB_KING[2];
113109

@@ -158,9 +154,7 @@ class Eval: public GenMoves {
158154
int kings[2];
159155
} _Tresult;
160156

161-
#ifdef DEBUG_MODE
162-
int evaluationCount[2];
163-
#endif
157+
DEBUG(int evaluationCount[2])
164158

165159
template<_Tphase phase>
166160
void getRes(_Tresult &res) {
@@ -188,8 +182,8 @@ class Eval: public GenMoves {
188182
BENCH(times->stop("eval rook"));
189183

190184
BENCH(times->start("eval knight"));
191-
res.knights[BLACK] = evaluateKnight<BLACK, phase>(chessboard[WHITE], ~structureEval.allPiecesSide[BLACK]);
192-
res.knights[WHITE] = evaluateKnight<WHITE, phase>(chessboard[BLACK], ~structureEval.allPiecesSide[WHITE]);
185+
res.knights[BLACK] = evaluateKnight<BLACK, phase>(~structureEval.allPiecesSide[BLACK]);
186+
res.knights[WHITE] = evaluateKnight<WHITE, phase>(~structureEval.allPiecesSide[WHITE]);
193187
BENCH(times->stop("eval knight"));
194188

195189
BENCH(times->start("eval king"));
@@ -198,9 +192,6 @@ class Eval: public GenMoves {
198192
BENCH(times->stop("eval king"));
199193
}
200194

201-
template<int side>
202-
void openFile();
203-
204195
template<int side, _Tphase phase>
205196
int evaluatePawn();
206197

@@ -211,7 +202,7 @@ class Eval: public GenMoves {
211202
int evaluateQueen(const u64 enemies);
212203

213204
template<int side, _Tphase phase>
214-
int evaluateKnight(const u64, const u64);
205+
int evaluateKnight(const u64);
215206

216207
template<int side, Eval::_Tphase phase>
217208
int evaluateRook(const u64, u64 enemies, u64 friends);

src/GenMoves.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class GenMoves : public ChessBoard {
449449

450450
template<int side, uchar type>
451451
bool inCheckSlow(const int from, const int to, const int pieceFrom, const int pieceTo, const int promotionPiece) {
452-
bool result = false;
452+
bool result;
453453
switch (type & 0x3) {
454454
case STANDARD_MOVE_MASK: {
455455
u64 from1, to1 = -1;
@@ -622,9 +622,7 @@ class GenMoves : public ChessBoard {
622622
_assert(0);
623623
}
624624

625-
#ifdef DEBUG_MODE
626625
ASSERT(!memcmp(&a, chessboard, sizeof(_Tchessboard)));
627-
#endif
628626
BENCH(times->stop("inCheck"))
629627
return result;
630628
}

src/Hash.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ class Hash : public Singleton<Hash> {
9595
if (zobristKeyR == (k ^ data)) {
9696
return data;
9797
}
98-
#ifdef DEBUG_MODE
99-
if (data)
100-
readCollisions++;
101-
#endif
98+
99+
DEBUG(if (data) readCollisions++)
100+
102101
return 0;
103102
}
104103

@@ -122,11 +121,8 @@ class Hash : public Singleton<Hash> {
122121

123122
_Thash *rootHashA = &(hashArray[HASH_GREATER][kMod]);
124123

125-
#ifdef DEBUG_MODE
126-
if (rootHashA->u.dataU) {
127-
INC(collisions);
128-
}
129-
#endif
124+
DEBUG(if (rootHashA->u.dataU) INC(collisions))
125+
130126
if (rootHashA->u.dataS.depth >= tmp.dataS.depth && rootHashA->u.dataS.entryAge) {
131127
return;
132128
}

src/IterativeDeeping.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void IterativeDeeping::run() {
9494

9595
string tb = searchManager.probeRootTB();
9696
if (!tb.empty()) {
97-
debug("info string returned move from TB\n");
97+
debug("info string returned move from TB\n")
9898
_Tmove move;
9999
searchManager.getMoveFromSan(tb, &move);
100100
searchManager.makemove(&move);
@@ -119,24 +119,24 @@ void IterativeDeeping::run() {
119119
int extension = 0;
120120
string ponderMove;
121121
searchManager.init();
122-
int mateIn = INT_MAX;
122+
123123
string pvv;
124124
_Tmove resultMove;
125125

126-
#ifdef DEBUG_MODE
127-
u64 totMovesPrec = -1;
128-
#endif
126+
127+
DEBUG(u64 totMovesPrec = -1)
128+
129129
while (searchManager.getRunning(0)) {
130130
totMoves = 0;
131131
++mply;
132132
searchManager.init();
133133

134-
auto sc =searchManager.search(mply);
134+
auto sc = searchManager.search(mply);
135135

136136
searchManager.setRunningThread(1);
137137
searchManager.setRunning(1);
138-
if (!searchManager.getRes(resultMove, ponderMove, pvv, &mateIn)) {
139-
debug("IterativeDeeping cmove == 0. Exit");
138+
if (!searchManager.getRes(resultMove, ponderMove, pvv)) {
139+
debug("IterativeDeeping cmove == 0. Exit")
140140
break;
141141
}
142142

@@ -146,7 +146,6 @@ void IterativeDeeping::run() {
146146
timeTaken = Time::diffTime(end1, start1) + 1;
147147
totMoves += searchManager.getTotMoves();
148148

149-
150149
if (sc > _INFINITE - MAX_PLY) {
151150
sc = 0x7fffffff;
152151
}
@@ -236,8 +235,7 @@ void IterativeDeeping::run() {
236235
if (searchManager.getForceCheck()) {
237236
searchManager.setForceCheck(inMate);
238237
searchManager.setRunning(1);
239-
240-
} else if (abs(sc) > _INFINITE - MAX_PLY) {
238+
} else if (mply == 1 && abs(sc) > _INFINITE - MAX_PLY) {
241239
searchManager.setForceCheck(true);
242240
searchManager.setRunning(2);
243241

src/IterativeDeeping.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class IterativeDeeping : public Thread<IterativeDeeping> {
7575

7676
private:
7777

78-
#ifdef DEBUG_MODE
79-
atomic_int checkSmp2;
80-
#endif
78+
79+
DEBUG(atomic_int checkSmp2)
80+
8181
SearchManager &searchManager = Singleton<SearchManager>::getInstance();
8282
int maxDepth;
8383
string bestmove;

0 commit comments

Comments
 (0)