Skip to content

Commit 2f00b68

Browse files
author
Giuseppe Cannella
committed
v2.1
1 parent 67d5798 commit 2f00b68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+10505
-2215
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.dll
2+
*.exe
3+
*.o
4+
*.so
5+
cmake-build-debug
6+
CMakeCache.txt
7+
CMakeFiles
8+
cmake_install.cmake
9+
CMakeCache.txt
10+
CMakeFiles/
11+
cmake_install.cmake
12+
*.log
13+
.DS_Store
14+
.DS_Store?
15+
.Trashes
16+
*.gcda
17+
src/cinnamon
18+
libCinnamon.a
19+
.idea/

README.md

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Cinnamon
22
==========
3-
###UCI Chess Engine
3+
### UCI Chess Engine
44

5-
Cinnamon is a chess program for Windows, Linux, Mac OS, Android and ARM, is a console-based chess engine for use with
5+
Cinnamon is a chess program for Windows, Linux, Mac OS, Android and Raspberry Pi, is a console-based chess engine for use with
66
[xboard][4],
77
[Arena][5],
88
[Tarrasch][6],
@@ -12,23 +12,21 @@ or any UCI-compatible GUI. Cinnamon is also a javascript library to play with
1212

1313
Version
1414
----------
15-
2.0
15+
2.1
1616

1717
Features
1818
----------
1919
20-
2120
- Available for both Unix, Windows, Mac, Android, ARM and Javascript
22-
- GPL 3 License
2321
- UCI protocol
24-
- Parallel Search - Lazy SMP
22+
- GPL 3 License
2523
- C++11 source
2624
- Rotated bitboards
2725
- Null moves
2826
- Futility pruning
2927
- Delta pruning
3028
- Razoring
31-
- Interruptible multithread [Perft][9] test
29+
- Interruptible multithread Perft test
3230
- 32/64 bit architectures
3331
- Iterative deeping
3432
- Killer heuristics
@@ -41,7 +39,6 @@ Features
4139
- Available with Tarrasch GUI for Windows
4240
- Open Book (Polyglot)
4341
- Gaviota Tablebases
44-
- [Source doc][2]
4542
- [Elo ratings][3]
4643

4744

@@ -55,34 +52,24 @@ All files are compiled statically, no further libraries are necessary.
5552
Compiling
5653
---------
5754

58-
Cinnamon requires C++11, use unique Makefile to compile for many architectures:
55+
Cinnamon requires C++11 or greater, use unique Makefile to compile for many architectures:
5956

6057
$ make
6158

62-
Makefile for cross-compile Linux/Windows/OSX/ARM/Javascript
63-
64-
make cinnamon64-modern-INTEL > 64-bit optimized for modern Intel cpu
65-
make cinnamon64-modern-AMD > 64-bit optimized for modern Amd cpu
66-
make cinnamon64-modern > 64-bit with popcnt bsf sse3 support
67-
make cinnamon64-generic > Unspecified 64-bit
68-
make cinnamon64-ARM > Optimized for arm cpu
69-
70-
make cinnamon32-modern > 32-bit with sse support
71-
make cinnamon32-generic > Unspecified 32-bit
72-
make cinnamon32-ARM > Optimized for arm cpu
73-
74-
make cinnamon-js > Javascript build
75-
76-
make cinnamon-drmemory > Memory monitor
77-
make cinnamon-profiler > Google profiler tool
78-
make cinnamon-gprof > Gnu profiler tool
79-
80-
add:
81-
COMP=compiler > Use another compiler
82-
PROFILE_GCC=yes > PGO build
83-
FULL_TEST=yes > Unit test
84-
LIBSTDC=-static > Link statically libstdc++
59+
Makefile for cross-compile Linux/Windows/OSX/Raspberry
60+
61+
make cinnamon64-modern-INTEL > 64-bit optimized for modern Intel cpu
62+
make cinnamon64-modern-AMD > 64-bit optimized for modern Amd cpu
63+
make cinnamon64-modern > 64-bit with popcnt bsf sse3 support
64+
make cinnamon64-generic > Unspecified 64-bit
65+
make cinnamon64-ARM > Optimized for ARM cpu
66+
67+
make cinnamon32-modern > 32-bit with sse support
68+
make cinnamon32-generic > Unspecified 32-bit
69+
make cinnamon32-ARM > Optimized for ARM cpu
8570

