| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | $NetBSD: patch-ad,v 1.5 2013/04/30 22:20:58 joerg Exp $ | | 1 | $NetBSD: patch-ad,v 1.6 2014/02/09 16:50:45 wiedi Exp $ |
2 | | | 2 | |
3 | --- main.cpp.orig 2000-04-01 07:46:20.000000000 +0000 | | 3 | --- main.cpp.orig 2000-04-01 07:46:20.000000000 +0000 |
4 | +++ main.cpp | | 4 | +++ main.cpp |
5 | @@ -3,20 +3,23 @@ | | 5 | @@ -3,20 +3,23 @@ |
6 | | | 6 | |
7 | /* Main functions controlling program */ | | 7 | /* Main functions controlling program */ |
8 | | | 8 | |
9 | -#include <iostream.h> | | 9 | -#include <iostream.h> |
10 | -#include <iomanip.h> | | 10 | -#include <iomanip.h> |
11 | +#include <iostream> | | 11 | +#include <iostream> |
12 | +#include <iomanip> | | 12 | +#include <iomanip> |
13 | #include <stdlib.h> | | 13 | #include <stdlib.h> |
14 | #include <string.h> | | 14 | #include <string.h> |
| @@ -19,27 +19,27 @@ $NetBSD: patch-ad,v 1.5 2013/04/30 22:20 | | | @@ -19,27 +19,27 @@ $NetBSD: patch-ad,v 1.5 2013/04/30 22:20 |
19 | +#include <fstream> | | 19 | +#include <fstream> |
20 | | | 20 | |
21 | #include "define.h" | | 21 | #include "define.h" |
22 | | | 22 | |
23 | +using namespace std; | | 23 | +using namespace std; |
24 | + | | 24 | + |
25 | #if UNIX | | 25 | #if UNIX |
26 | #include <sys/types.h> | | 26 | #include <sys/types.h> |
27 | #include <sys/time.h> | | 27 | #include <sys/time.h> |
28 | + #include <unistd.h> | | 28 | + #include <unistd.h> |
29 | #else | | 29 | #else |
30 | #include <windows.h> | | 30 | #include <windows.h> |
31 | #include <time.h> | | 31 | #include <time.h> |
32 | @@ -42,21 +45,21 @@ int omttc = 0, mttc = 0, inc = 0; float | | 32 | @@ -42,21 +45,21 @@ int omttc = 0, mttc = 0, inc = 0; float |
33 | int display_board = 0; | | 33 | int display_board = 0; |
34 | int analysis_mode = 0; | | 34 | int analysis_mode = 0; |
35 | extern int fail; // flag for fail high/fail low from search | | 35 | extern int fail; // flag for fail high/fail low from search |
36 | -extern move ponder_move; | | 36 | -extern move ponder_move; |
37 | +extern my_move ponder_move; | | 37 | +extern my_move ponder_move; |
38 | extern int logging; | | 38 | extern int logging; |
39 | | | 39 | |
40 | ofstream logfile; | | 40 | ofstream logfile; |
41 | int MAX_LOGS = 100; | | 41 | int MAX_LOGS = 100; |
42 | | | 42 | |
43 | // xboard flag | | 43 | // xboard flag |
44 | -int xboard, post, ics, ALLEG = 0, hintflag = 0, count = 1; | | 44 | -int xboard, post, ics, ALLEG = 0, hintflag = 0, count = 1; |
45 | +int xboard, post, ics, ALLEG = 0, hintflag = 0, my_count = 1; | | 45 | +int xboard, post, ics, ALLEG = 0, hintflag = 0, my_count = 1; |
| @@ -86,31 +86,85 @@ $NetBSD: patch-ad,v 1.5 2013/04/30 22:20 | | | @@ -86,31 +86,85 @@ $NetBSD: patch-ad,v 1.5 2013/04/30 22:20 |
86 | + logfile.open(lfile, ios::out); | | 86 | + logfile.open(lfile, ios::out); |
87 | if(logfile) break; | | 87 | if(logfile) break; |
88 | } | | 88 | } |
89 | if(!logfile) { | | 89 | if(!logfile) { |
90 | @@ -164,7 +158,7 @@ int main(int argc, char *argv[]) | | 90 | @@ -164,7 +158,7 @@ int main(int argc, char *argv[]) |
91 | | | 91 | |
92 | /* main loop */ | | 92 | /* main loop */ |
93 | | | 93 | |
94 | - while (count > 0) | | 94 | - while (count > 0) |
95 | + while (my_count > 0) | | 95 | + while (my_count > 0) |
96 | { | | 96 | { |
97 | | | 97 | |
98 | // find a hint move, check book first then look in pv | | 98 | // find a hint move, check book first then look in pv |
| | | 99 | @@ -204,14 +198,14 @@ int main(int argc, char *argv[]) |
| | | 100 | if(!game_pos.wtm) // if it is black's turn |
| | | 101 | { |
| | | 102 | if(both) p_side = 0; |
| | | 103 | - if(!xboard) cout << "Black-To-Move[" << ceil(T/2) << "]: "; |
| | | 104 | - if(logging) logfile << "Black-To-Move[" << ceil(T/2) << "]: "; |
| | | 105 | + if(!xboard) cout << "Black-To-Move[" << ceil((double)(T/2)) << "]: "; |
| | | 106 | + if(logging) logfile << "Black-To-Move[" << ceil((double)(T/2)) << "]: "; |
| | | 107 | } |
| | | 108 | else // or if it is white's |
| | | 109 | { |
| | | 110 | if(both) p_side = 1; |
| | | 111 | - if(!xboard) cout << "White-To-Move[" << (ceil(T/2) + 1) << "]: "; |
| | | 112 | - if(logging) logfile << "White-To-Move[" << (ceil(T/2) + 1) << "]: "; |
| | | 113 | + if(!xboard) cout << "White-To-Move[" << (ceil((double)(T/2)) + 1) << "]: "; |
| | | 114 | + if(logging) logfile << "White-To-Move[" << (ceil((double)(T/2)) + 1) << "]: "; |
| | | 115 | } |
| | | 116 | |
| | | 117 | cout.flush(); |
| | | 118 | @@ -322,12 +316,12 @@ void make_move() |
| | | 119 | if(p_side != game_pos.wtm) |
| | | 120 | { |
| | | 121 | if(game_pos.wtm) { |
| | | 122 | - cout << (ceil(T/2) + 1) << ". "; |
| | | 123 | + cout << (ceil((double)(T/2)) + 1) << ". "; |
| | | 124 | if(xboard) cout << "... "; |
| | | 125 | - if(logging) logfile << (ceil(T/2) + 1) << ". "; |
| | | 126 | + if(logging) logfile << (ceil((double)(T/2)) + 1) << ". "; |
| | | 127 | } else { |
| | | 128 | - cout << ceil(T/2) << ". ... "; |
| | | 129 | - if(logging) logfile << ceil(T/2) << ". ... "; |
| | | 130 | + cout << ceil((double)(T/2)) << ". ... "; |
| | | 131 | + if(logging) logfile << ceil((double)(T/2)) << ". ... "; |
| | | 132 | } |
| | | 133 | print_move(game_pos, best, mstring); |
| | | 134 | cout << mstring << "\n"; |
| | | 135 | @@ -558,7 +552,7 @@ void drawboard() |
| | | 136 | print_move(last_pos, game_pos.last, mstring); |
| | | 137 | cout << mstring; |
| | | 138 | } |
| | | 139 | - if(j==3) cout << " fifty: " << ceil(game_pos.fifty/2); |
| | | 140 | + if(j==3) cout << " fifty: " << ceil((double)(game_pos.fifty/2)); |
| | | 141 | if(j==2) cout << " Computer time: " << int(timeleft/100) << " seconds"; |
| | | 142 | } |
| | | 143 | cout << "\n +---+---+---+---+---+---+---+---+"; |
99 | @@ -745,7 +739,7 @@ void parse_command() | | 144 | @@ -745,7 +739,7 @@ void parse_command() |
100 | else if(!strcmp(response, "nopost")) { post = 0; } | | 145 | else if(!strcmp(response, "nopost")) { post = 0; } |
101 | else if(!strcmp(response, "probe")) { cout << probe_tb(&game_pos,0) << "\n"; } | | 146 | else if(!strcmp(response, "probe")) { cout << probe_tb(&game_pos,0) << "\n"; } |
102 | else if(!strcmp(response, "save") || !strcmp(response, "SR")) { save_game(); } | | 147 | else if(!strcmp(response, "save") || !strcmp(response, "SR")) { save_game(); } |
103 | - else if(!strcmp(response, "quit")) { game_over = 1; count = 0; } | | 148 | - else if(!strcmp(response, "quit")) { game_over = 1; count = 0; } |
104 | + else if(!strcmp(response, "quit")) { game_over = 1; my_count = 0; } | | 149 | + else if(!strcmp(response, "quit")) { game_over = 1; my_count = 0; } |
105 | else if(!strcmp(response, "performance")) { performance(); } | | 150 | else if(!strcmp(response, "performance")) { performance(); } |
106 | else if(!strcmp(response, "setboard")) | | 151 | else if(!strcmp(response, "setboard")) |
107 | { cin >> inboard >> ms >> castle >> ep; mttc = omttc; game_over = 0; | | 152 | { cin >> inboard >> ms >> castle >> ep; mttc = omttc; game_over = 0; |
108 | @@ -795,7 +789,7 @@ void performance() | | 153 | @@ -795,7 +789,7 @@ void performance() |
109 | // when the best move was first found and held on to. | | 154 | // when the best move was first found and held on to. |
110 | | | 155 | |
111 | float soltime; | | 156 | float soltime; |
112 | -int bmcount, tsuite = 0; move bmoves[10]; | | 157 | -int bmcount, tsuite = 0; move bmoves[10]; |
113 | +int bmcount, tsuite = 0; my_move bmoves[10]; | | 158 | +int bmcount, tsuite = 0; my_move bmoves[10]; |
114 | int best_depth, best_score; | | 159 | int best_depth, best_score; |
115 | extern int stage; | | 160 | extern int stage; |
116 | unsigned long nodes, nodes1, test_time, test_time1; | | 161 | unsigned long nodes, nodes1, test_time, test_time1; |
| | | 162 | @@ -1063,7 +1057,7 @@ void save_game() |
| | | 163 | for(int i = 1; i < TURN; i++) |
| | | 164 | { |
| | | 165 | print_move(game_pos, game_history[i-1], mstring); |
| | | 166 | - if (game_pos.wtm) outfile << (ceil(i/2) + 1) << ". " << mstring; |
| | | 167 | + if (game_pos.wtm) outfile << (ceil((double)(i/2)) + 1) << ". " << mstring; |
| | | 168 | else outfile << mstring; |
| | | 169 | outfile << " "; |
| | | 170 | if(!(T%8)) outfile << "\n"; |