Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sunaus.oz!richb From: richb@sunaus.oz (Rich Burridge) Newsgroups: comp.sources.games.bugs Subject: Official patch #1 for Reve v1.1 (Part 3 of 4). Message-ID: <1990Nov9.002840.10277@sunaus.oz> Date: 9 Nov 90 00:28:40 GMT Organization: Sun Microsystems - Australia Lines: 1545 ------CUT HERE------patch1 - part3------CUT HERE------ ------- rev_eval.c ------- *** /tmp/da28908 Fri Nov 9 10:39:56 1990 --- rev_eval.c Mon Nov 5 09:06:42 1990 *************** *** 3,13 **** * * Copyright (C) 1990 - Yves Gallot - all rights reserved. * ! * Permission is given to distribute these sources, as long as the ! * introductory messages are not removed, and no monies are exchanged. * ! * You are forbidden from using Reve as is, or in a modified state, in ! * any tournaments, without the permission of the authors. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported --- 3,18 ---- * * Copyright (C) 1990 - Yves Gallot - all rights reserved. * ! * Permission is granted to copy this source, for redistribution ! * in source form only, provided the news headers in "substantially ! * unaltered format" are retained, the introductory messages are not ! * removed, and no monies are exchanged. * ! * Permission is also granted to copy this source, without the ! * news headers, for the purposes of making an executable copy by ! * means of compilation, provided that such copy will not be used ! * for the purposes of competition in any othello tournaments, without ! * prior permission from the authors. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported *************** *** 23,36 **** extern long c1, c2, c3 ; extern long edges[6561] ; ! /* Evaluation function : give a note to a board = damier[ niv ]. * It computes 4 components : * - Edge Stability, using Edge Stability Table pre-computed before * - Current Mobility, in fact computed during alpha-beta pruning * - X squares Values * - Potential Mobility, looking at squares contacts ! * And then Eval = c1 * ES + c2 * CM + c3 * XV + c4 * PM ! * Eval is replaced by - Eval if Black is replaced by White. Eval is positif * if macouleur ( my color ) has a good position and negatif if tacouleur * position is good. * If we are "near" the end of the game, then Eval is equal to final disc --- 28,41 ---- extern long c1, c2, c3 ; extern long edges[6561] ; ! /* Evaluation function : gives a note to a board = damier[ niv ]. * It computes 4 components : * - Edge Stability, using Edge Stability Table pre-computed before * - Current Mobility, in fact computed during alpha-beta pruning * - X squares Values * - Potential Mobility, looking at squares contacts ! * And then Eval = c1 * ES + c2 * ( CM + cx * XV ) + c3 * PM ! * Eval is replaced by - Eval if Black is replaced by White. Eval is positive * if macouleur ( my color ) has a good position and negatif if tacouleur * position is good. * If we are "near" the end of the game, then Eval is equal to final disc *************** *** 45,51 **** register int i, x, y ; register long note ; register int vp, vo ; ! register long tnote ; d = damier[niv] ; --- 50,56 ---- register int i, x, y ; register long note ; register int vp, vo ; ! register long tnote, cx ; d = damier[niv] ; *************** *** 105,135 **** } note += edges[i] ; if (d[0] == FREE) { ! if (d[9] == macouleur) note -= c3 ; ! else if (d[9] == tacouleur) note += c3 ; } if (d[7] == FREE) { ! if (d[14] == macouleur) note -= c3 ; ! else if (d[14] == tacouleur) note += c3 ; } if (d[56] == FREE) { ! if (d[49] == macouleur) note -= c3 ; ! else if (d[49] == tacouleur) note += c3 ; } if (d[63] == FREE) { ! if (d[54] == macouleur) note -= c3 ; ! else if (d[54] == tacouleur) note += c3 ; } ! tnote = c1 * note + c2 * (vp0 - vo0) / (vp0 + vo0 + 2) ; vp = vo = 0 ; for (x = 0; x < 8; x++) --- 110,142 ---- } note += edges[i] ; + cx = 8 * (50 - mnb - profmax) ; + if (d[0] == FREE) { ! if (d[9] == macouleur) note -= cx ; ! else if (d[9] == tacouleur) note += cx ; } if (d[7] == FREE) { ! if (d[14] == macouleur) note -= cx ; ! else if (d[14] == tacouleur) note += cx ; } if (d[56] == FREE) { ! if (d[49] == macouleur) note -= cx ; ! else if (d[49] == tacouleur) note += cx ; } if (d[63] == FREE) { ! if (d[54] == macouleur) note -= cx ; ! else if (d[54] == tacouleur) note += cx ; } ! tnote = c1 * note + c2 * (long) 1000 * (vp0 - vo0) / (vp0 + vo0 + 2) ; vp = vo = 0 ; for (x = 0; x < 8; x++) *************** *** 219,225 **** } note += ((long) 1000 * (vp - vo)) / (vp + vo + 2) ; ! tnote += 99 * note ; ! return(tnote) ; } } --- 226,232 ---- } note += ((long) 1000 * (vp - vo)) / (vp + vo + 2) ; ! tnote += c3 * note ; ! return(tnote / 1000) ; } } ------- rev_ip.c ------- *** /tmp/da28911 Fri Nov 9 10:39:56 1990 --- rev_ip.c Mon Nov 5 09:07:12 1990 *************** *** 3,11 **** * * Copyright (C) 1990 - Yves Gallot - all rights reserved. * ! * Permission is given to distribute these sources, as long as the ! * introductory messages are not removed, and no monies are exchanged. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported * (see README file), then an attempt will be made to fix them. --- 3,19 ---- * * Copyright (C) 1990 - Yves Gallot - all rights reserved. * ! * Permission is granted to copy this source, for redistribution ! * in source form only, provided the news headers in "substantially ! * unaltered format" are retained, the introductory messages are not ! * removed, and no monies are exchanged. * + * Permission is also granted to copy this source, without the + * news headers, for the purposes of making an executable copy by + * means of compilation, provided that such copy will not be used + * for the purposes of competition in any othello tournaments, without + * prior permission from the authors. + * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported * (see README file), then an attempt will be made to fix them. *************** *** 12,22 **** */ #include #include #include #include "reve.h" ! extern time_t time() ; extern int damier[NIVEAUMAX][64] ; extern int tacouleur, macouleur ; extern int mnb, profmax ; --- 20,33 ---- */ #include + #include + #include #include #include #include "reve.h" ! extern int saveres ; ! extern time_t timeleft, time() ; extern int damier[NIVEAUMAX][64] ; extern int tacouleur, macouleur ; extern int mnb, profmax ; *************** *** 58,81 **** static int timevals[MAXDIFF] = { 0, 1, 3, 5, 10, 15, 20, 30, 60 } ; ! static int cpi[60], cpj[60], cpk[60] ; static int locallevel = -1 ; ! static time_t timeleft ; static long jeplonge() ; static long tuplonges() ; long evalue() ; play_reve(board, color, level, rtnmv, rtnnote) int *board, color, level, *rtnmv ; long *rtnnote ; { register int *d0, *d1 ; ! register int k, cp, cpmax ; ! register long lnote, note ; ! register int count, fact ; ! time_t firsttime, timeused, allotime ; for (k = 0; k < 60; k++) { --- 69,105 ---- static int timevals[MAXDIFF] = { 0, 1, 3, 5, 10, 15, 20, 30, 60 } ; ! static int cpi[60], cpj[60], cpk[60], cpf[60] ; ! static int cpi2[60], cpj2[60], cpk2[60] ; ! static int cpmaxi[4] ; static int locallevel = -1 ; ! static firsttime, timeused, allotime ; + jmp_buf jumper ; + static long jeplonge() ; static long tuplonges() ; long evalue() ; + + static void + catcher() + { + longjmp(jumper, 1) ; + } + + play_reve(board, color, level, rtnmv, rtnnote) int *board, color, level, *rtnmv ; long *rtnnote ; { register int *d0, *d1 ; ! register int k, cp ; ! register long lnote ; ! register int count ; ! static int cpmax, note, oldnote ; ! FILE *fp ; for (k = 0; k < 60; k++) { *************** *** 119,125 **** mnb++ ; cp = 0 ; while (cpk[cp] != k) cp++ ; ! for ( ; cp < 60; cp++) { cpi[cp] = cpi[cp + 1] ; cpj[cp] = cpj[cp + 1] ; --- 143,149 ---- mnb++ ; cp = 0 ; while (cpk[cp] != k) cp++ ; ! for ( ; cp < 59; cp++) { cpi[cp] = cpi[cp + 1] ; cpj[cp] = cpj[cp + 1] ; *************** *** 129,135 **** if ((locallevel != level) || (mnb == 1) || (mnb == 2)) { ! timeleft = timevals[level] * 60 ; locallevel = level ; } --- 153,159 ---- if ((locallevel != level) || (mnb == 1) || (mnb == 2)) { ! timeleft = timevals[level-1] * 60 ; locallevel = level ; } *************** *** 137,171 **** for (cp = 0; cp <= 60 - mnb; cp++) if (d0[cpk[cp]] == JPJ) k++ ; ! if ((k == 1) || (mnb == 1)) { - note = 0 ; - timeused = profmax = 1 ; for (cp = 0; d0[cpk[cp]] != JPJ; cp++) ; cpi[0] = cpi[cp] ; cpj[0] = cpj[cp] ; cpk[0] = cpk[cp] ; } else ! { ! count = 0 ; ! profmax = 1 ; ! allotime = timeleft * 2 / (60 - mnb) ; firsttime = time((time_t *) NULL) ; do { note = -1000000000 ; c1 = 312 + 6 * (mnb + profmax) ; if (mnb + profmax < 25) ! c2 = 1000 * (long) (50 + 2 * (mnb + profmax)) ; else ! c2 = 1000 * (long) (75 + mnb + profmax) ; ! c3 = 4 * (50 - mnb - profmax) ; profmax++ ; - if (profmax > 55 - mnb) profmax = 61 - mnb ; for (cp = 0; cp <= 60 - mnb; cp++) { if (d0[cpk[cp]] == JPJ) --- 161,256 ---- for (cp = 0; cp <= 60 - mnb; cp++) if (d0[cpk[cp]] == JPJ) k++ ; ! count = note = cpmax = 0 ; ! timeused = profmax = 1 ; ! ! if (((k == 1) && (mnb < 52)) || (mnb == 1)) { for (cp = 0; d0[cpk[cp]] != JPJ; cp++) ; cpi[0] = cpi[cp] ; cpj[0] = cpj[cp] ; cpk[0] = cpk[cp] ; } + else if (mnb == 2) + { + if (d0[2 * 8 + 3] == BLACK) + { + cpi[0] = 4 ; + cpj[0] = 2 ; + } + else if (d0[3 * 8 + 2] == BLACK) + { + cpi[0] = 2 ; + cpj[0] = 4 ; + } + else if (d0[4 * 8 + 5] == BLACK) + { + cpi[0] = 5 ; + cpj[0] = 3 ; + } + else if (d0[5 * 8 + 4] == BLACK) + { + cpi[0] = 3 ; + cpj[0] = 5 ; + } + cpk[0] = cpi[0] * 8 + cpj[0] ; + } + else if (mnb == 3) + { + if (d0[4 * 8 + 2] == WHITE) + { + cpi[0] = 5 ; + cpj[0] = 3 ; + } + else if (d0[2 * 8 + 2] == WHITE) + { + cpi[0] = 3 ; + cpj[0] = 2 ; + } + else if (d0[2 * 8 + 4] == WHITE) + { + cpi[0] = 3 ; + cpj[0] = 5 ; + } + cpk[0] = cpi[0] * 8 + cpj[0] ; + } else ! { ! allotime = timeleft * 3 / (61 - mnb) ; firsttime = time((time_t *) NULL) ; + + signal(SIGALRM, catcher) ; + + if (setjmp(jumper) != 0) + { + if (cpmax == 0) note = oldnote ; + profmax = -profmax ; + goto trap ; + } + do { + oldnote = note ; note = -1000000000 ; + if ((int) (allotime - timeused) > 2) alarm(allotime - timeused) ; + c1 = 312 + 6 * (mnb + profmax) ; if (mnb + profmax < 25) ! c2 = 50 + 2 * (mnb + profmax) ; else ! c2 = 75 + mnb + profmax ; ! c3 = 99 ; profmax++ ; + if (profmax > 53 - mnb) + { + profmax = 61 - mnb ; + allotime = timeleft * 3 / 5 ; + if ((int) (allotime - timeused) > 2) alarm(allotime - timeused) ; + } + for (cp = 0; cp <= 60 - mnb; cp++) { if (d0[cpk[cp]] == JPJ) *************** *** 185,215 **** } } } ! if (cpmax == 0) count++ ; else { ! count = 1 ; ! k = cpi[0] ; ! cpi[0] = cpi[cpmax] ; ! cpi[cpmax] = k ; ! k = cpj[0] ; ! cpj[0] = cpj[cpmax] ; ! cpj[cpmax] = k ; ! k = cpk[0] ; ! cpk[0] = cpk[cpmax] ; ! cpk[cpmax] = k ; } timeused = time((time_t *) NULL) - firsttime ; ! if (count < 3) fact = 1 ; ! else fact = 3 ; } ! while ((timeused * fact < allotime) && (profmax <= 60 - mnb)) ; if (timeused == 0) timeused = 1 ; } ! timeleft -= timeused ; ! *rtnmv = cpk[0] ; *rtnnote = note ; } --- 270,349 ---- } } } ! ! alarm(0) ; ! cpmaxi[0] = cpmax ; ! ! if ((mnb < 57) && (cpmaxi[0] != cpmaxi[1]) ! && (cpmaxi[1] != cpmaxi[2]) && (cpmaxi[0] != cpmaxi[2])) ! { ! if (cpmax == 0) count++ ; else count = 1 ; ! for (cp = 0; cp <= 60 - mnb; cp++) cpf[cp] = TRUE ; ! for (k = 0; k < 3; k++) ! { ! cpi2[k] = cpi[cpmaxi[k]] ; ! cpj2[k] = cpj[cpmaxi[k]] ; ! cpk2[k] = cpk[cpmaxi[k]] ; ! cpf[cpmaxi[k]] = FALSE ; ! } ! k = 3 ; ! for (cp = 0; cp <= 60 - mnb; cp++) ! if (cpf[cp] == TRUE) ! { ! cpi2[k] = cpi[cp] ; ! cpj2[k] = cpj[cp] ; ! cpk2[k] = cpk[cp] ; ! k++ ; ! } ! for (cp = 0; cp <= 60 - mnb; cp++) ! { ! cpi[cp] = cpi2[cp] ; ! cpj[cp] = cpj2[cp] ; ! cpk[cp] = cpk2[cp] ; ! } ! } else { ! cpi2[0] = cpi[cpmax] ; ! cpj2[0] = cpj[cpmax] ; ! cpk2[0] = cpk[cpmax] ; ! cpi[cpmax] = cpi[0] ; ! cpj[cpmax] = cpj[0] ; ! cpk[cpmax] = cpk[0] ; ! cpi[0] = cpi2[0] ; ! cpj[0] = cpj2[0] ; ! cpk[0] = cpk2[0] ; } + cpmax = 0 ; timeused = time((time_t *) NULL) - firsttime ; ! if ((mnb == 4) && (profmax == 3)) break ; } ! while ((timeused * count < allotime * 5 / 4) && (profmax != 61 - mnb)) ; ! trap: ! timeused = time((time_t *) NULL) - firsttime ; if (timeused == 0) timeused = 1 ; } ! if (*rtnmv == TRUE) timeleft -= timeused ; ! if ((int) timeleft < 0) timeleft = 0 ; ! if (saveres) ! { ! if ((mnb == 1) || (mnb == 2)) ! { ! fp = fopen("reve.res", "w") ; ! FPRINTF(fp, "\n") ; ! FCLOSE(fp) ; ! } ! fp = fopen("reve.res", "a") ; ! FPRINTF(fp, "%2d, <%c-%c>, ", mnb, 'A' + cpj[cpmax], '1' + cpi[cpmax]) ; ! FPRINTF(fp, "nt : %5d, pmax : %3d, tmleft : %d, level : %d, ", ! note, profmax, timeleft, level) ; ! FPRINTF(fp, "exp : <%c-%c>\n", 'A' + cpj[1], '1' + cpi[1]) ; ! FCLOSE(fp) ; ! } ! ! *rtnmv = cpk[cpmax] ; *rtnnote = note ; } *************** *** 220,226 **** long alpha, beta ; { register int *d0, *d1 ; ! register int k, cp ; register long lnote, note ; d0 = damier[niv] ; --- 354,360 ---- long alpha, beta ; { register int *d0, *d1 ; ! register int k, cp, cpmax ; register long lnote, note ; d0 = damier[niv] ; *************** *** 241,250 **** lnote = tuplonges(niv + 1, alpha, note) ; else lnote = evalue(niv + 1) ; ! if (lnote < note) note = lnote ; if (note <= alpha) return note ; } } return note ; } --- 375,397 ---- lnote = tuplonges(niv + 1, alpha, note) ; else lnote = evalue(niv + 1) ; ! if (lnote < note) ! { ! note = lnote ; ! cpmax = cp ; ! } if (note <= alpha) return note ; } } + + if (niv == 1) + { + cpmaxi[1] = cpmax ; + cpmaxi[2] = cpmaxi[3] ; + } + else if (niv == 2) + cpmaxi[3] = cpmax ; + return note ; } *************** *** 255,261 **** long alpha, beta ; { register int *d0, *d1 ; ! register int k, cp ; register long lnote, note ; d0 = damier[niv] ; --- 402,408 ---- long alpha, beta ; { register int *d0, *d1 ; ! register int k, cp, cpmax ; register long lnote, note ; d0 = damier[niv] ; *************** *** 276,284 **** lnote = jeplonge(niv + 1, note, beta) ; else lnote = evalue(niv + 1) ; ! if (lnote > note) note = lnote ; if (note >= beta) return note ; } } return note ; } --- 423,444 ---- lnote = jeplonge(niv + 1, note, beta) ; else lnote = evalue(niv + 1) ; ! if (lnote > note) ! { ! note = lnote ; ! cpmax = cp ; ! } if (note >= beta) return note ; } } + + if (niv == 1) + { + cpmaxi[1] = cpmax ; + cpmaxi[2] = cpmaxi[3] ; + } + else if (niv == 2) + cpmaxi[3] = cpmax ; + return note ; } ------- rev_iycp.c ------- *** /tmp/da28914 Fri Nov 9 10:39:57 1990 --- rev_iycp.c Mon Nov 5 09:10:39 1990 *************** *** 3,13 **** * * Copyright (C) 1990 - Yves Gallot - all rights reserved. * ! * Permission is given to distribute these sources, as long as the ! * introductory messages are not removed, and no monies are exchanged. * ! * You are forbidden from using Reve as is, or in a modified state, in ! * any tournaments, without the permission of the authors. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported --- 3,18 ---- * * Copyright (C) 1990 - Yves Gallot - all rights reserved. * ! * Permission is granted to copy this source, for redistribution ! * in source form only, provided the news headers in "substantially ! * unaltered format" are retained, the introductory messages are not ! * removed, and no monies are exchanged. * ! * Permission is also granted to copy this source, without the ! * news headers, for the purposes of making an executable copy by ! * means of compilation, provided that such copy will not be used ! * for the purposes of competition in any othello tournaments, without ! * prior permission from the authors. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported ------- reve.h ------- *** /tmp/da28917 Fri Nov 9 10:39:58 1990 --- reve.h Mon Nov 5 09:07:58 1990 *************** *** 6,16 **** * Copyright (C) 1990 - Rich Burridge & Yves Gallot. * All rights reserved. * ! * Permission is given to distribute these sources, as long as the ! * introductory messages are not removed, and no monies are exchanged. * ! * You are forbidden from using Reve as is, or in a modified state, in ! * any tournaments, without the permission of the authors. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported --- 6,21 ---- * Copyright (C) 1990 - Rich Burridge & Yves Gallot. * All rights reserved. * ! * Permission is granted to copy this source, for redistribution ! * in source form only, provided the news headers in "substantially ! * unaltered format" are retained, the introductory messages are not ! * removed, and no monies are exchanged. * ! * Permission is also granted to copy this source, without the ! * news headers, for the purposes of making an executable copy by ! * means of compilation, provided that such copy will not be used ! * for the purposes of competition in any othello tournaments, without ! * prior permission from the authors. * * No responsibility is taken for any errors on inaccuracies inherent * either to the comments or the code of this program, but if reported *************** *** 17,26 **** * (see README file), then an attempt will be made to fix them. */ #define FCLOSE (void) fclose /* To make lint happy. */ #define FFLUSH (void) fflush #define FGETS (void) fgets - #define FREAD (void) fread #define FSEEK (void) fseek #define FPRINTF (void) fprintf #define GETTIMEOFDAY (void) gettimeofday --- 22,33 ---- * (see README file), then an attempt will be made to fix them. */ + #include + #include + #define FCLOSE (void) fclose /* To make lint happy. */ #define FFLUSH (void) fflush #define FGETS (void) fgets #define FSEEK (void) fseek #define FPRINTF (void) fprintf #define GETTIMEOFDAY (void) gettimeofday *************** *** 42,57 **** #define BGAP 10 /* Width of the gap between buttons. */ #define BHEIGHT 32 /* Height of a reve button item. */ #define BWIDTH 64 /* Width of a reve button item. */ - #define CELL_SIZE (int) ((TOTAL_WIDTH-(2*BBORDER)) / BOARD_SIZE) #define CHEIGHT 20 /* Height of a reve cycle item. */ #define CWIDTH 32 /* Width of a reve cycle item. */ - #define CY ((NOROWS*BHEIGHT) + ((NOROWS-1)*BGAP) + (2*BBORDER)) #define NOBUTS 6 /* Number of reve buttons. */ - #define NOROWS 6 /* Number of rows of reve items. */ #define PIECE_MARGIN 8 #define PIECE_RAD (CELL_SIZE / 2 - PIECE_MARGIN) #define TOTAL_HEIGHT CY + (8 * CELL_SIZE) + (2 * BBORDER) #define TOTAL_WIDTH ((NOBUTS*BWIDTH) + ((NOBUTS-1)*BGAP) + (2*BBORDER)) /* States that the the Reve squares can be in. */ #define BLACK (-1) /* Piece definitions. */ --- 49,73 ---- #define BGAP 10 /* Width of the gap between buttons. */ #define BHEIGHT 32 /* Height of a reve button item. */ #define BWIDTH 64 /* Width of a reve button item. */ #define CHEIGHT 20 /* Height of a reve cycle item. */ #define CWIDTH 32 /* Width of a reve cycle item. */ #define NOBUTS 6 /* Number of reve buttons. */ #define PIECE_MARGIN 8 #define PIECE_RAD (CELL_SIZE / 2 - PIECE_MARGIN) + + #ifdef XVIEW + #define CELL_SIZE 54 + #define CY 0 + #define NOROWS 0 + #define TOTAL_HEIGHT (8 * CELL_SIZE) + (2 * BBORDER) + #define TOTAL_WIDTH (8 * CELL_SIZE) + (2 * BBORDER) + #else + #define CELL_SIZE (int) ((TOTAL_WIDTH-(2*BBORDER)) / BOARD_SIZE) + #define CY ((NOROWS*BHEIGHT) + ((NOROWS-1)*BGAP) + (2*BBORDER)) + #define NOROWS 6 /* Number of rows of reve items. */ #define TOTAL_HEIGHT CY + (8 * CELL_SIZE) + (2 * BBORDER) #define TOTAL_WIDTH ((NOBUTS*BWIDTH) + ((NOBUTS-1)*BGAP) + (2*BBORDER)) + #endif /*XVIEW*/ /* States that the the Reve squares can be in. */ #define BLACK (-1) /* Piece definitions. */ *************** *** 91,104 **** #ifndef MAXLINE #define MAXLINE 80 /* Length of character strings. */ ! #endif /*MAXLINE*/ #define MAXMENUS 4 /* Maximum number of popup menus. */ #define NIVEAUMAX 25 /* Maximum possible depth. */ #ifdef NOINDEX #define index strchr #endif /*NOINDEX*/ #define NOMOVE -1 #define OPPONENT(p) p * -1 --- 107,122 ---- #ifndef MAXLINE #define MAXLINE 80 /* Length of character strings. */ ! #endif /*!MAXLINE*/ #define MAXMENUS 4 /* Maximum number of popup menus. */ #define NIVEAUMAX 25 /* Maximum possible depth. */ + #ifndef X11 #ifdef NOINDEX #define index strchr #endif /*NOINDEX*/ + #endif /*!X11*/ #define NOMOVE -1 #define OPPONENT(p) p * -1 *************** *** 116,128 **** #ifndef EDGENAME #define EDGENAME "reve.edgetable" ! #endif /*EDGENAME*/ ! #ifndef NO_4_3SIGNAL #define SIGRET void #else #define SIGRET int ! #endif /*NO_4_3SIGNAL*/ #define VINVUL 50 --- 134,146 ---- #ifndef EDGENAME #define EDGENAME "reve.edgetable" ! #endif /*!EDGENAME*/ ! #ifndef INT_SIGNAL #define SIGRET void #else #define SIGRET int ! #endif /*!INT_SIGNAL*/ #define VINVUL 50 *************** *** 140,146 **** #define MOUSE_MOVING 110 /* Mouse is moving. */ #define IGNORE_EVENT 111 /* No interest in this event. */ ! /* Batch or locking direction (ON or OFF). */ enum bltype { IS_OFF, IS_ON } ; /* Reve move status. */ --- 158,164 ---- #define MOUSE_MOVING 110 /* Mouse is moving. */ #define IGNORE_EVENT 111 /* No interest in this event. */ ! /* Batch, last move, locking or show all direction (ON or OFF). */ enum bltype { IS_OFF, IS_ON } ; /* Reve move status. */ *************** *** 167,176 **** enum item_type { P_BUTTON, P_CYCLE, P_MESSAGE } ; /* Different panel items. */ ! enum panel_type { LAST_BUT, LOAD_BUT, NEW_GAME_BUT, SAVE_BUT, SUGGEST_BUT, UNDO_BUT, DONE_BUT, CANCEL_BUT, QUIT_BUT, BLACK_PLAYS, WHITE_PLAYS, DIFFICULTY, NOTES, ! PANEL_MES, NOTES_MES, SCORE_MES, TURN_MES } ; enum set_type { INCREMENT, DECREMENT, NONE } ; /* Cycle directions. */ --- 185,194 ---- enum item_type { P_BUTTON, P_CYCLE, P_MESSAGE } ; /* Different panel items. */ ! enum panel_type { LOAD_BUT, NEW_GAME_BUT, SAVE_BUT, SHOW_ALL_BUT, SUGGEST_BUT, UNDO_BUT, DONE_BUT, CANCEL_BUT, QUIT_BUT, BLACK_PLAYS, WHITE_PLAYS, DIFFICULTY, NOTES, ! PANEL_MES, EVAL_MES, SCORE_MES, TURN_MES } ; enum set_type { INCREMENT, DECREMENT, NONE } ; /* Cycle directions. */ *************** *** 187,192 **** --- 205,211 ---- int move ; int moves_left ; long note ; + time_t timeleft ; } BOARD ; struct iteminfo /* Item information record. */ *************** *** 213,233 **** void done(), draw_button(), draw_cycle() ; void draw_cycle_item(), draw_image(), draw_line() ; void draw_piece(), draw_rect(), draw_stencil() ; ! void draw_text(), draw_textfield(), get_filename() ; void get_options(), get_xy(), getparam() ; void handle_board_event(), handle_event(), handle_item() ; void handle_key(), init_canvas(), init_edge_table() ; void init_fonts(), init_notes(), init_player() ; void initboard(), initialise() ; ! void last(), load_colors(), load_game() ; ! void lock_screen() ; void make_canvas(), make_frame(), make_icon() ; void make_message(), make_move(), make_panel() ; ! void message(), nap_upto() ; ! void new_game(), process_event(), quit() ; void remove_textfield(), save_game(), set_cursor() ; void set_cycle(), set_display_types() ; void set_timer(), set_score(), set_turn() ; void show_suggestion(), start_tool() ; void suggest(), think(), undo() ; void update_board_image(), usage(), who_wins() ; --- 232,253 ---- void done(), draw_button(), draw_cycle() ; void draw_cycle_item(), draw_image(), draw_line() ; void draw_piece(), draw_rect(), draw_stencil() ; ! void draw_text(), draw_textfield() ; ! void generate_graphics(), get_filename() ; void get_options(), get_xy(), getparam() ; void handle_board_event(), handle_event(), handle_item() ; void handle_key(), init_canvas(), init_edge_table() ; void init_fonts(), init_notes(), init_player() ; void initboard(), initialise() ; ! void load_colors(), load_game(), lock_screen() ; void make_canvas(), make_frame(), make_icon() ; void make_message(), make_move(), make_panel() ; ! void message(), nap_upto(), new_game() ; ! void position_popup(), process_event(), quit() ; void remove_textfield(), save_game(), set_cursor() ; void set_cycle(), set_display_types() ; void set_timer(), set_score(), set_turn() ; + void show_all(), show_all_moves(), show_last() ; void show_suggestion(), start_tool() ; void suggest(), think(), undo() ; void update_board_image(), usage(), who_wins() ; ------- tty.c ------- *** /tmp/da28926 Fri Nov 9 10:40:00 1990 --- tty.c Mon Nov 5 09:08:40 1990 *************** *** 7,17 **** * Copyright (C) 1990 - Rich Burridge & Yves Gallot. * All rights reserved. * ! * Permission is given to distribute these sources, as long as the ! * introductory messages are not removed, and no monies are exchanged. * ! * You are forbidden from using Reve as is, or in a modified state, in ! * any tournaments, without the permission of the authors. * * No responsibility is taken for any errors or inaccuracies inherent * either to the comments or the code of this program, but if reported --- 7,22 ---- * Copyright (C) 1990 - Rich Burridge & Yves Gallot. * All rights reserved. * ! * Permission is granted to copy this source, for redistribution ! * in source form only, provided the news headers in "substantially ! * unaltered format" are retained, the introductory messages are not ! * removed, and no monies are exchanged. * ! * Permission is also granted to copy this source, without the ! * news headers, for the purposes of making an executable copy by ! * means of compilation, provided that such copy will not be used ! * for the purposes of competition in any othello tournaments, without ! * prior permission from the authors. * * No responsibility is taken for any errors or inaccuracies inherent * either to the comments or the code of this program, but if reported *************** *** 18,36 **** * (see README file), then an attempt will be made to fix them. */ ! #include ! #include #include #include #ifdef SYSV #include #endif /*SYSV*/ - #include "reve.h" - #include "color.h" - #include "extern.h" - #define DRAW_STRING(col, row, str, v) draw_string(col, row, str, v), return enum gr_type gtype = GTTY ; /* Graphics type. */ --- 23,41 ---- * (see README file), then an attempt will be made to fix them. */ ! #include "reve.h" ! #include "color.h" ! #include "extern.h" #include #include #ifdef SYSV + #include #include + #else + #include #endif /*SYSV*/ #define DRAW_STRING(col, row, str, v) draw_string(col, row, str, v), return enum gr_type gtype = GTTY ; /* Graphics type. */ *************** *** 60,69 **** } ; struct tty_info ttyvals[MAXITEMS] = { ! { 1, 1, 33, 33, }, /* Last */ ! { 11, 1, 107, 33, }, /* Load */ ! { 22, 1, 167, 33, }, /* New game */ ! { 33, 1, 255, 33, }, /* Save */ { 44, 1, 318, 33, }, /* Suggest */ { 55, 1, 403, 33, }, /* Undo */ { -1, -1, 33, 75, }, /* Done (not displayed). */ --- 65,74 ---- } ; struct tty_info ttyvals[MAXITEMS] = { ! { 1, 1, 33, 33, }, /* Load */ ! { 11, 1, 107, 33, }, /* New game */ ! { 22, 1, 167, 33, }, /* Save */ ! { 33, 1, 255, 33, }, /* Show all */ { 44, 1, 318, 33, }, /* Suggest */ { 55, 1, 403, 33, }, /* Undo */ { -1, -1, 33, 75, }, /* Done (not displayed). */ *************** *** 85,94 **** } ; struct other_info othervals[MAXITEMS] = { - { -1, -1, }, /* Last (ignored). */ { -1, -1, }, /* Load (ignored). */ { -1, -1, }, /* New game (ignored). */ { -1, -1, }, /* Save (ignored). */ { -1, -1, }, /* Suggest (ignored). */ { -1, -1, }, /* Undo (ignored). */ { -1, -1, }, /* Done (ignored). */ --- 90,99 ---- } ; struct other_info othervals[MAXITEMS] = { { -1, -1, }, /* Load (ignored). */ { -1, -1, }, /* New game (ignored). */ { -1, -1, }, /* Save (ignored). */ + { -1, -1, }, /* Show all (ignored). */ { -1, -1, }, /* Suggest (ignored). */ { -1, -1, }, /* Undo (ignored). */ { -1, -1, }, /* Done (ignored). */ *************** *** 346,353 **** } else if (x == 237 && y == 195) /* Note message. */ { ! draw_string(othervals[(int) NOTES_MES].column, ! othervals[(int) NOTES_MES].row, str, TRUE) ; return ; } else if (x == 15 && y == 237) /* Score message. */ --- 351,358 ---- } else if (x == 237 && y == 195) /* Note message. */ { ! draw_string(othervals[(int) EVAL_MES].column, ! othervals[(int) EVAL_MES].row, str, TRUE) ; return ; } else if (x == 15 && y == 237) /* Score message. */ *************** *** 371,378 **** if (EQUAL(str, items[i].text)) if (ttyvals[i].column != -1) { ! if (EQUAL(str, "load")) STRCPY(str, "Load") ; ! else if (EQUAL(str, "save")) STRCPY(str, "Save") ; draw_string(ttyvals[i].column, ttyvals[i].row, str, FALSE) ; return ; } --- 376,384 ---- if (EQUAL(str, items[i].text)) if (ttyvals[i].column != -1) { ! if (EQUAL(str, "load")) STRCPY(str, "Load") ; ! else if (EQUAL(str, "save")) STRCPY(str, "Save") ; ! else if (EQUAL(str, "show all")) STRCPY(str, "show All") ; draw_string(ttyvals[i].column, ttyvals[i].row, str, FALSE) ; return ; } ------- x11.c ------- *** /tmp/da28929 Fri Nov 9 10:40:00 1990 --- x11.c Thu Nov 8 10:28:39 1990 *************** *** 7,17 **** * Copyright (c) 1990 - Rich Burridge & Yves Gallot. * All rights reserved. * ! * Permission is given to distribute these sources, as long as the ! * introductory messages are not removed, and no monies are exchanged. * ! * You are forbidden from using Reve as is, or in a modified state, in ! * any tournaments, without the permission of the authors. * * No responsibility is taken for any errors or inaccuracies inherent * either to the comments or the code of this program, but if reported --- 7,22 ---- * Copyright (c) 1990 - Rich Burridge & Yves Gallot. * All rights reserved. * ! * Permission is granted to copy this source, for redistribution ! * in source form only, provided the news headers in "substantially ! * unaltered format" are retained, the introductory messages are not ! * removed, and no monies are exchanged. * ! * Permission is also granted to copy this source, without the ! * news headers, for the purposes of making an executable copy by ! * means of compilation, provided that such copy will not be used ! * for the purposes of competition in any othello tournaments, without ! * prior permission from the authors. * * No responsibility is taken for any errors or inaccuracies inherent * either to the comments or the code of this program, but if reported *************** *** 18,30 **** * (see README file), then an attempt will be made to fix them. */ - #include - #include - #include #include "reve.h" #include "color.h" #include "extern.h" #include "images.h" #include #include #include --- 23,40 ---- * (see README file), then an attempt will be made to fix them. */ #include "reve.h" #include "color.h" #include "extern.h" #include "images.h" + #include + + #ifdef SYSV + #include + #else + #include + #endif /*SYSV*/ + #include #include #include *************** *** 53,59 **** GC stencilgc[MAXDPY] ; /* Graphics context for stencils. */ Pixmap images[MAXIMAGES] ; Pixmap no_pixmap ; ! Pixmap load_color_icon(), load_image(), reve_icon ; Window frame[MAXDPY], root[MAXDPY] ; XClassHint class_hint = { "reve", "Reve" } ; XColor BGcolor, FGcolor ; --- 63,69 ---- GC stencilgc[MAXDPY] ; /* Graphics context for stencils. */ Pixmap images[MAXIMAGES] ; Pixmap no_pixmap ; ! Pixmap load_color_icon(), load_image(), reve_icon[MAXDPY] ; Window frame[MAXDPY], root[MAXDPY] ; XClassHint class_hint = { "reve", "Reve" } ; XColor BGcolor, FGcolor ; *************** *** 62,68 **** XSizeHints size ; XWMHints wm_hints ; XGCValues gc_val ; /* Used to setup graphics context values. */ - int cmap_loaded ; /* Set if we've already loaded the colormap. */ int gc_flags ; /* Used to set up graphics context flags. */ int screen[MAXDPY] ; /* Default graphics display screen. */ int xfd[MAXDPY] ; /* Server connection file descriptors. */ --- 72,77 ---- *************** *** 79,85 **** fd_set fullmask ; /* Full mask of file descriptors to check on. */ fd_set readmask ; /* Readmask used in select call. */ #endif /*NO_43SELECT*/ ! #endif /*NOSELECT*/ /* 256-byte table for quickly reversing the bits in an unsigned 8-bit char, * used to convert between MSBFirst and LSBFirst image formats. --- 88,94 ---- fd_set fullmask ; /* Full mask of file descriptors to check on. */ fd_set readmask ; /* Readmask used in select call. */ #endif /*NO_43SELECT*/ ! #endif /*!NOSELECT*/ /* 256-byte table for quickly reversing the bits in an unsigned 8-bit char, * used to convert between MSBFirst and LSBFirst image formats. *************** *** 221,227 **** d = (int) cur_dpyno ; if (iscolor[d]) gc_val.foreground = palette[color] ; ! else gc_val.foreground = foregnd[d] ; gc_val.function = opvals[(int) op] ; XChangeGC(dpy[d], gc[d], GCForeground | GCFunction, &gc_val) ; XDrawLine(dpy[d], frame[d], gc[d], x1, y1, x2, y2) ; --- 230,240 ---- d = (int) cur_dpyno ; if (iscolor[d]) gc_val.foreground = palette[color] ; ! else ! { ! if (color == C_WHITE) gc_val.foreground = backgnd[d] ; ! else gc_val.foreground = foregnd[d] ; ! } gc_val.function = opvals[(int) op] ; XChangeGC(dpy[d], gc[d], GCForeground | GCFunction, &gc_val) ; XDrawLine(dpy[d], frame[d], gc[d], x1, y1, x2, y2) ; *************** *** 356,362 **** #else FD_ZERO(&fullmask) ; #endif /*NO_43SELECT*/ ! #endif /*NOSELECT*/ if (dtype == XTWO) { --- 369,375 ---- #else FD_ZERO(&fullmask) ; #endif /*NO_43SELECT*/ ! #endif /*!NOSELECT*/ if (dtype == XTWO) { *************** *** 364,370 **** init_X(DPY2, XWHITE) ; } else init_X(DPY1, dtype) ; - cmap_loaded = 0 ; move_delta = 10 ; images[(int) BUT_STENCIL] = load_image(button_stencil_image) ; --- 377,382 ---- *************** *** 394,400 **** u_char red[OTH_COLORSIZE], green[OTH_COLORSIZE], blue[OTH_COLORSIZE] ; int d, i, numcolors ; - if (cmap_loaded) return ; d = (int) cur_dpyno ; iscolor[d] = 0 ; if (DisplayCells(dpy[d], screen[d]) > 2) --- 406,411 ---- *************** *** 417,423 **** FPRINTF(stderr, "%s: cannot allocate colors.\n", progname) ; exit(1) ; } - cmap_loaded = 1 ; } } --- 428,433 ---- *************** *** 491,499 **** opvals[(int) RSRC] = GXcopy ; opvals[(int) RINV] = GXxor ; ! load_colors() ; ! if (iscolor[d]) reve_icon = load_color_icon(cicon_image) ; ! else reve_icon = load_image(icon_image) ; size.flags = PMinSize | PMaxSize | PPosition | PSize ; size.x = 0 ; --- 501,509 ---- opvals[(int) RSRC] = GXcopy ; opvals[(int) RINV] = GXxor ; ! if (!monochrome) load_colors() ; ! if (iscolor[d]) reve_icon[d] = load_color_icon(cicon_image) ; ! else reve_icon[d] = load_image(icon_image) ; size.flags = PMinSize | PMaxSize | PPosition | PSize ; size.x = 0 ; *************** *** 527,539 **** protocol_atom[d] = XInternAtom(dpy[d], "WM_PROTOCOLS", False) ; kill_atom[d] = XInternAtom(dpy[d], "WM_DELETE_WINDOW", False) ; ! XSetStandardProperties(dpy[d], frame[d], "reve", NULL, reve_icon, argv, argc, &size) ; wm_hints.icon_x = ix ; wm_hints.icon_y = iy ; wm_hints.input = True ; ! wm_hints.icon_pixmap = reve_icon ; wm_hints.flags = InputHint | IconPixmapHint ; if (iconic) { --- 537,549 ---- protocol_atom[d] = XInternAtom(dpy[d], "WM_PROTOCOLS", False) ; kill_atom[d] = XInternAtom(dpy[d], "WM_DELETE_WINDOW", False) ; ! XSetStandardProperties(dpy[d], frame[d], "reve", NULL, reve_icon[d], argv, argc, &size) ; wm_hints.icon_x = ix ; wm_hints.icon_y = iy ; wm_hints.input = True ; ! wm_hints.icon_pixmap = reve_icon[d] ; wm_hints.flags = InputHint | IconPixmapHint ; if (iconic) { *************** *** 587,593 **** #else FD_SET(xfd[d], &fullmask) ; #endif /*NO_43SELECT*/ ! #endif /*NOSELECT*/ return(dpy) ; } --- 597,603 ---- #else FD_SET(xfd[d], &fullmask) ; #endif /*NO_43SELECT*/ ! #endif /*!NOSELECT*/ return(dpy) ; } *************** *** 704,710 **** for (;;) { get_event() ; /* Get next canvas event. */ - process_event() ; /* Find out what kind it is. */ handle_event() ; /* And do the apropriate action. */ } } --- 714,719 ---- *************** *** 713,728 **** Xselect_input() { int fd = -1 ; /* File descriptor with this event. */ ! struct timeval tval ; /* To set checking period. */ - tval.tv_usec = 0 ; - tval.tv_sec = 0 ; - for (;;) { ! XSync(dpy[0], 0) ; ! if (dtype == XTWO) XSync(dpy[1], 0) ; ! #ifdef NOSELECT fd = 0 ; #else --- 722,734 ---- Xselect_input() { int fd = -1 ; /* File descriptor with this event. */ ! /** static struct timeval tval = { 0, 0 } ; **/ ! struct timeval *tval = NULL ; for (;;) { ! XFlush(dpy[(int) DPY1]) ; ! XFlush(dpy[(int) DPY2]) ; #ifdef NOSELECT fd = 0 ; #else *************** *** 730,737 **** readmask = fullmask ; #ifdef NO_43SELECT SELECT(32, &readmask, 0, 0, &tval) ; ! if (readmask && (1 << xfd)[0]) fd = 0 ; ! else if (readmask && (1 << xfd)[1]) fd = 1 ; #else SELECT(FD_SETSIZE, &readmask, (fd_set *) 0, (fd_set *) 0, &tval) ; if (FD_ISSET(xfd[0], &readmask)) fd = 0 ; --- 736,743 ---- readmask = fullmask ; #ifdef NO_43SELECT SELECT(32, &readmask, 0, 0, &tval) ; ! if (readmask && (1 << xfd[0])) fd = 0 ; ! else if (readmask && (1 << xfd[1])) fd = 1 ; #else SELECT(FD_SETSIZE, &readmask, (fd_set *) 0, (fd_set *) 0, &tval) ; if (FD_ISSET(xfd[0], &readmask)) fd = 0 ; *************** *** 741,754 **** if (fd >= 0) { ! cur_dpyno = (enum dpy_type) fd ; ! do { ! get_event() ; /* Get next canvas event. */ ! process_event() ; /* Find out what kind it is. */ ! handle_event() ; /* And do appropriate action. */ } ! while (XPending(dpy[fd])) ; } } } --- 747,767 ---- if (fd >= 0) { ! fd = 0 ; ! cur_dpyno = DPY1 ; ! while (XPending(dpy[fd])) { ! get_event() ; /* Get next canvas event. */ ! handle_event() ; /* And do appropriate action. */ } ! ! fd = 1 ; ! cur_dpyno = DPY2 ; ! while (XPending(dpy[fd])) ! { ! get_event() ; /* Get next canvas event. */ ! handle_event() ; /* And do appropriate action. */ ! } } } } ------- FILES ------- *** /tmp/da28932 Fri Nov 9 10:40:01 1990 --- FILES Sat Nov 3 21:03:34 1990 *************** *** 33,38 **** --- 33,39 ---- reve.edge1 - first half of the Reve edge stability table. reve.edge2 - second half of the Reve edge stability table. Makefile.dist - master Makefile used to build mp on Unix systems. + Imakefile - Imakefile for the X11 version of reve. sunview.c - Sun SunView graphics routines. tty.c - dumb tty "graphics" routines. ------- MANIFEST ------- *** /tmp/da28935 Fri Nov 9 10:40:02 1990 --- MANIFEST Sat Nov 3 21:04:35 1990 *************** *** 32,37 **** --- 32,38 ---- x11.c | 4 xview.c | 4 sunview.c | 5 + Imakefile | 5 images/black.icon | 5 images/reve.icon | 5 images/reve.color.icon | 5 ------- reve.edge2 ------- *** /tmp/da28938 Fri Nov 9 10:40:03 1990 --- reve.edge2 Fri Oct 26 12:05:37 1990 *************** *** 549,555 **** edges[2188] = -80 [ -oooooo- ] edges[2189] = 1304 [ xoooooo- ] edges[2190] = -1166 [ o-ooooo- ] ! edges[2191] = 34 [ --ooooo- ] edges[2192] = 1234 [ x-ooooo- ] edges[2193] = 1434 [ oxooooo- ] edges[2194] = -36 [ -xooooo- ] --- 549,555 ---- edges[2188] = -80 [ -oooooo- ] edges[2189] = 1304 [ xoooooo- ] edges[2190] = -1166 [ o-ooooo- ] ! edges[2191] = 100 [ --ooooo- ] edges[2192] = 1234 [ x-ooooo- ] edges[2193] = 1434 [ oxooooo- ] edges[2194] = -36 [ -xooooo- ] *************** *** 1275,1281 **** edges[2914] = 36 [ -xxxxxo- ] edges[2915] = 6511 [ xxxxxxo- ] edges[2916] = -6441 [ oooooo-- ] ! edges[2917] = 34 [ -ooooo-- ] edges[2918] = 1234 [ xooooo-- ] edges[2919] = -1236 [ o-oooo-- ] edges[2920] = -36 [ --oooo-- ] --- 1275,1281 ---- edges[2914] = 36 [ -xxxxxo- ] edges[2915] = 6511 [ xxxxxxo- ] edges[2916] = -6441 [ oooooo-- ] ! edges[2917] = 100 [ -ooooo-- ] edges[2918] = 1234 [ xooooo-- ] edges[2919] = -1236 [ o-oooo-- ] edges[2920] = -36 [ --oooo-- ]