71+
g++ is the default compiler, add COMP=yourcompiler to use another compiler
72+
example: make cinnamon64-modern-INTEL COMP=clang++
8673

8774

8875
License
@@ -96,11 +83,9 @@ Credits
9683
Cinnamon was written by Giuseppe Cannella at gmail dot com.
9784

9885
[1]: http://cinnamonchess.altervista.org
99-
[2]: http://cinnamonchess.altervista.org/api/2.0/_uci_8h.html
10086
[3]: http://www.computerchess.org.uk/ccrl/404/cgi/compare_engines.cgi?family=Cinnamon
10187
[4]: http://www.gnu.org/software/xboard
10288
[5]: http://www.playwitharena.com
10389
[6]: http://triplehappy.com
10490
[7]: https://play.google.com/store/apps/details?id=com.google.android.chess
10591
[8]: http://chessboardjs.com
106-
[9]: http://cinnamonchess.altervista.org/perft.html
Lines changed: 197 additions & 53 deletions
Large diffs are not rendered by default.

src/ChessBoard.cpp

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ChessBoard::ChessBoard() {
2323
memset(&structureEval, 0, sizeof(_Tboard));
2424
if ((chessboard[SIDETOMOVE_IDX] = loadFen(fenString)) == 2) {
2525
fatal("Bad FEN position format ", fenString);
26-
std::_Exit(1);
26+
std::exit(1);
2727
}
2828
}
2929

