1 /***************************************************************************
4 begin : Fri Jan 11 2002
5 copyright : (C) 2002-2005 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)
41 // printf("telluser \"cwd = %s\"\n", cwd);
42 // printf("telluser \"sizeof(uint64_t) = %d, sizeof HashKey = %d\"\n", sizeof(uint64_t), sizeof(HashKey));
45 Engine
*eng
= new Engine();
47 /*#define PRINT_SIZE(c) printf("sizeof(" #c ") = %ld\n", sizeof(c))
50 PRINT_SIZE(HashEntry);
51 PRINT_SIZE(LinePawns);
52 PRINT_SIZE(MatTrack);*/
54 if(argc
>=2 && !strcmp(argv
[1], "-a"))
57 if(argc
>=4 && !strcmp(argv
[1], "-b"))
60 eng
->set_depth(atoi(argv
[2]));
61 for(int i
=3;i
<argc
;i
++)
63 FILE* f
= fopen(argv
[i
],"r");
70 printf("\nanalyzing %s\n", argv
[i
]);
71 eng
->find_best_move();
72 tot_nodes
+= eng
->processed_nodes
;
75 printf("\ntot processed nodes is %d\n", tot_nodes
);
79 if(argc
>=3 && !strcmp(argv
[1], "-e"))
81 for(int i
=2;i
<argc
;i
++)
83 FILE* f
= fopen(argv
[i
],"r");
97 eng
->read_board("r2rb1k1/pp1q1p1p/2n1p1p1/2bp4/5P2/PP1BPR1Q/1BPN2PP/R5K1 w - - 0 1");
99 eng
->find_best_move();
105 int prev_move_index
= 999;
106 int prev_move_val
= 0;
112 if(eng
->eng_status
==ANALYZING
)
116 else if(eng
->computer_color() != eng
->color_to_move()
117 || eng
->get_status() != PLAYING
) //wait for command or move...
119 if(eng
->ponder
&& eng
->eng_status
==PLAYING
&&
120 eng
->status
== PLAYING
&&
121 eng
->st_computer_color
== eng
->board
.other_color
)
124 eng
->process_input();
128 if(prev_move_index
> eng
->mv_done_num
)
129 prev_move_val
= +INF
;
130 prev_move_index
= eng
->mv_done_num
;
132 Move mv
= eng
->find_best_move();
134 if(mv
.val
> prev_move_val
+200 && mv
.capture
&& PIECE_OF(mv
.capture
) != PAWN
)
135 eng
->output("tellicsnoalias say Chomp!\n");
136 //eng->output("telluser Chomp!\n");
137 prev_move_val
= mv
.val
;
140 eng
->print_moves(&mv
,1);
142 if(eng
->io_xboard
&& !eng
->io_san
)
143 eng
->output("move %s\n",eng
->move_to_coord(str
,&mv
));
145 eng
->output("move %s\n",eng
->move_to_alg(str
,&mv
));
153 if(eng
->get_status()!=PLAYING
&& message
)
156 eng
->output("%s {%s}\n", eng
->status
==_01
?"0-1":
157 eng
->status
==_10
?"1-0":"1/2-1/2",
158 eng
->status_string
);