1 /***************************************************************************
4 begin : Fri Jan 11 2002
5 copyright : (C) 2002-2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
26 //--------------------------------------------------------------------------------------------
29 int main(int argc
, char *argv
[])
31 #if defined(_WIN32) || defined(_WIN64)
36 //setvbuf(stdin, NULL, _IOLBF, 0);
38 setvbuf(stdout
, NULL
, _IOLBF
, 0);
41 Engine
*eng
= new Engine();
43 /*#define PRINT_SIZE(c) printf("sizeof(" #c ") = %ld\n", sizeof(c))
46 PRINT_SIZE(HashEntry);
47 PRINT_SIZE(LinePawns);
48 PRINT_SIZE(MatTrack);*/
50 if(argc
>=2 && !strcmp(argv
[1], "-a"))
53 if(argc
>=4 && !strcmp(argv
[1], "-b"))
56 eng
->set_depth(atoi(argv
[2]));
57 for(int i
=3;i
<argc
;i
++)
59 FILE* f
= fopen(argv
[i
],"r");
66 printf("\nanalyzing %s\n", argv
[i
]);
67 eng
->find_best_move();
68 tot_nodes
+= eng
->processed_nodes
;
71 printf("\ntot processed nodes is %d\n", tot_nodes
);
75 if(argc
>=3 && !strcmp(argv
[1], "-e"))
77 for(int i
=2;i
<argc
;i
++)
79 FILE* f
= fopen(argv
[i
],"r");
93 eng
->read_board("r2rb1k1/pp1q1p1p/2n1p1p1/2bp4/5P2/PP1BPR1Q/1BPN2PP/R5K1 w - - 0 1");
95 eng
->find_best_move();
101 int prev_move_index
= 999;
102 int prev_move_val
= 0;
108 if(eng
->eng_status
==ANALYZING
)
112 else if(eng
->computer_color() != eng
->color_to_move()
113 || eng
->get_status() != PLAYING
) //wait for command or move...
115 if(eng
->ponder
&& eng
->eng_status
==PLAYING
&&
116 eng
->status
== PLAYING
&&
117 eng
->st_computer_color
== eng
->board
.other_color
)
120 eng
->process_input();
124 if(prev_move_index
> eng
->mv_done_num
)
125 prev_move_val
= +INF
;
126 prev_move_index
= eng
->mv_done_num
;
128 Move mv
= eng
->find_best_move();
129 int t
= current_time(); ////
130 if(t
< eng
->max_think_time
-5) ////
132 printf("# will simulate a human think %d centiseconds\n", 50*(eng
->max_think_time
-t
));
133 usleep(5000*(eng
->max_think_time
-t
)); ////
136 //// if(mv.val > prev_move_val+200 && mv.capture && PIECE_OF(mv.capture) != PAWN)
137 //// eng->output("tellicsnoalias say Chomp!\n");
139 prev_move_val
= mv
.val
;
142 eng
->print_moves(&mv
,1);
144 if(eng
->io_xboard
&& !eng
->io_san
)
145 eng
->output("move %s\n",eng
->move_to_coord(str
,&mv
));
147 eng
->output("move %s\n",eng
->move_to_alg(str
,&mv
));
155 if(eng
->get_status()!=PLAYING
&& message
)
158 eng
->output("%s {%s}\n", eng
->status
==_01
?"0-1":
159 eng
->status
==_10
?"1-0":"1/2-1/2",
160 eng
->status_string
);