@@ -45,23 +45,26 @@ int ChessBoard::getPieceAt(int side, u64 bitmapPos) {
4545

4646
void ChessBoard::makeZobristKey() {
4747
chessboard[ZOBRISTKEY_IDX] = 0;
48+
4849
for (int u = 0; u < 12; u++) {
49-
u64 c = chessboard[u];
50-
while (c) {
51-
int position = BITScanForward(c);
50+
for (u64 c = chessboard[u]; c; RESET_LSB(c)) {
51+
const int position = BITScanForward(c);
5252
updateZobristKey(u, position);
53-
RESET_LSB(c);
5453
}
5554
}
56-
if (chessboard[ENPASSANT_IDX] != NO_ENPASSANT) {
57-
updateZobristKey(ENPASSANT_IDX, chessboard[ENPASSANT_IDX]);
55+
56+
57+
for (u64 x2 = chessboard[RIGHT_CASTLE_IDX]; x2; RESET_LSB(x2)) {
58+
const int position = BITScanForward(x2);
59+
updateZobristKey(RIGHT_CASTLE_IDX, position);//12
5860
}
59-
u64 x2 = chessboard[RIGHT_CASTLE_IDX];
60-
while (x2) {
61-
int position = BITScanForward(x2);
62-
updateZobristKey(14, position);
63-
RESET_LSB(x2);
61+
62+
if (chessboard[ENPASSANT_IDX] != NO_ENPASSANT) {
63+
updateZobristKey(ENPASSANT_IDX, chessboard[ENPASSANT_IDX]);//13
6464
}
65+
66+
updateZobristKey(SIDETOMOVE_IDX, getSide()); //14
67+
6568
}
6669

6770

@@ -78,15 +81,16 @@ int ChessBoard::getPieceByChar(char c) {
7881
}
7982

8083

81-
void ChessBoard::display() {
84+
void ChessBoard::display() const {
8285
cout << "\n a b c d e f g h";
8386
for (int t = 0; t <= 63; t++) {
8487
char x = ' ';
8588
if (t % 8 == 0) {
8689
cout << "\n ----+---+---+---+---+---+---+----\n";
8790
cout << " " << 8 - RANK_AT[t] << " | ";
8891
}
89-
x = (x = (x = FEN_PIECE[getPieceAt<WHITE>(POW2[63 - t])]) != '-' ? x : FEN_PIECE[getPieceAt<BLACK>(POW2[63 - t])]) == '-' ? ' ' : x;
92+
x = (x = (x = FEN_PIECE[getPieceAt<WHITE>(POW2[63 - t])]) != '-' ? x : FEN_PIECE[getPieceAt<BLACK>(
93+
POW2[63 - t])]) == '-' ? ' ' : x;
9094
x != ' ' ? cout << x : POW2[t] & WHITE_SQUARES ? cout << " " : cout << ".";
9195
cout << " | ";
9296
};
@@ -159,7 +163,8 @@ string ChessBoard::boardToFen() const {
159163
fen.append(" -");
160164
} else {
161165
fen.append(" ");
162-
chessboard[SIDETOMOVE_IDX] ? fen.append(BOARD[chessboard[ENPASSANT_IDX] + 8]) : fen.append(BOARD[chessboard[ENPASSANT_IDX] - 8]);
166+
chessboard[SIDETOMOVE_IDX] ? fen.append(BOARD[chessboard[ENPASSANT_IDX] + 8]) : fen.append(
167+
BOARD[chessboard[ENPASSANT_IDX] - 8]);
163168
}
164169
fen.append(" 0 1");
165170
return fen;
@@ -171,7 +176,7 @@ char ChessBoard::decodeBoard(string a) {
171176
return i;
172177
}
173178
}
174-
cout << "\n" << a << endl;
179+
error(a);
175180
ASSERT(0);
176181
return -1;
177182
}
@@ -232,22 +237,22 @@ int ChessBoard::loadFen(string fen) {
232237
switch (castle.at(e)) {
233238
case 'K':
234239
updateZobristKey(RIGHT_CASTLE_IDX, 4);
235-
ASSERT(BITScanForward(4 == RIGHT_KING_CASTLE_WHITE_MASK));
240+
ASSERT(4 == BITScanForward(RIGHT_KING_CASTLE_WHITE_MASK));
236241
chessboard[RIGHT_CASTLE_IDX] |= RIGHT_KING_CASTLE_WHITE_MASK;
237242
break;
238243
case 'k':
239244
updateZobristKey(RIGHT_CASTLE_IDX, 6);
240-
ASSERT(BITScanForward(6 == RIGHT_KING_CASTLE_BLACK_MASK));
245+
ASSERT(6 == BITScanForward(RIGHT_KING_CASTLE_BLACK_MASK));
241246
chessboard[RIGHT_CASTLE_IDX] |= RIGHT_KING_CASTLE_BLACK_MASK;
242247
break;
243248
case 'Q':
244249
updateZobristKey(RIGHT_CASTLE_IDX, 5);
245-
ASSERT(BITScanForward(5 == RIGHT_QUEEN_CASTLE_WHITE_MASK));
250+
ASSERT(5 == BITScanForward(RIGHT_QUEEN_CASTLE_WHITE_MASK));
246251
chessboard[RIGHT_CASTLE_IDX] |= RIGHT_QUEEN_CASTLE_WHITE_MASK;
247252
break;
248253
case 'q':
249254
updateZobristKey(RIGHT_CASTLE_IDX, 7);
250-
ASSERT(BITScanForward(7 == RIGHT_QUEEN_CASTLE_BLACK_MASK));
255+
ASSERT(7 == BITScanForward(RIGHT_QUEEN_CASTLE_BLACK_MASK));
251256
chessboard[RIGHT_CASTLE_IDX] |= RIGHT_QUEEN_CASTLE_BLACK_MASK;
252257
break;
253258
default:;
@@ -279,4 +284,4 @@ bool ChessBoard::checkNPieces(std::unordered_map<int, int> pieces) {
279284
return a == 13;
280285
}
281286

282-
#endif
287+
#endif

0 commit comments

Comments
 (0)