Hi Dan, Thanks for the quick response. I know 3.2 uses a lot of resources. But it is the best way to get all the future versions of GnuGo to run on small device. Hopefully GnuGo will evolve also. I would particularly like to see GnuGo use some kind of database for patterns instead of compiling them in. Much more flexible, extensible and much less resource hungry. Here is the diff with gnugo-3.2 source code. And a small gtpclient (PS: I agree to GPL it) as a sample. The basic usage to run gnugo.exe first as the following: gnugo.exe --mode gtp --silent --port 5000 Then run gtpclient.exe from command line as: gtpclient.exe Obviously it can take server name and a port number. By default, it uses 5000. Then you can enter GTP command from the gtpclient window, such as showboard, black q4, etc. Let me know what you think. Best Regards, Sidney Liu --- bump@sporadic.stanford.edu wrote: > > > Hi, > > > > Thank you for a great Go player. I am interested > in > > porting Gnugo.exe to embedded device such as > WinCE. I > > know that there is a Pocket PC version 2.6. But I > > found that to be tightly integrated with a specifc > > GnuGo version. I am thinking of interfacing GnuGo > with > > GTP. I would like to add an option "-port" so that > > gnugo can listen directly on the port number. And > > other program such as UI can connect directly to > > gnugo.exe without another layer of translator. > Mainly > > because those devices have no std io. What is your > > thought on this? Can it be integrated to the next > > version of GnuGo? > > > > Best Regards, > > > > Sid Liu > > We'd be happy to support your efforts if we can, > though > our main emphasis is necessarily on improving the > engine. > > Can you send us a patch implementing this as you > want it? > > The reason that GNU Go 2.6 was ported to WinCE and > not 3.0 is that > 2.6 uses a lot less resources. While 3.2 uses less > resources than > 2.6 it still needs a lot more RAM. > > Dan > __________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com --0-1805802148-1030568836=:75520 Content-Type: text/plain; name="gnugo-3.2.diff" Content-Description: gnugo-3.2.diff Content-Disposition: inline; filename="gnugo-3.2.diff" diff -r -w -b -B gnugo-3.2/config.h gnugo.40/config.h 18a19,21 > #ifdef _WIN32_WCE > #define DEFAULT_MEMORY 8 > #else // _WIN32_WCE 19a23 > #endif // _WIN32_WCE 61a66,83 > #define ALLOW_NETWORK_PLAY > #define DEBUG_LOG_TO_FILE > #define USE_FILE_POINTER > > #ifndef _WIN32_WCE > > #define HAVE_IO_H > #define HAVE_TIME_H > #define HAVE_SIGNAL_H > #define HAVE_ERRNO_H > #define HAVE_ASSERT_H > > #else // _WIN32_WCE > > #define abort() exit(1) > > #endif // _WIN32_WCE > 62a85 > diff -r -w -b -B gnugo-3.2/config.vc gnugo.40/config.vc 18a19,21 > #ifdef _WIN32_WCE > #define DEFAULT_MEMORY 8 > #else // _WIN32_WCE 19a23 > #endif // _WIN32_WCE 61a66,83 > #define ALLOW_NETWORK_PLAY > #define DEBUG_LOG_TO_FILE > #define USE_FILE_POINTER > > #ifndef _WIN32_WCE > > #define HAVE_IO_H > #define HAVE_TIME_H > #define HAVE_SIGNAL_H > #define HAVE_ERRNO_H > #define HAVE_ASSERT_H > > #else // _WIN32_WCE > > #define abort() exit(1) > > #endif // _WIN32_WCE > 62a85 > diff -r -w -b -B gnugo-3.2/engine/clock.h gnugo.40/engine/clock.h 47a48,49 > > #ifdef HAVE_IO_H 48a51,53 > #endif // HAVE_IO_H > > #ifdef HAVE_TIME_H 49a55,56 > #endif // HAVE_TIME_H > 50a58,59 > > #ifdef HAVE_SYS_TIME_H 51a61,62 > #endif // HAVE_SYS_TIME_H > diff -r -w -b -B gnugo-3.2/engine/genmove.c gnugo.40/engine/genmove.c 31a32,35 > #ifdef DEBUG_LOG_TO_FILE > #include "gg_utils.h" > #endif // DEBUG_LOG_TO_FILE > 844a849 > diff -r -w -b -B gnugo-3.2/engine/gnugo.h gnugo.40/engine/gnugo.h 297a298 > #ifndef _WIN32_WCE 298a300,302 > #else // _WIN32_WCE > extern int time_to_die; /* set by signal handlers */ > #endif // _WIN32_WCE 320a325,328 > #ifdef ALLOW_NETWORK_PLAY > int is_hoshi_point(int m, int n); > #endif // ALLOW_NETWORK_PLAY > 364a373,377 > > #ifdef DEBUG > #undef DEBUG > #endif // DEBUG > diff -r -w -b -B gnugo-3.2/engine/influence.h gnugo.40/engine/influence.h 23a24 > #ifdef HAVE_ASSERT_H 24a26 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/engine/matchpat.c gnugo.40/engine/matchpat.c 26a27,28 > > #ifdef HAVE_ASSERT_H 27a30 > #endif // HAVE_ASSERT_H 824a828,829 > > #ifndef _WIN32_WCE 825a831,833 > #else // _WIN32_WCE > extern int *spiral[8]; > #endif // _WIN32_WCE 857a866,872 > #ifdef _WIN32_WCE > int i; > > for(i=0;i<8;i++) > spiral[i] = (int*)malloc(sizeof(int)*MAX_ORDER); > #endif // _WIN32_WCE > 1340a1356 > diff -r -w -b -B gnugo-3.2/engine/owl.c gnugo.40/engine/owl.c 62a63,64 > > #ifdef HAVE_TIME_H 63a66,67 > #endif // HAVE_TIME_H > diff -r -w -b -B gnugo-3.2/engine/sgffile.c gnugo.40/engine/sgffile.c 36a37 > #ifdef HAVE_SIGNAL_H 37a39 > #endif // HAVE_SIGNAL_H 465a468 > diff -r -w -b -B gnugo-3.2/engine/showbord.c gnugo.40/engine/showbord.c 80a81,83 > #ifdef ALLOW_NETWORK_PLAY > int > #else // ALLOW_NETWORK_PLAY 81a85 > #endif // ALLOW_NETWORK_PLAY diff -r -w -b -B gnugo-3.2/interface/debugboard/main.c gnugo.40/interface/debugboard/main.c 32a33,34 > > #ifdef HAVE_SYS_TIME_H 33a36,38 > #endif // HAVE_SYS_TIME_H > > #ifdef HAVE_TIME_H 34a40,41 > #endif // HAVE_TIME_H > 38a46,47 > > #ifdef HAVE_TIME_H 39a49,50 > #endif // HAVE_TIME_H > 50a62 > #ifdef HAVE_IO_H 51a64 > #endif // HAVE_IO_H diff -r -w -b -B gnugo-3.2/interface/gmp.c gnugo.40/interface/gmp.c 23a24 > #ifdef HAVE_ASSERT_H 24a26,27 > #endif // HAVE_ASSERT_H > 28a32,35 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > 29a37,38 > > #ifdef HAVE_SYS_TIME_H 30a40,42 > #endif // HAVE_SYS_TIME_H > > #ifdef HAVE_TIME_H 31a44,45 > #endif // HAVE_TIME_H > 35a50,51 > > #ifdef HAVE_TIME_H 36a53,54 > #endif // HAVE_TIME_H > 51a70,71 > > #ifdef HAVE_IO_H 52a73,74 > #endif // HAVE_IO_H > 54a77,80 > #ifdef DEBUG_LOG_TO_FILE > #include "gg_utils.h" > #endif // DEBUG_LOG_TO_FILE > 81a108,110 > #ifdef USE_FILE_POINTER > FILE *inFile, *outFile; > #else // USE_FILE_POINTER 82a112 > #endif // USE_FILE_POINTER 92a123 > #ifndef _WIN32_WCE 93a125,127 > #else // _WIN32_WCE > double lastSendTime; > #endif // _WIN32_WCE 149c183,185 < --- > #ifdef USE_FILE_POINTER > Gmp *gmp_create(FILE* inFile, FILE* outFile) { > #else // USE_FILE_POINTER 150a187 > #endif // USE_FILE_POINTER 218a256 > #ifndef _WIN32_WCE 219a258,260 > #else // _WIN32_WCE > if (gg_gettimeofday() != ge->lastSendTime) { > #endif // _WIN32_WCE 226c267 < FD_SET(ge->inFile, &readReady); --- > FD_SET((int)ge->inFile, &readReady); 232,233c273,274 < select(ge->inFile + 1, &readReady, NULL, NULL, &noTime); < if (!gsleep && !FD_ISSET(ge->inFile, &readReady)) --- > select((int)ge->inFile + 1, &readReady, NULL, NULL, &noTime); > if (!gsleep && !FD_ISSET((int)ge->inFile, &readReady)) 246a288,291 > #ifdef USE_FILE_POINTER > fflush(ge->inFile); > count = fread(charsIn, sizeof(char), 4 - ge->recvSoFar, ge->inFile); > #else // USE_FILE_POINTER 247a293 > #endif // USE_FILE_POINTER 478a525 > #ifndef _WIN32_WCE 479a527,529 > #else > ge->lastSendTime = gg_gettimeofday(); > #endif // _WIN32_WCE 486a537,540 > #ifdef USE_FILE_POINTER > fwrite(ge->sendData, sizeof(char), 4, ge->outFile); > fflush(ge->outFile); > #else // USE_FILE_POINTER 487a542 > #endif // USE_FILE_POINTER 706a762,765 > #ifdef USE_FILE_POINTER > fwrite(ge->sendData, sizeof(char), 4, ge->outFile); > fflush(ge->outFile); > #else // USE_FILE_POINTER 707a767 > #endif // USE_FILE_POINTER 820a881 > diff -r -w -b -B gnugo-3.2/interface/gmp.h gnugo.40/interface/gmp.h 45a46,48 > #ifdef USE_FILE_POINTER > extern Gmp *gmp_create(FILE* inFile, FILE* outFile); > #else // USE_FILE_POINTER 46a50 > #endif // USE_FILE_POINTER diff -r -w -b -B gnugo-3.2/interface/gtp.c gnugo.40/interface/gtp.c 42a43,46 > > #define ALLOW_NETWORK_PLAY > > #ifdef HAVE_ASSERT_H 43a48,52 > #endif // HAVE_ASSERT_H > > #ifdef ALLOW_NETWORK_PLAY > #include > #endif // ALLOW_NETWORK_PLAY 46a56,59 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > 64a78,210 > #ifdef ALLOW_NETWORK_PLAY > > static SOCKET sock = -1; > > int write_socket_data(char *buffer,int N) > { > int total=0; > int ret, selrtn; > fd_set fds; > > while (total < N) > { > FD_ZERO(&fds); > FD_SET(sock,&fds); > > selrtn = select(sock,NULL,&fds,NULL,NULL); > > /* Check if error */ > if(selrtn == -1) > { > /* something is wrong. Maybe the socket is dead? */ > printf("Something is wrong\n"); > return -3; > } > > /* Did we timeout ? */ > if (selrtn == 0) > { > printf("timeout\n"); > return -2; > } > > ret = send(sock, buffer + total, N - total,0); > > if (ret == SOCKET_ERROR ) { > printf("write_socket_data: write failure. Error = %d\n", WSAGetLastError()); > return -1; > } > if (ret == 0) return total; > > total += ret; > } > return total; > } > > /* Read from socket linewise and interpret as GTP commands. */ > void gtp_main_loop_network(struct gtp_command commands[], SOCKET localsock) > { > char line[GTP_BUFSIZE]; > char command[GTP_BUFSIZE]; > char *p; > int i; > int id; > int n; > int status = GTP_OK, rc; > fd_set fds; > int selrtn; > > sock = localsock; > > while (status == GTP_OK) > { > /* Read a line */ > > FD_ZERO(&fds); > FD_SET(sock,&fds); > > selrtn = select(sock,&fds,NULL,NULL,NULL); > > /* Check if error */ > if(selrtn == -1) > { > /* something is wrong. Maybe the socket is dead? */ > printf("Client Recv: Something is wrong\n"); > break; > } > > /* Did we timeout ? */ > if (selrtn == 0) > { > printf("Client Recv: timeout\n"); > break; > } > > rc = recv (sock, line, sizeof(line), 0); > > // Check if there is any data received. If there is, display it. > if (rc == SOCKET_ERROR) > { > printf ("No data is received, recv failed. Error: %d", WSAGetLastError ()); > break; > } > else if (rc == 0) > { > // Done > break; > } > > /* Remove comments. */ > if ((p = strchr(line, '#')) != NULL) > *p = 0; > > p = line; > > /* Look for an identification number. */ > if (sscanf(p, "%d%n", &id, &n) == 1) > p += n; > else > id = -1; /* No identification number. */ > > /* Look for command name. */ > if (sscanf(p, " %s %n", command, &n) < 1) > continue; /* Whitespace only on this line, ignore. */ > p += n; > > /* Search the list of commands and call the corresponding function > * if it's found. > */ > for (i = 0; commands[i].name != NULL; i++) { > if (strcmp(command, commands[i].name) == 0) { > status = (*commands[i].function)(p, id); > break; > } > } > if (commands[i].name == NULL) > gtp_failure(id, "unknown command: '%s'", command); > > if (status == GTP_FATAL) > gtp_panic(); > } > } > #endif // ALLOW_NETWORK_PLAY > 134a281,282 > #ifndef ALLOW_NETWORK_PLAY > 203a352,447 > #else // ALLOW_NETWORK_PLAY > > /* > * This function works like printf, except that it only understands > * very few of the standard formats, to be precise %c, %d, %f, %s. > * But it also accepts %m, which takes two integers and writes a move, > * and %C, which takes a color value and writes a color string. > */ > void > gtp_mprintf(const char *fmt, ...) > { > char szOut[256], szTemp[256]; > > va_list ap; > va_start(ap, fmt); > > memset(szOut, 0, sizeof(szOut)); > memset(szTemp, 0, sizeof(szTemp)); > > for (; *fmt ; ++fmt) { > if (*fmt == '%') { > switch (*++fmt) { > case 'c': > { > /* rules of promotion => passed as int, not char */ > int c = va_arg(ap, int); > szOut[strlen(szOut)] = c; > //fputc(c, stdout); > break; > } > case 'd': > { > int d = va_arg(ap, int); > //fprintf(stdout, "%d", d); > sprintf(szTemp, "%d", d); > strcat(szOut, szTemp); > break; > } > case 'f': > { > double f = va_arg(ap, double); /* passed as double, not float */ > //fprintf(stdout, "%f", f); > sprintf(szTemp, "%f", f); > strcat(szOut, szTemp); > break; > } > case 's': > { > char *s = va_arg(ap, char*); > //fputs(s, stdout); > strcat(szOut, s); > break; > } > case 'm': > { > int m = va_arg(ap, int); > int n = va_arg(ap, int); > gtp_print_vertex(m, n); > break; > } > case 'C': > { > int color = va_arg(ap, int); > if (color == WHITE) > strcat(szOut, "white"); > //fputs("white", stdout); > else if (color == BLACK) > strcat(szOut, "black"); > //fputs("black", stdout); > else > strcat(szOut, "empty"); > //fputs("empty", stdout); > break; > } > default: > sprintf(szTemp, "\n\nUnknown format character '%c'\n", *fmt); > strcat(szOut, szTemp); > //fprintf(stdout, "\n\nUnknown format character '%c'\n", *fmt); > break; > } > } > else > szOut[strlen(szOut)] = *fmt; > //putc(*fmt); > } > va_end(ap); > > if (sock < 0) > fprintf(stdout, "%s", szOut); > else > write_socket_data(szOut, strlen(szOut)); > } > > #endif // ALLOW_NETWORK_PLAY > > #ifndef ALLOW_NETWORK_PLAY 214a459,479 > #else // ALLOW_NETWORK_PLAY > > /* This currently works exactly like printf. */ > void > gtp_printf(const char *format, ...) > { > char szOut[256]; > > va_list ap; > va_start(ap, format); > //vfprintf(stdout, format, ap); > vsprintf(szOut, format, ap); > va_end(ap); > > if (sock < 0) > fprintf(stdout, "%s", szOut); > else > write_socket_data(szOut, strlen(szOut)); > } > > #endif // ALLOW_NETWORK_PLAY 242a508,509 > #ifndef ALLOW_NETWORK_PLAY > 256a524,550 > #else // ALLOW_NETWORK_PLAY > > /* Write a full success response. Except for the id number, the call > * is just like one to printf. > */ > int > gtp_success(int id, const char *format, ...) > { > char szOut[256]; > > va_list ap; > gtp_printid(id, GTP_SUCCESS); > va_start(ap, format); > //vfprintf(stdout, format, ap); > vsprintf(szOut, format, ap); > va_end(ap); > > if (sock < 0) > fprintf(stdout, "%s", szOut); > else > write_socket_data(szOut, strlen(szOut)); > return gtp_finish_response(); > } > > #endif // ALLOW_NETWORK_PLAY > > #ifndef ALLOW_NETWORK_PLAY 269a564,586 > #else // ALLOW_NETWORK_PLAY > > /* Write a full failure response. The call is identical to gtp_success. */ > int > gtp_failure(int id, const char *format, ...) > { > char szOut[256]; > > va_list ap; > gtp_printid(id, GTP_FAILURE); > va_start(ap, format); > //vfprintf(stdout, format, ap); > vsprintf(szOut, format, ap); > va_end(ap); > > if (sock < 0) > fprintf(stdout, "%s", szOut); > else > write_socket_data(szOut, strlen(szOut)); > return gtp_finish_response(); > } > > #endif // ALLOW_NETWORK_PLAY 435a753,758 > > > > > > diff -r -w -b -B gnugo-3.2/interface/gtp.h gnugo.40/interface/gtp.h 65a66,70 > #ifdef ALLOW_NETWORK_PLAY > int write_socket_data(char *buffer,int N); > void gtp_main_loop_network(struct gtp_command commands[], SOCKET sock); > #endif // ALLOW_NETWORK_PLAY > diff -r -w -b -B gnugo-3.2/interface/interface.h gnugo.40/interface/interface.h 36a37 > #ifndef ALLOW_NETWORK_PLAY 37a39,41 > #else // ALLOW_NETWORK_PLAY > void play_gtp(FILE *gtp_input, int nPort, int gtp_initial_orientation); > #endif // ALLOW_NETWORK_PLAY diff -r -w -b -B gnugo-3.2/interface/main.c gnugo.40/interface/main.c 23a24 > #ifdef HAVE_ASSERT_H 24a26 > #endif // HAVE_ASSERT_H 32a35 > #ifdef HAVE_IO_H 33a37 > #endif // HAVE_IO_H 36a41,42 > > #ifdef HAVE_SYS_TIME_H 37a44,46 > #endif // HAVE_SYS_TIME_H > > #ifdef HAVE_TIME_H 38a48,49 > #endif // HAVE_TIME_H > 42a54,55 > > #ifdef HAVE_TIME_H 43a57,58 > #endif // HAVE_TIME_H > 74a90,92 > #ifdef ALLOW_NETWORK_PLAY > OPT_PORT, > #endif // ALLOW_NETWORK_PLAY 164a183,185 > #ifdef ALLOW_NETWORK_PLAY > {"port", required_argument, 0, OPT_PORT}, > #endif // ALLOW_NETWORK_PLAY 283a305,308 > #ifdef ALLOW_NETWORK_PLAY > int nPort = 0; // Default port number > #endif // ALLOW_NETWORK_PLAY > 525a551,556 > #ifdef ALLOW_NETWORK_PLAY > case OPT_PORT: > nPort = atoi(gg_optarg); > break; > #endif // ALLOW_NETWORK_PLAY > 1112a1144 > #ifndef ALLOW_NETWORK_PLAY 1113a1146,1148 > #else // ALLOW_NETWORK_PLAY > play_gtp(gtp_input_FILE, nPort, orientation); > #endif // ALLOW_NETWORK_PLAY 1151c1186 < --- > #ifndef _WIN32_WCE 1152a1188,1190 > #else // _WIN32_WCE > int time_to_die = 0; /* set by signal handlers */ > #endif // _WIN32_WCE 1153a1192 > #ifndef _WIN32_WCE 1175a1215 > #endif // _WIN32_WCE diff -r -w -b -B gnugo-3.2/interface/play_ascii.c gnugo.40/interface/play_ascii.c 26a27 > #ifdef HAVE_ASSERT_H 27a29 > #endif // HAVE_ASSERT_H 564a567 > #ifndef _WIN32_WCE 565a569 > #endif // _WIN32_WCE diff -r -w -b -B gnugo-3.2/interface/play_gmp.c gnugo.40/interface/play_gmp.c 25a26 > #ifdef HAVE_ASSERT_H 26a28 > #endif // HAVE_ASSERT_H 31a34,37 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > 59a66,68 > #ifdef USE_FILE_POINTER > ge = gmp_create(stdin, stdout); > #else // USE_FILE_POINTER 60a70 > #endif // USE_FILE_POINTER diff -r -w -b -B gnugo-3.2/interface/play_gtp.c gnugo.40/interface/play_gtp.c 24a25 > #ifdef HAVE_ASSERT_H 25a27 > #endif // HAVE_ASSERT_H 34a37,45 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > > #ifdef ALLOW_NETWORK_PLAY > #define MAX_PENDING_CONNECTS 4 // Maximum length of the queue > static SOCKET gsock = -1; > #endif // ALLOW_NETWORK_PLAY > 237a249 > #ifndef ALLOW_NETWORK_PLAY 246a259,260 > > #ifndef _WIN32_WCE 247a262,263 > #endif // _WIN32_WCE > 259a276,395 > #else // ALLOW_NETWORK_PLAY > > SOCKET GtpConnect(int nPort) > { > WSADATA wsData; > WORD wVer = MAKEWORD(2,2); > INT iStatus; > > SOCKET WinSocket = INVALID_SOCKET, // Window socket > ClientSock = INVALID_SOCKET; // Socket for communicating > // between the server and client > SOCKADDR_IN local_sin, // Local socket address > accept_sin; // Receives the address of the > // connecting entity > int accept_sin_len; // Length of accept_sin > > // Initialize Winsock. > iStatus = WSAStartup(wVer,&wsData); > if (iStatus != NO_ERROR) > return -1; > > // Create a TCP/IP socket, WinSocket. > if ((WinSocket = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) > { > printf("Allocating socket failed. Error: %d", WSAGetLastError ()); > return -2; > } > > // Fill out the local socket's address information. > local_sin.sin_family = AF_INET; > local_sin.sin_port = htons (nPort); > local_sin.sin_addr.s_addr = htonl (INADDR_ANY); > > // Associate the local address with WinSocket. > if (bind (WinSocket, > (struct sockaddr *) &local_sin, > sizeof (local_sin)) == SOCKET_ERROR) > { > printf ("Binding socket failed. Error: %d", WSAGetLastError ()); > closesocket (WinSocket); > return -3; > } > > // Establish a socket to listen for incoming connections. > if (listen (WinSocket, MAX_PENDING_CONNECTS) == SOCKET_ERROR) > { > printf ("Listening to the client failed. Error: %d", WSAGetLastError ()); > closesocket (WinSocket); > return -4; > } > > accept_sin_len = sizeof (accept_sin); > > // Accept an incoming connection attempt on WinSocket. > ClientSock = accept (WinSocket, > (struct sockaddr *) &accept_sin, > (int *) &accept_sin_len); > > // Stop listening for connections from clients. > closesocket (WinSocket); > > if (ClientSock == INVALID_SOCKET) > { > printf ("Accepting connection with client failed. Error: %d", WSAGetLastError ()); > return -5; > } > > return ClientSock; > } > > void GtpClose(SOCKET sock) > { > // Disable receiving on ServerSock. > shutdown (sock, 0x00); > > // Close the socket. > closesocket (sock); > > WSACleanup (); > } > > /* Start playing using the Go Text Protocol. */ > void > play_gtp(FILE *gtp_input, int nPort, int gtp_initial_orientation) > { > /* Try to make sure that we have a useful level of buffering of stdout. */ > #ifdef HAVE_SETLINEBUF > setlinebuf(stdout); > #else > > #ifndef _WIN32_WCE > setbuf(stdout, NULL); > #endif // _WIN32_WCE > > #endif > > /* Inform the GTP utility functions about the board size. */ > gtp_internal_set_boardsize(board_size); > gtp_orientation = gtp_initial_orientation; > gtp_set_vertex_transform_hooks(rotate_on_input, rotate_on_output); > > /* Prepare pattern matcher and reading code. */ > reset_engine(); > > if (nPort > 0) > { > if ((gsock = GtpConnect(nPort)) >= 0) > { > gtp_main_loop_network(commands, gsock); > > GtpClose(gsock); > } > } > else > { > gtp_main_loop(commands, gtp_input); > } > } > > #endif // ALLOW_NETWORK_PLAY 2332a2469,2499 > #ifdef ALLOW_NETWORK_PLAY > > /*******************************************************************/ > > // Copy from showbord.c to allow showing of board to network > > /* Print a line with coordinate letters above the board. */ > static void gtp_draw_letter_coordinates(void) > { > char szOut[256]; > > int i; > int ch; > > sprintf(szOut, " "); > for (i = 0, ch = 'A'; i < board_size; i++, ch++) { > if (ch == 'I') > ch++; > sprintf(szOut, "%s %c", szOut, ch); > } > > strcat(szOut, "\n"); > write_socket_data(szOut, strlen(szOut)); > } > > /* > * Write one stone. Use 'empty' if the board is empty ('-' or '+') > * We use capital letters A,B,... for black, lower case a,b,... for white. > * This allows us to indicate up to 26 dragons uniquely, and more with > * low risk of ambiguity. > */ 2333a2501,2562 > static void gtp_showchar(int i, int j, int empty, int xo, char* szOut) > { > struct dragon_data *d; /* dragon data at (i, j) */ > int x; > ASSERT_ON_BOARD2(i, j); > x = BOARD(i, j); > d = &(dragon[POS(i, j)]); > > if (x == EMPTY) > { > sprintf(szOut, " %c", empty); > } > else { > if (xo == 0 || ! ON_BOARD1(d->origin)) { > sprintf(szOut, " %c", BOARD(i, j) == BLACK ? 'X' : 'O'); > return; > } > } > } > > static void gtp_showboard_network(int xo) > { > char szOut[256], szTemp[256]; > int i, j, ii; > > memset(szOut, 0, sizeof(szOut)); > > gtp_draw_letter_coordinates(); > > for (i = 0; i < board_size; i++) > { > memset(szOut, 0, sizeof(szOut)); > > ii = board_size - i; > sprintf(szOut, "%s%2d", szOut, ii); > > for (j = 0; j < board_size; j++) > { > gtp_showchar(i, j, is_hoshi_point(i, j) ? '+' : '.', xo, szTemp); > strcat(szOut, szTemp); > } > > sprintf(szOut, "%s %d", szOut, ii); > > if ((xo == 0) && ((board_size < 10 && i == board_size-2) > || (board_size >= 10 && i == 8))) > sprintf(szOut, "%s WHITE has captured %d stones", szOut, black_captured); > > if ((xo == 0) && ((board_size < 10 && i == board_size-1) > || (board_size >= 10 && i == 9))) > sprintf(szOut, "%s BLACK has captured %d stones", szOut, white_captured); > > strcat(szOut, "\n"); > > write_socket_data(szOut, strlen(szOut)); > } > > gtp_draw_letter_coordinates(); > > } > > #endif // ALLOW_NETWORK_PLAY 2343a2573,2579 > > #ifndef ALLOW_NETWORK_PLAY > showboard(0); > #else // ALLOW_NETWORK_PLAY > if (gsock >= 0) > gtp_showboard_network(0); > else 2344a2581,2582 > #endif // ALLOW_NETWORK_PLAY > 2876a3115 > #ifndef _WIN32_WCE 2877a3117,3120 > #else // _WIN32_WCE > gtp_success(id, ""); > #endif // _WIN32_WCE > diff -r -w -b -B gnugo-3.2/interface/play_solo.c gnugo.40/interface/play_solo.c 26a27 > #ifdef HAVE_ASSERT_H 27a29 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/interface/play_test.c gnugo.40/interface/play_test.c 26a27 > #ifdef HAVE_ASSERT_H 27a29 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/patterns/connections.c gnugo.40/patterns/connections.c 27a28 > #ifdef HAVE_ASSERT_H 28a30 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/patterns/dfa.c gnugo.40/patterns/dfa.c 27a28 > #ifdef HAVE_ASSERT_H 28a30 > #endif // HAVE_ASSERT_H 39a42,44 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H 120a126 > #ifndef _WIN32_WCE 121a128,130 > #else // _WIN32_WCE > int *spiral[8]; > #endif // _WIN32_WCE 144a154 > #ifndef _WIN32_WCE 146a157,159 > #else // _WIN32_WCE > void buildSpiralOrder(int **order) > #endif // _WIN32_WCE 789a803,809 > #ifdef _WIN32_WCE > int i; > > for(i=0;i<8;i++) > spiral[i] = (int*)malloc(sizeof(int)*MAX_ORDER); > #endif // _WIN32_WCE > diff -r -w -b -B gnugo-3.2/patterns/dfa.h gnugo.40/patterns/dfa.h 26a27 > #ifdef HAVE_ERRNO_H 27a29 > #endif // HAVE_ERRNO_H 114a117 > #ifndef _WIN32_WCE 115a119,121 > #else // _WIN32_WCE > void buildSpiralOrder(int **order); /* Needed by matchpat */ > #endif // _WIN32_WCE diff -r -w -b -B gnugo-3.2/patterns/extract_fuseki.c gnugo.40/patterns/extract_fuseki.c 233a234 > #ifndef _WIN32_WCE 234a236,240 > #else // _WIN32_WCE > filenames[n] = (char*)malloc(strlen(buf)*sizeof(char)); > strcpy(filenames[n], buf); > #endif // _WIN32_WCE > diff -r -w -b -B gnugo-3.2/patterns/helpers.c gnugo.40/patterns/helpers.c 26a27 > #ifdef HAVE_ASSERT_H 27a29 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/patterns/joseki.c gnugo.40/patterns/joseki.c 23a24,27 > #ifndef _WIN32_WCE > #define HAVE_ASSERT_H > #endif // _WIN32_WCE > 25a30 > #ifdef HAVE_ASSERT_H 26a32 > #endif // HAVE_ASSERT_H 32a39,42 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > diff -r -w -b -B gnugo-3.2/patterns/mkeyes.c gnugo.40/patterns/mkeyes.c 36a37 > #ifdef HAVE_ASSERT_H 37a39 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/patterns/mkpat.c gnugo.40/patterns/mkpat.c 69a70 > #ifdef HAVE_ASSERT_H 70a72 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/patterns/patlib.c gnugo.40/patterns/patlib.c 31a32 > #ifdef HAVE_ASSERT_H 32a34 > #endif // HAVE_ASSERT_H diff -r -w -b -B gnugo-3.2/sgf/sgf_utils.c gnugo.40/sgf/sgf_utils.c 24a25 > #ifdef HAVE_ASSERT_H 25a27 > #endif // HAVE_ASSERT_H 29a32,35 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > diff -r -w -b -B gnugo-3.2/sgf/sgfnode.c gnugo.40/sgf/sgfnode.c 31a32 > #ifdef HAVE_ASSERT_H 33c34 < --- > #endif // HAVE_ASSERT_H 35a37,38 > > #ifdef HAVE_SYS_TIME_H 36a40,42 > #endif // HAVE_SYS_TIME_H > > #ifdef HAVE_TIME_H 37a44,45 > #endif // HAVE_TIME_H > 39c47 < # if HAVE_SYS_TIME_H --- > # ifdef HAVE_SYS_TIME_H 41a50,51 > > #ifdef HAVE_TIME_H 42a53,54 > #endif // HAVE_TIME_H > 48a61,63 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H 1339a1355 > #ifndef _WIN32_WCE 1341a1358,1359 > #endif // _WIN32_WCE > 1344a1363,1367 > #ifdef _WIN32_WCE > SYSTEMTIME st; > GetSystemTime(&st); > #endif // _WIN32_WCE > 1348a1372 > #ifndef _WIN32_WCE 1350a1375,1379 > #else // _WIN32_WCE > gg_snprintf(str, 128, "%4.4i-%2.2i-%2.2i", > st.wYear, st.wMonth, st.wDay); > #endif // _WIN32_WCE > diff -r -w -b -B gnugo-3.2/sgf/sgftree.c gnugo.40/sgf/sgftree.c 21a22,26 > #ifndef _WIN32_WCE > #define HAVE_ASSERT_H > #endif // _WIN32_WCE > > #ifdef HAVE_ASSERT_H 22a28 > #endif // HAVE_ASSERT_H 26a33,36 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > diff -r -w -b -B gnugo-3.2/utils/getopt.c gnugo.40/utils/getopt.c 184a185 > #ifndef _WIN32_WCE 185a187,189 > #else // _WIN32_WCE > static char *posixly_correct = NULL; > #endif // _WIN32_WCE 393a398 > #ifndef _WIN32_WCE 394a400 > #endif // _WIN32_WCE diff -r -w -b -B gnugo-3.2/utils/gg-getopt.h gnugo.40/utils/gg-getopt.h 155a156,172 > > #ifdef _WIN32_WCE > > extern int gg_getopt_long (int argc, char *const *argv, const char *shortopts, > const struct gg_option *longopts, int *longind); > extern int gg_getopt_long_only (int argc, char *const *argv, > const char *shortopts, > const struct gg_option *longopts, int *longind); > > /* Internal only. Users should not call this directly. */ > extern int _getopt_internal (int argc, char *const *argv, > const char *shortopts, > const struct gg_option *longopts, int *longind, > int long_only); > > #else // _WIN32_WCE > 159a177,179 > > #endif // _WIN32_WCE > diff -r -w -b -B gnugo-3.2/utils/gg_utils.c gnugo.40/utils/gg_utils.c 21a22,25 > #ifndef _WIN32_WCE > #define HAVE_ASSERT_H > #endif // _WIN32_WCE > 23a28 > #ifdef HAVE_ASSERT_H 24a30 > #endif // HAVE_ASSERT_H 31a38,41 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H > 153a164 > #ifndef _WIN32_WCE 197a209 > #endif // _WIN32_WCE 247a260,261 > #ifndef _WIN32_WCE > 269a284,302 > #else // _WIN32_WCE > > double > gg_gettimeofday(void) > { > SYSTEMTIME st; > FILETIME ft; > double t; > > GetSystemTime(&st); > SystemTimeToFileTime(&st,&ft); > > memcpy(&t, &ft, sizeof(double)); > > return t; > } > > #endif // _WIN32_WCE > 285a319,329 > > #elif defined(_WIN32_WCE) > > static int warned = 0; > if (!warned) { > fprintf(stderr, "CPU timing unavailable - returning wall time."); > warned = 1; > } > /* return wall clock seconds */ > return gg_gettimeofday(); > 473a518,558 > #ifdef DEBUG_LOG_TO_FILE > > #ifdef _GO_DEBUG > > void GoLog(char *lpszFormat, ...) > { > TCHAR szFileName[MAX_PATH] = _T("\\GoLog.txt"); > HANDLE hFile; > ULONG ulRet, ulBytesWritten; > > char szBuffer[512]; > va_list args; > > va_start(args, lpszFormat); > > memset(szBuffer, 0, sizeof(szBuffer)); > > vsprintf (szBuffer, lpszFormat, args); > > // Open GoLog.txt file > hFile = CreateFile( szFileName, > GENERIC_WRITE|GENERIC_READ, > FILE_SHARE_WRITE|FILE_SHARE_READ, > NULL, > OPEN_ALWAYS, > FILE_ATTRIBUTE_NORMAL, > NULL ); > > ASSERT(hFile != INVALID_HANDLE_VALUE); > > SetFilePointer( hFile, 0L, NULL, FILE_END ); > ulRet = WriteFile(hFile, szBuffer, strlen(szBuffer), &ulBytesWritten, NULL); > > ASSERT(ulRet != FALSE); > > CloseHandle(hFile); > > va_end(args); > } > > #endif // _GO_DEBUG 474a560 > #endif // DEBUG_LOG_TO_FILE 481a568 > diff -r -w -b -B gnugo-3.2/utils/gg_utils.h gnugo.40/utils/gg_utils.h 31a32,33 > > #ifdef HAVE_SYS_TIME_H 32a35,37 > #endif // HAVE_SYS_TIME_H > > #ifdef HAVE_TIME_H 33a39,40 > #endif // HAVE_TIME_H > 37a45,46 > > #ifdef HAVE_TIME_H 38a48,49 > #endif // HAVE_TIME_H > 49a61 > #ifdef HAVE_IO_H 50a63 > #endif // HAVE_IO_H 60a74 > #ifndef _WIN32_WCE 61a76 > #endif // _WIN32_WCE 77a93,108 > #ifdef DEBUG_LOG_TO_FILE > > //#define _GO_DEBUG > > #ifdef _GO_DEBUG > void GoLog(char *lpszFormat, ...); > #endif // _GO_DEBUG > > #if defined(_GO_DEBUG) > #define GOTRACE GoLog > #else > #define GOTRACE {} > #endif // _GO_DEBUG > > #endif // DEBUG_LOG_TO_FILE > 86a118 > diff -r -w -b -B gnugo-3.2/utils/random.c gnugo.40/utils/random.c 22a23 > #ifdef HAVE_ASSERT_H 23a25 > #endif // HAVE_ASSERT_H 25a28,30 > #ifndef HAVE_ASSERT_H > #define assert(x) {} > #endif // HAVE_ASSERT_H