Cinnamon  1.0
chess engine
main.cpp
Go to the documentation of this file.
00001 #include "Uci.h"
00002 #include <unistd.h>
00003 #include "namespaces.h"
00004 
00005 /*
00006  8| 63 62 61 60 59 58 57 56
00007  7| 55 54 53 52 51 50 49 48
00008 6| 47 46 45 44 43 42 41 40
00009  5| 39 38 37 36 35 34 33 32
00010  4| 31 30 29 28 27 26 25 24
00011  3| 23 22 21 20 19 18 17 16
00012  2| 15 14 13 12 11 10 09 08
00013  1| 07 06 05 04 03 02 01 00
00014  ...a  b  c  d  e  f  g  h
00015 
00016 
00017 rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
00018  Depth  Perft
00019  1              20                              verified
00020  2      400                     verified
00021  3              8902                    verified
00022  4              197281                  verified
00023  5              4865609                 verified
00024  6              119060324               verified
00025  7              3195901860      verified
00026  8              84998978956     verified
00027  9              2439530234167   verified
00028 
00029 r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
00030  Depth  Perft
00031  1              48              verified
00032  2              2039            verified
00033  3              97862           verified
00034  4              4085603         verified
00035  5              193690690       verified
00036  6              8031647685      verified
00037  7      374190009323    verified
00038 
00039 rnbqkbnr/pp1ppppp/8/2pP4/8/8/PPP1PPPP/RNBQKBNR w KQkq c6 0 2
00040 Depth   Perft
00041  1      30              verified
00042  2      631             verified
00043  3      18825           verified
00044  4      437149          verified
00045  5      13787913        verified
00046 
00047  */
00048 
00049 using namespace _board;
00050 
00051 int main(int argc, char **argv) {
00052     _bits::init();
00053     cout << NAME;
00054     cout <<" UCI (ex Butterfly) by Giuseppe Cannella" << endl;
00055 #if UINTPTR_MAX == 0xffffffffffffffff
00056     cout<<"64-bit";
00057 #else
00058     cout<<"32-bit";
00059 #endif
00060     cout << " version compiled " << __DATE__ << " with gcc " << __VERSION__ << endl;
00061     cout <<"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"<<endl<<endl;
00062 #ifdef DEBUG_MODE
00063     cout << "DEBUG_MODE"<<endl;
00064 #endif
00065 #ifdef NO_FP_MODE
00066     cout << "NO FP_MODE"<<endl;
00067 #endif
00068 #ifdef NO_HASH_MODE
00069     cout << "NO HASH_MODE"<<endl;
00070 #endif
00071     char opt;
00072     while ((opt = getopt(argc, argv, "bp:")) != -1) {
00073         if (opt=='b') {
00074             IterativeDeeping* it = new IterativeDeeping();
00075             it->setUseBook(false);
00076             it->setMaxTimeMillsec(40000);
00077             it->run();
00078             delete it;
00079             _bits::_free();
00080             return 0;
00081         } else if (opt == 'p') { // perft test
00082             const string error ="use: -perft [-d depth] [-c nCpu] [-h hash size (Mb)] [-f \"fen position\"]";
00083             if(string(optarg)!="erft") {
00084                 cout <<error <<endl;
00085                 _bits::_free();
00086                 return 1;
00087             };
00088 #ifdef NO_HASH_MODE
00089             #error "recompile without -DNO_HASH_MODE"
00090 #endif
00091             int nCpu = 1;
00092             int perftDepth = 1;
00093             string fen;
00094             int PERFT_HASH_SIZE = 0;
00095             while ((opt = getopt(argc, argv, "d:f:h:f:c:")) != -1) {
00096                 if (opt == 'd') { //depth
00097                     perftDepth = atoi(optarg);
00098                 } else if (opt == 'c') { //N cpu
00099                     nCpu = atoi(optarg);
00100                 } else if (opt == 'h') { //hash
00101                     PERFT_HASH_SIZE = atoi(optarg);
00102                 } else if (opt == 'f') { //fen
00103                     fen = optarg;
00104                 }
00105             }
00106             if (perftDepth > GenMoves::MAX_PLY || perftDepth <= 0 || nCpu > 32 || nCpu <= 0 || PERFT_HASH_SIZE > 32768 || PERFT_HASH_SIZE < 0) {
00107                 cout << error <<endl;
00108                 _bits::_free();
00109                 return 1;
00110             }
00111 
00112             if(fen.empty())fen=STARTPOS;
00113             cout << argv[0]<<" -perft -d "<<perftDepth<<" -c "<<nCpu<<" -h "<< PERFT_HASH_SIZE<< " -f \""<< fen <<"\""<<endl;
00114             Perft* p = new Perft(fen, perftDepth, nCpu, PERFT_HASH_SIZE);
00115             delete p;
00116             return 0;
00117         }
00118     }
00119     Uci* uci = new Uci();
00120     delete uci;
00121     _bits::_free();
00122     return 0;
00123 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines