mirror of
https://github.com/PDP-10/its.git
synced 2026-03-22 09:03:20 +00:00
Unsorted files from CLUSRC; \O -IPAK-
This commit is contained in:
19
src/as/o/blt.1
Normal file
19
src/as/o/blt.1
Normal file
@@ -0,0 +1,19 @@
|
||||
;
|
||||
; BLT
|
||||
;
|
||||
|
||||
RELOCATABLE
|
||||
TITLE BLT
|
||||
.INSRT C;NC INSERT
|
||||
.INSRT C;NM INSERT
|
||||
|
||||
CENTRY BLT,[FROM,TO,NUM]
|
||||
|
||||
HRRZ A,TO
|
||||
HRRZI B,-1(A)
|
||||
ADD B,NUM
|
||||
HRL A,FROM
|
||||
BLT A,(B)
|
||||
RETURN
|
||||
|
||||
END
|
||||
BIN
src/as/o/blt.rel
Normal file
BIN
src/as/o/blt.rel
Normal file
Binary file not shown.
35
src/as/o/ismov1.midas
Normal file
35
src/as/o/ismov1.midas
Normal file
@@ -0,0 +1,35 @@
|
||||
;
|
||||
; ISMOV1
|
||||
;
|
||||
RELOCATABLE
|
||||
TITLE ISMOV1
|
||||
.INSRT C;NC INSERT
|
||||
.INSRT C;NM INSERT
|
||||
|
||||
CENTRY ISMOV1,[BB,CC,P1]
|
||||
|
||||
DD==3
|
||||
P2==2
|
||||
K==5
|
||||
|
||||
MOVEI DD,ZDIRLI" ; DIRECTION LIST
|
||||
NXTDIR: MOVE D,(DD) ; NEXT DIRECTION
|
||||
ADDI DD,1 ; REST OF LIST
|
||||
JUMPE D,LOSE ; IF NO MORE DIRECTIONS
|
||||
MOVE P2,P1 ; INITIAL POSITION
|
||||
SETZ K, ; COUNTER
|
||||
NXTPOS: ADD P2,D ; MOVE 1 STEP
|
||||
SKIPG ZSQVAL"(P2) ; STILL ON THE BOARD?
|
||||
GO NXTDIR ; NO
|
||||
MOVE A,BB ; THE BOARD
|
||||
ADDI A,(P2) ; ADDRESS OF SQUARE AT P2
|
||||
MOVE A,(A) ; CONTENTS OF SQUARE AT P2
|
||||
JUMPE A,NXTDIR ; IT'S EMPTY
|
||||
CAME A,CC ; IS IT OUR COLOR?
|
||||
AOJA K,NXTPOS ; NO, COUNT TOKEN AND GO TO NEXT POSITION
|
||||
JUMPE K,NXTDIR ; DID NOT PASS OVER ANY OPPONENT
|
||||
MOVEI A,1 ; WIN!
|
||||
RET: RETURN
|
||||
LOSE: MOVEI A,0
|
||||
GO RET
|
||||
END
|
||||
BIN
src/as/o/ismov1.rel
Normal file
BIN
src/as/o/ismov1.rel
Normal file
Binary file not shown.
122
src/as/o/o.h
Normal file
122
src/as/o/o.h
Normal file
@@ -0,0 +1,122 @@
|
||||
# ifdef unix
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
|
||||
/* colors */
|
||||
|
||||
# define EMPTY 0 /* - */
|
||||
# define WHITE 1 /* @ */
|
||||
# define BLACK 2 /* * */
|
||||
|
||||
/* commands */
|
||||
|
||||
# define ANALYZ 'a'
|
||||
# define PBOARD 'b'
|
||||
# define HCAP 'h'
|
||||
# define LISTM 'l'
|
||||
# define MANUAL 'm'
|
||||
# define OPTCOM 'o'
|
||||
# define QUIT 'q'
|
||||
# define RESIGN 'r'
|
||||
# define READCM 'B'
|
||||
# define SCORE 's'
|
||||
# define TREECM 't'
|
||||
# define WRITCM 'w'
|
||||
# define XCOM 'x'
|
||||
# define HELP '?'
|
||||
# define SHELL '!'
|
||||
|
||||
/* internal commands */
|
||||
|
||||
# define ERROR 0
|
||||
# define MOVE 'M'
|
||||
# define DONE 'D'
|
||||
# define RETRY 'R'
|
||||
|
||||
/* answers */
|
||||
|
||||
# define YES 'y'
|
||||
# define NO 'n'
|
||||
|
||||
# ifndef unix
|
||||
# define fastchar int
|
||||
# endif
|
||||
# ifdef unix
|
||||
# define fastchar char
|
||||
# endif
|
||||
|
||||
extern fastchar sqval[100], ssqval[100];
|
||||
extern int endgame;
|
||||
|
||||
typedef fastchar board[100];
|
||||
typedef int position;
|
||||
typedef int direction;
|
||||
typedef int color;
|
||||
|
||||
# define oppcolor(c) ((c)^3)
|
||||
# define bscore(b,c) (b[c])
|
||||
|
||||
# define ismove(b,c,p) ((b[p] == EMPTY) && ismov1(b,c,p))
|
||||
|
||||
struct mt {
|
||||
position p;
|
||||
int c;
|
||||
int s;
|
||||
};
|
||||
|
||||
# define NORTH (-10)
|
||||
# define EAST 1
|
||||
# define SOUTH 10
|
||||
# define WEST (-1)
|
||||
# define NORTHEAST (-9)
|
||||
# define NORTHWEST (-11)
|
||||
# define SOUTHEAST 11
|
||||
# define SOUTHWEST 9
|
||||
|
||||
# define CORNERVALUE 7
|
||||
# define EDGEVALUE 6
|
||||
# define HEDGEVALUE 5
|
||||
# define INTERIORVALUE 4
|
||||
|
||||
# define CORNERSCORE 30
|
||||
# define EDGESCORE 15
|
||||
# define POINTSCORE 4
|
||||
# define INTERIORSCORE 3
|
||||
# define DANGERSCORE 2
|
||||
|
||||
# define MIDDLEMOVE 27
|
||||
# define ENDGAMEMOVE 27
|
||||
|
||||
# define sqscore(p) (endgame ? 1 : ssqval[p])
|
||||
|
||||
# define valid(p) (sqval[p]>0)
|
||||
# define edge(p) (ssqval[p]>=EDGESCORE)
|
||||
# define corner(p) (sqval[p]>=CORNERVALUE)
|
||||
# define horizedge(p) ((p)<19||(p)>80)
|
||||
# define adjedge(p) (sqval[p]==2)
|
||||
# define adjdiag(p) (sqval[p]==1)
|
||||
# define adjcorner(p) (sqval[p]<=2)
|
||||
|
||||
# define forallpos(p) for(p=11;p<89;++p) if(valid(p))
|
||||
# define nextpos(p,d) (p=+(d))
|
||||
# define abs(a) ((a)<0?-(a):(a))
|
||||
# define oppdir(d) (-(d))
|
||||
# define posx(p) (((p)/10)-1)
|
||||
# define posy(p) (((p)%10)-1)
|
||||
# define pos(x,y) ((x)*10+(y)+11)
|
||||
|
||||
# ifndef unix
|
||||
# define FILE int
|
||||
# define NULL 0
|
||||
# define EOF -1
|
||||
# define BUFSIZ 512
|
||||
extern int stdin, stdout;
|
||||
# define fopen flopen
|
||||
# define time nowtime
|
||||
# endif
|
||||
|
||||
# ifndef unix
|
||||
# define cpybrd(a,b) (blt((b),(a),100))
|
||||
# endif
|
||||
11
src/as/o/o.maktap
Normal file
11
src/as/o/o.maktap
Normal file
@@ -0,0 +1,11 @@
|
||||
u
|
||||
u 9 2
|
||||
a o.h
|
||||
a o1.c
|
||||
a o2.c
|
||||
a o3.c
|
||||
a o4.c
|
||||
a o5.c
|
||||
a o6.c
|
||||
|
||||
|
||||
62
src/as/o/o.notes
Normal file
62
src/as/o/o.notes
Normal file
@@ -0,0 +1,62 @@
|
||||
perhaps should count edges against, in order to save edge spaces
|
||||
for later
|
||||
|
||||
-----
|
||||
|
||||
randomize strategy for confusing humans
|
||||
|
||||
-----
|
||||
|
||||
bug: rates * - @
|
||||
* @ -
|
||||
- @ M * @ *
|
||||
|
||||
for * even though * loses the corner
|
||||
|
||||
-----
|
||||
|
||||
an obscure point: sometimes too eager to run along the edge when
|
||||
about to lose a corner, e.g.
|
||||
|
||||
- - -
|
||||
- @ -
|
||||
@ - *
|
||||
@ - -
|
||||
* * -
|
||||
? * - really shouldn't take this
|
||||
@ - -
|
||||
- - -
|
||||
|
||||
-----
|
||||
|
||||
need an algorithm for determining which corner to give up and when to
|
||||
play X moves
|
||||
|
||||
-----
|
||||
|
||||
perhaps should rate takeback on edge higher, e.g. X * @ for @
|
||||
along the edge is better than a random edge-taking move
|
||||
when the opponent can also take an edge
|
||||
really need a better transition analysis so that the program will
|
||||
prefer to take a super-safe edge even if it is going to
|
||||
lose a corner anyway; perhaps need a category for super-safe
|
||||
edge; would need a prevents-losing-corner category
|
||||
|
||||
-----
|
||||
|
||||
this position good for *: - * - @ @ - * -
|
||||
|
||||
-----
|
||||
|
||||
these moves not so bad for *, * not likely to get those anyway:
|
||||
|
||||
- - @ ? ? @ - -
|
||||
|
||||
-----
|
||||
|
||||
these moves are bad for *, they lose the ability to later move in
|
||||
2 or 7:
|
||||
|
||||
- - ? @ @ ? - -
|
||||
|
||||
|
||||
221
src/as/o/o.old
Normal file
221
src/as/o/o.old
Normal file
@@ -0,0 +1,221 @@
|
||||
|
||||
#define FHOLE 1
|
||||
#define FCORNER 2
|
||||
|
||||
/*
|
||||
* hole - does the position resulting from a move at P by C contain a
|
||||
* hole for O? If so, what value square is given up?
|
||||
*
|
||||
*/
|
||||
|
||||
hole(b,c,o,p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{register int h;
|
||||
if (horizedge (p))
|
||||
h = hole1 (b,c,o,p,EAST) | hole1 (b,c,o,p,WEST);
|
||||
else
|
||||
h = hole1 (b,c,o,p,NORTH) | hole1 (b,c,o,p,SOUTH);
|
||||
if (h == (FHOLE+FCORNER)) return (CORNERVALUE);
|
||||
if (h & FHOLE) return (EDGEVALUE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* [_ X = FCORNER
|
||||
* [_ c+ o* X = FCORNER -- this seems wrong
|
||||
*
|
||||
*/
|
||||
|
||||
hole1(b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
register position p;
|
||||
direction d;
|
||||
|
||||
{int n, m;
|
||||
n = 0;
|
||||
while (b[p] == o)
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
else ++n;
|
||||
m = 0;
|
||||
while (b[p] == c)
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
else ++m;
|
||||
if (corner (p))
|
||||
{if (b[p] == EMPTY)
|
||||
{if (n == 0) return (FCORNER);
|
||||
if (m > 0) return (FCORNER);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (0);
|
||||
if (b[p] == c) return (0);
|
||||
if (corner (p)) return (0);
|
||||
n = 0;
|
||||
while (b[p] == EMPTY)
|
||||
{++n;
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
}
|
||||
if ((n & 1) == 0) return (0);
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (FHOLE);
|
||||
if (b[p] != c) return (0);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (FHOLE);
|
||||
if (b[p] == o) return (FHOLE);
|
||||
if (corner (p)) return (FHOLE+FCORNER);
|
||||
return (FHOLE);
|
||||
}
|
||||
|
||||
|
||||
takeback(b,c,o,p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{return (takb1(b,c,o,p,NORTH) ||
|
||||
takb1(b,c,o,p,NORTHEAST) ||
|
||||
takb1(b,c,o,p,EAST) ||
|
||||
takb1(b,c,o,p,SOUTHEAST));
|
||||
}
|
||||
|
||||
takb1(b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{register int c1, c2;
|
||||
c1 = takb2(b,c,o,p,d);
|
||||
c2 = takb2(b,c,o,p,oppdir(d));
|
||||
return(c1==o&&c2==EMPTY || c1==EMPTY&&c2==o);
|
||||
}
|
||||
|
||||
takb2(b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
register position p;
|
||||
direction d;
|
||||
|
||||
{nextpos (p, d);
|
||||
if (valid (p))
|
||||
{while (b[p] == o)
|
||||
{nextpos (p, d);
|
||||
if (!valid (p) || b[p]==EMPTY) return (o);
|
||||
}
|
||||
}
|
||||
while (valid (p) && b[p] == c) nextpos (p, d);
|
||||
if (!valid (p)) return (c);
|
||||
return (b[p]);
|
||||
}
|
||||
|
||||
int trydepth;
|
||||
|
||||
int tryedge (oldb,b,c,o,p,d) /* return score from O's point of view */
|
||||
board oldb, b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{int s1, s2, rc;
|
||||
|
||||
++trydepth;
|
||||
if (eflag)
|
||||
{putn (trydepth);
|
||||
printf ("tryedge (%c, %d%d):\n", pcolor[c],
|
||||
posx(p)+1, posy(p)+1);
|
||||
}
|
||||
s1 = try1edge (oldb,b,c,o,p,d);
|
||||
s2 = try1edge (oldb,b,c,o,p,oppdir(d));
|
||||
if (s1 == 0)
|
||||
{if (s2 == 0) rc = 1;
|
||||
else rc = -s2;
|
||||
}
|
||||
else if (s2 == 0) rc = -s1;
|
||||
else
|
||||
{if (s2>s1) s1=s2;
|
||||
rc = -s1;
|
||||
}
|
||||
if (eflag)
|
||||
{putn (trydepth);
|
||||
printf ("tryedge (%c, %d%d) = %d\n", pcolor[c],
|
||||
posx(p)+1, posy(p)+1, rc);
|
||||
}
|
||||
--trydepth;
|
||||
return (rc);
|
||||
}
|
||||
|
||||
int try1edge (oldb,b,c,o,p,d) /* return score from C's point of view */
|
||||
board oldb, b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{position p1;
|
||||
int rc;
|
||||
|
||||
++trydepth;
|
||||
if (eflag)
|
||||
{putn (trydepth);
|
||||
printf ("try1edge (%c, %d%d, %d):\n", pcolor[c],
|
||||
posx(p)+1, posy(p)+1, d);
|
||||
}
|
||||
|
||||
rc = 0;
|
||||
p1 = p;
|
||||
while (valid (nextpos (p, d)))
|
||||
{if (b[p] == EMPTY)
|
||||
{if (ismove (b,c,p))
|
||||
{board a;
|
||||
cpybrd (a,b);
|
||||
putmov (a,c,p);
|
||||
/* if (a[p1]==o) {rc = -1; break;} */
|
||||
if (corner(p))
|
||||
{if (ismove (oldb,c,p)) rc = 1;
|
||||
else rc = 2;
|
||||
break;
|
||||
}
|
||||
rc = tryedge (oldb,a,o,c,p,d);
|
||||
if (rc<0 && !ismove(b,o,p))
|
||||
rc = 1; /* C need not move */
|
||||
break;
|
||||
}
|
||||
if (ismove (b,o,p)) /* C can't move, but O can */
|
||||
{rc = -try1edge (oldb,b,o,c,p1,d);
|
||||
if (rc > 0) rc = 0; /* O need not move */
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (eflag)
|
||||
{putn (trydepth);
|
||||
printf ("try1edge (%c, %d%d, %d) = %d\n", pcolor[c],
|
||||
posx(p)+1, posy(p)+1, d, rc);
|
||||
}
|
||||
--trydepth;
|
||||
return (rc);
|
||||
}
|
||||
|
||||
/*
|
||||
else
|
||||
{struct mt t[64], *tp[64];
|
||||
register struct mt **mp;
|
||||
register int k;
|
||||
k = pmvgen (a,o,c,tp,t,movnum>=MIDDLEMOVE);
|
||||
mp = tp;
|
||||
while (--k >= 0)
|
||||
{position q;
|
||||
register int temp;
|
||||
q = (*mp++)->p;
|
||||
temp = -meval(a,o,c,q,-minmove);
|
||||
if (temp<minmove)
|
||||
{minmove=temp;
|
||||
if (minmove<alpha) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
834
src/as/o/o1.c
Normal file
834
src/as/o/o1.c
Normal file
@@ -0,0 +1,834 @@
|
||||
# include "o.h"
|
||||
# ifdef unix
|
||||
char *log "/usr/games/o.log";
|
||||
# endif
|
||||
# ifndef unix
|
||||
char *log "c/_ o.stat";
|
||||
char *recfile "as/o.record";
|
||||
# endif
|
||||
char *svgame "o.game";
|
||||
|
||||
# define MVNREAL 6 /* after this move, game is for real */
|
||||
|
||||
int n_inhibit;
|
||||
char username[100];
|
||||
static int wizard;
|
||||
char buf[BUFSIZ];
|
||||
char gambuf[1000];
|
||||
FILE *gamefile;
|
||||
char *timestring;
|
||||
int fcnt[3];
|
||||
int machine[3];
|
||||
int manmode; /* redundant variable */
|
||||
int handicap;
|
||||
int endgame;
|
||||
int explain, eflag, debug;
|
||||
int mvnhack 1;
|
||||
int superself;
|
||||
int display;
|
||||
int movnum;
|
||||
color player;
|
||||
color mcolor;
|
||||
int selfplay;
|
||||
int nanalyze;
|
||||
position h[4] {pos(0,0),pos(7,7),pos(0,7),pos(7,0)};
|
||||
|
||||
char *helpmsg
|
||||
"l - list legal moves\n\
|
||||
a - analyze position (A=best)\n\
|
||||
b - print board\n\
|
||||
s - print score\n\
|
||||
r - resign game (score is recorded)\n\
|
||||
x - show board after move (toggle)\n\
|
||||
h - set handicap (-4 .. 4)\n\
|
||||
m - manual mode (user plays both sides)\n\
|
||||
q - quit this game (score not recorded)\n\
|
||||
rb - read board from file\n\
|
||||
wb - write board to file\n";
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
{bk_init ();
|
||||
stdio ();
|
||||
getuser ();
|
||||
setsuper ();
|
||||
if (superself) display = 0;
|
||||
else
|
||||
{checkuser ();
|
||||
display = isdisplay ();
|
||||
if (argc>1) options (argv[1]);
|
||||
if (display) clrscreen ();
|
||||
prnews ();
|
||||
}
|
||||
setrand ();
|
||||
# ifndef unix
|
||||
if (debug>0)
|
||||
# endif
|
||||
mcolor = WHITE;
|
||||
# ifndef unix
|
||||
else mcolor = (rand () & 1 ? WHITE : BLACK);
|
||||
# endif
|
||||
manmode = 0;
|
||||
while (playgame () && (superself || ask(stdin,"Another game") == YES));
|
||||
# ifdef unix
|
||||
if (ask(stdin,"Delete saved game") == YES)
|
||||
unlink (svgame);
|
||||
# endif
|
||||
exit(0);
|
||||
}
|
||||
|
||||
options (s)
|
||||
char *s;
|
||||
|
||||
{register fastchar c;
|
||||
explain = debug = eflag = 0;
|
||||
while (c = lower (*s++)) switch (c) {
|
||||
case 'x': if (wizard || explain==0) ++explain; continue;
|
||||
case 'd': if (wizard) ++debug; continue;
|
||||
case 'e': if (wizard) ++eflag; continue;
|
||||
case 'm': if (wizard) mvnhack = !mvnhack; continue;
|
||||
}
|
||||
if (debug>0) explain=2;
|
||||
}
|
||||
|
||||
playgame ()
|
||||
|
||||
{board b;
|
||||
int i;
|
||||
|
||||
settime();
|
||||
clrbrd(b);
|
||||
# ifndef unix
|
||||
gamefile = copen (gambuf, 'w', "s");
|
||||
# endif
|
||||
# ifdef unix
|
||||
if (superself) gamefile = fopen (svgame, "a");
|
||||
else gamefile = fopen (svgame, "w");
|
||||
if (gamefile == NULL)
|
||||
{printf ("Can't create %s\n", svgame);
|
||||
return (0);
|
||||
}
|
||||
# endif
|
||||
if (superself) fprintf (gamefile, "----------\n");
|
||||
|
||||
# ifdef unix
|
||||
else prgame (gamefile);
|
||||
# endif
|
||||
|
||||
i = game(b);
|
||||
if (i != QUIT && i != EOF)
|
||||
{putc ('\n', gamefile);
|
||||
prtscr (b, gamefile, FALSE);
|
||||
putc ('\n', gamefile);
|
||||
if (n_inhibit == 0) inhibit ();
|
||||
if (!superself && i != RESIGN) shwscore (b);
|
||||
if (!manmode) wrstat (b, i==RESIGN);
|
||||
}
|
||||
fclose (gamefile);
|
||||
# ifndef unix
|
||||
if (i != QUIT && i != EOF)
|
||||
{if (!superself && !manmode && cntbrd(b,oppcolor(mcolor))>=50
|
||||
&& handicap==0)
|
||||
{FILE *f;
|
||||
f = fopen (recfile, "a");
|
||||
if (f != NULL)
|
||||
{prgame (f);
|
||||
putc ('\p', f);
|
||||
fclose (f);
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
uninhibit ();
|
||||
# ifndef unix
|
||||
if (superself || (movnum > MVNREAL && ask (stdin, "Save game")==YES))
|
||||
{FILE *f;
|
||||
if (superself) f = fopen ("o.game", "a");
|
||||
else f = fopen ("ogame", "w");
|
||||
if (f == NULL) printf ("Can't open file\n");
|
||||
else
|
||||
{prgame (f);
|
||||
fclose (f);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
mcolor = oppcolor (mcolor);
|
||||
return (i != EOF);
|
||||
}
|
||||
|
||||
prgame (f)
|
||||
|
||||
{fprintf (f, "%s (", username);
|
||||
if (manmode)
|
||||
fprintf (f, "manual");
|
||||
else putcolor (oppcolor (mcolor), f);
|
||||
fprintf (f, ") %s\n", timestring);
|
||||
fprintf (f, "%s", gambuf);
|
||||
}
|
||||
|
||||
shwscore (b)
|
||||
board b;
|
||||
|
||||
{int i;
|
||||
printf("\n");
|
||||
i = prtscr(b,stdout,TRUE);
|
||||
putchar (' ');
|
||||
if (i!=0)
|
||||
{if (!manmode)
|
||||
{if (i > 0) printf("You won by %d\n",i);
|
||||
else printf("You lost by %d\n",-i);
|
||||
}
|
||||
else
|
||||
{if (i > 0) printf ("* won by %d\n", i);
|
||||
else printf ("@ won by %d\n", -i);
|
||||
}
|
||||
}
|
||||
else printf("A draw\n");
|
||||
}
|
||||
|
||||
wrstat (b, resigned)
|
||||
board b;
|
||||
|
||||
{FILE *f;
|
||||
if (debug)
|
||||
{wrfstat (b, resigned, stdout);
|
||||
if (ask(stdin,"Write stat file")==NO) return;
|
||||
}
|
||||
if ((f = fopen(log,"a"))!=NULL)
|
||||
{wrfstat (b, resigned, f);
|
||||
fclose (f);
|
||||
}
|
||||
}
|
||||
|
||||
wrfstat (b, resigned, f)
|
||||
board b;
|
||||
FILE *f;
|
||||
|
||||
{if (superself) putc ('O', f);
|
||||
else fprintf (f, "%s", username);
|
||||
putc('\t',f);
|
||||
prtscr(b,f,TRUE);
|
||||
putc ('\t', f);
|
||||
putcolor (oppcolor(mcolor), f);
|
||||
if (resigned) putc ('r', f);
|
||||
else if (nanalyze>10) putc ('a', f);
|
||||
fprintf (f, "%d\t%d+%d\t%s",
|
||||
handicap,fcnt[oppcolor(mcolor)],fcnt[mcolor],timestring);
|
||||
}
|
||||
|
||||
settime ()
|
||||
|
||||
{int tv[2];
|
||||
time (tv);
|
||||
timestring = ctime(tv);
|
||||
}
|
||||
|
||||
game (b)
|
||||
board b;
|
||||
|
||||
{handicap = fcnt[BLACK] = fcnt[WHITE] = 0;
|
||||
endgame = -1000;
|
||||
setmov (b, 1);
|
||||
machine[mcolor] = TRUE;
|
||||
machine[oppcolor(mcolor)] = superself;
|
||||
player = BLACK;
|
||||
bk_clear (BLACK);
|
||||
selfplay = superself;
|
||||
nanalyze = 0;
|
||||
if (!superself && machine[player] && display) dpyempty ();
|
||||
for (;;)
|
||||
{position p;
|
||||
int mtime;
|
||||
mtime = -1;
|
||||
if (cntbrd(b,EMPTY) == 0) break;
|
||||
if (!anymvs (b, player))
|
||||
{if (!anymvs (b, oppcolor(player))) break;
|
||||
p = -1;
|
||||
++fcnt[player];
|
||||
bk_flush ();
|
||||
if (!machine[player])
|
||||
{do_inhibit ();
|
||||
if (explain)
|
||||
{prtbrd (b);
|
||||
printf ("Forfeit. ");
|
||||
pause ();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{if (machine[player])
|
||||
{if (explain)
|
||||
if (explain>1)
|
||||
{int temp;
|
||||
temp = debug;
|
||||
debug = 0;
|
||||
analyze(b,player,oppcolor(player));
|
||||
debug = temp;
|
||||
}
|
||||
else auxbrd(b);
|
||||
mtime = cputm ();
|
||||
p = my_mov(b,player,oppcolor(player));
|
||||
if (mtime) mtime = cputm () - mtime;
|
||||
else mtime = -1;
|
||||
}
|
||||
else
|
||||
{fastchar c;
|
||||
p = onemov (b, player);
|
||||
if (p >= 0)
|
||||
{do_inhibit ();
|
||||
if (explain)
|
||||
{prtbrd (b);
|
||||
printf ("The only legal move is ");
|
||||
printf ("%d-%d. ",
|
||||
posx(p)+1, posy(p)+1);
|
||||
pause ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{uninhibit ();
|
||||
if (player==WHITE) putchar ('\n');
|
||||
switch (c = getmov(b,stdin,&p)) {
|
||||
|
||||
case RESIGN: if (ask (stdin,
|
||||
"You really want to resign") != YES)
|
||||
continue;
|
||||
if (movnum <= MVNREAL) return (QUIT);
|
||||
p = -2;
|
||||
break;
|
||||
case QUIT: if (movnum>MVNREAL && ask (stdin,
|
||||
"Would you rather resign") == YES)
|
||||
{p = -2; break;}
|
||||
if (movnum>MVNREAL) return (EOF);
|
||||
/* penalize quitters */
|
||||
case EOF: return (c);
|
||||
case RETRY: continue;
|
||||
case MOVE: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bk_move (p);
|
||||
putmov(b,player,p);
|
||||
}
|
||||
if (player==BLACK) mprint ("%d. ", movnum);
|
||||
else mprint ("...");
|
||||
if (p == -1) mprint ("Forfeit");
|
||||
else if (p == -2) mprint ("Resign");
|
||||
else
|
||||
{mprint("%d-%d", posx(p)+1, posy(p)+1);
|
||||
if (machine[player] && mtime>=0)
|
||||
{int ntenths, nsec;
|
||||
nsec = mtime / 60;
|
||||
ntenths = mtime % 60;
|
||||
ntenths = (ntenths+5)/6;
|
||||
if (ntenths==10) {ntenths=0;++nsec;}
|
||||
mprint (" (%d.%d)", nsec, ntenths);
|
||||
}
|
||||
}
|
||||
if (player == WHITE)
|
||||
{mprint ("\n");
|
||||
setmov (b, movnum+1);
|
||||
}
|
||||
else if (machine[player])
|
||||
tyo_flush ();
|
||||
player = oppcolor (player);
|
||||
if (p == -2)
|
||||
{if (player == WHITE) mprint ("\n");
|
||||
return (RESIGN);
|
||||
}
|
||||
}
|
||||
if (!superself) shwbrd(b);
|
||||
return (DONE);
|
||||
}
|
||||
|
||||
do_inhibit ()
|
||||
|
||||
{if (!debug && !eflag && n_inhibit==0 && !manmode) inhibit ();
|
||||
}
|
||||
|
||||
setmov (b, n)
|
||||
board b;
|
||||
|
||||
{int nend;
|
||||
nend = (n >= ENDGAMEMOVE);
|
||||
movnum = n;
|
||||
if (nend != endgame)
|
||||
{endgame = nend;
|
||||
fixbrd (b);
|
||||
}
|
||||
}
|
||||
|
||||
getmov (b, f, pp)
|
||||
board b;
|
||||
FILE *f;
|
||||
position *pp;
|
||||
|
||||
{int pflag;
|
||||
|
||||
pflag = 1;
|
||||
for (;;)
|
||||
{int c, p, i;
|
||||
|
||||
if (pflag && !superself)
|
||||
{if (pflag>1 && display)
|
||||
{clrscreen ();
|
||||
redisplay ();
|
||||
tyoflush();
|
||||
}
|
||||
else if (movnum>=2 || !machine[BLACK]) prtbrd (b);
|
||||
else shwbrd (b);
|
||||
}
|
||||
pflag = 0;
|
||||
c = command(stdin,&p);
|
||||
*pp = p;
|
||||
switch (c) {
|
||||
|
||||
case HELP: printf ("%s", helpmsg);
|
||||
continue;
|
||||
case MANUAL: bk_flush ();
|
||||
machine[BLACK] = machine[WHITE] = 0;
|
||||
manmode = TRUE;
|
||||
continue;
|
||||
case PBOARD: pflag = 2;
|
||||
continue;
|
||||
case READCM: bk_flush ();
|
||||
if (readbd (b, buf)) return (RETRY);
|
||||
printf ("no file\n");
|
||||
continue;
|
||||
case WRITCM: if (!writbd (b, buf)) printf ("can't\n");
|
||||
continue;
|
||||
case TREECM: dotree (b,player,oppcolor(player),p,stdout);
|
||||
continue;
|
||||
case OPTCOM: options (buf);
|
||||
continue;
|
||||
case XCOM: explain = !explain;
|
||||
continue;
|
||||
case SCORE: i = prtscr(b,stdout,TRUE);
|
||||
if (!manmode)
|
||||
{if (i > 0) printf(" You're winning.");
|
||||
else if (i < 0) printf(" You're losing!");
|
||||
}
|
||||
else
|
||||
{if (i > 0) printf (" * is winning.");
|
||||
else if (i < 0) printf (" @ is winning.");
|
||||
}
|
||||
putchar('\n');
|
||||
continue;
|
||||
case QUIT:
|
||||
case RESIGN:
|
||||
case EOF: return (c);
|
||||
case HCAP: if (handicap==0 && movnum==1)
|
||||
{for (i=0; p!=0; ++i)
|
||||
{b[h[i]] = p>0 ? player : oppcolor(player);
|
||||
handicap =+ p>0? 1: -1;
|
||||
p =+ p>0? -1 : 1;
|
||||
pflag = 1;
|
||||
}
|
||||
if (handicap!=0)
|
||||
{printf ("Warning: this game will not be ");
|
||||
printf ("counted in the statistics.\n");
|
||||
}
|
||||
}
|
||||
else printf("Too late!\n");
|
||||
continue;
|
||||
case LISTM: lstmvs (b,player);
|
||||
continue;
|
||||
case ANALYZ: printf (" (%d)\n", ++nanalyze);
|
||||
analyze(b,player,oppcolor(player));
|
||||
continue;
|
||||
case MOVE: if (ismove(b,player,p)) return (c);
|
||||
printf("Illegal!\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prtscr(b,f,reverse)
|
||||
board b;
|
||||
FILE *f;
|
||||
|
||||
{register int i, j;
|
||||
i = cntbrd (b, BLACK);
|
||||
j = cntbrd (b, WHITE);
|
||||
if (reverse && machine[BLACK])
|
||||
{int temp;
|
||||
temp = i;
|
||||
i = j;
|
||||
j = temp;
|
||||
}
|
||||
fprintf(f,"%d-%d",i,j);
|
||||
return (i-j);
|
||||
}
|
||||
|
||||
onemov (b,c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{register position p;
|
||||
position p1;
|
||||
int nmoves;
|
||||
|
||||
p1 = -1;
|
||||
nmoves = 0;
|
||||
forallpos (p) if (ismove (b,c,p))
|
||||
{p1 = p;
|
||||
if (++nmoves>1) return (-1);
|
||||
}
|
||||
return (p1);
|
||||
}
|
||||
|
||||
analyze(b,c,o)
|
||||
board b;
|
||||
color c, o;
|
||||
|
||||
{board a, omb;
|
||||
register position p;
|
||||
int omvnhack;
|
||||
|
||||
omvnhack = mvnhack;
|
||||
if (!machine[c]) mvnhack = 0;
|
||||
else sethack (b, c);
|
||||
cpybrd(a,b);
|
||||
filmvs(b,o,omb);
|
||||
forallpos (p) if (ismove (b,c,p))
|
||||
a[p] = s_move(b,c,o,p,omb);
|
||||
auxbrd(a);
|
||||
mvnhack = omvnhack;
|
||||
}
|
||||
|
||||
lstmvs(b,c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{board a;
|
||||
|
||||
filmvs(b,c,a);
|
||||
auxbrd(a);
|
||||
}
|
||||
|
||||
filmvs(b,c,a)
|
||||
board b,a;
|
||||
color c;
|
||||
|
||||
{register position p;
|
||||
cpybrd(a,b);
|
||||
forallpos (p) if (ismove (b,c,p))
|
||||
a[p] = '?';
|
||||
}
|
||||
|
||||
command(f,pp)
|
||||
FILE *f;
|
||||
position *pp;
|
||||
|
||||
{fastchar a, c;
|
||||
char *s;
|
||||
int x, y;
|
||||
|
||||
for (;;)
|
||||
{putcolor (player, stdout);
|
||||
printf (" to move: ");
|
||||
switch (c = lower (skipbl(f))) {
|
||||
|
||||
#ifdef unix
|
||||
|
||||
case SHELL: unix();
|
||||
continue;
|
||||
|
||||
#endif
|
||||
|
||||
case RESIGN:
|
||||
c = lower (getc (f));
|
||||
if (c == '\n') return (RESIGN);
|
||||
if (c != 'b') goto flush;
|
||||
a = READCM;
|
||||
goto rdname;
|
||||
|
||||
case OPTCOM: if (!wizard) goto flush;
|
||||
a = OPTCOM;
|
||||
goto rdname;
|
||||
|
||||
case WRITCM: c = lower (getc (f));
|
||||
if (c == '\n') goto flushnl;
|
||||
if (c != 'b') goto flush;
|
||||
a = WRITCM;
|
||||
|
||||
rdname: s = buf;
|
||||
c = getc (f);
|
||||
if (c != '\n')
|
||||
{if (c != ' ') goto flush;
|
||||
c = skipbl (f);
|
||||
while (c != '\n')
|
||||
{*s++ = c;
|
||||
c = getc (f);
|
||||
}
|
||||
}
|
||||
*s++ = 0;
|
||||
return (a);
|
||||
|
||||
case PBOARD:
|
||||
case SCORE:
|
||||
case QUIT:
|
||||
case ANALYZ:
|
||||
case LISTM:
|
||||
case MANUAL:
|
||||
case XCOM:
|
||||
case HELP:
|
||||
a = c;
|
||||
if ((c = skipbl(f)) != '\n') goto flush;
|
||||
return (a);
|
||||
case HCAP: if ((a = c = skipbl(f)) == '-') c = getc(f);
|
||||
if (c < '1' || c > '4' || skipbl(f) != '\n')
|
||||
goto flush;
|
||||
*pp = a=='-'? -(c-'0'):(c-'0');
|
||||
return (HCAP);
|
||||
case TREECM: a = c;
|
||||
c = skipbl(f);
|
||||
if (c < '1' || c > '9') goto flush;
|
||||
if (!wizard) goto flush;
|
||||
*pp = c-'0';
|
||||
while (c = skipbl(f))
|
||||
{if (c == '\n') return (a);
|
||||
if (c < '0' || c > '9') goto flush;
|
||||
*pp = (*pp * 10) + (c - '0');
|
||||
}
|
||||
goto flush;
|
||||
case EOF: return (c);
|
||||
default: if (c < '1' || c > '8') goto flush;
|
||||
x = c - '1';
|
||||
c = skipbl(f);
|
||||
if (c < '1' || c > '8') goto flush;
|
||||
y = c - '1';
|
||||
if ((c = skipbl(f)) == '\n')
|
||||
{*pp = pos(x,y);
|
||||
return (MOVE);
|
||||
}
|
||||
flush: while (c != '\n' && c != EOF) c = getc(f);
|
||||
if (c == EOF) return (c);
|
||||
case '\n':
|
||||
flushnl: printf ("Huh?\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
skipbl(f)
|
||||
register FILE *f;
|
||||
|
||||
{register fastchar c;
|
||||
while ((c = getc(f)) == ' ' || c == '\t');
|
||||
return (c);
|
||||
}
|
||||
|
||||
mprint (f, a, b, c, d, e)
|
||||
{fprintf (gamefile, f, a, b, c, d, e);
|
||||
if (!superself) printf (f, a, b, c, d, e);
|
||||
}
|
||||
|
||||
getuser ()
|
||||
|
||||
{char *s;
|
||||
getpw(getuid(),username);
|
||||
s = username;
|
||||
while (*s) if (*s == ':') {*s = 0; break;} else ++s;
|
||||
if (username[0]==0) exit(255);
|
||||
s = username;
|
||||
while (*s) {if (*s == ' ') *s = '_'; ++s;}
|
||||
setwizard ();
|
||||
}
|
||||
|
||||
#ifndef unix
|
||||
#include "c/its.bits"
|
||||
# include "c/c.defs"
|
||||
isdisplay ()
|
||||
{extern int cout;
|
||||
return (istty (cout) && (status (itschan (cout)) & 077) == 2);
|
||||
}
|
||||
|
||||
setsuper ()
|
||||
|
||||
{if (rsuset (UXJNAME) == csto6 ("OO")) ++superself;}
|
||||
|
||||
checkuser ()
|
||||
{while (!validuser ())
|
||||
{char nambuf[40];
|
||||
int n;
|
||||
printf ("Enter your user name (6 or fewer letters): ");
|
||||
gets (nambuf);
|
||||
n = csto6 (nambuf);
|
||||
if (n == csto6 ("AS")) n = 0;
|
||||
c6tos (n, username);
|
||||
wsuset (UXUNAME, n);
|
||||
}
|
||||
}
|
||||
|
||||
validuser ()
|
||||
{int n, loser, guest, foo;
|
||||
loser = csto6 ("BERN");
|
||||
guest = csto6 ("GUEST");
|
||||
foo = csto6 ("FOO");
|
||||
n = rsuset (UXUNAME);
|
||||
if (n == 0) return (FALSE);
|
||||
if ((n | 0777777) == -1) return (FALSE);
|
||||
if (n == guest || n == foo) return (FALSE);
|
||||
if (n == loser)
|
||||
return (ask (stdin, "Is your name really BERN") == YES);
|
||||
while (n)
|
||||
{int c;
|
||||
c = ((n >> 30) & 077);
|
||||
n = n << 6;
|
||||
if (c < ('A'-32) || c > ('Z'-32)) return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
setwizard ()
|
||||
{if (stcmp (username, "AS")) wizard=TRUE;
|
||||
}
|
||||
|
||||
prnews ()
|
||||
|
||||
{int f;
|
||||
f = copen ("c/_oo.news");
|
||||
if (f != OPENLOSS)
|
||||
{int c;
|
||||
while (c = getc (f)) putchar (c);
|
||||
putchar ('\n');
|
||||
cclose (f);
|
||||
pause ();
|
||||
if (display) clrscreen ();
|
||||
}
|
||||
}
|
||||
|
||||
pause ()
|
||||
|
||||
{tyos ("Type anything... ");
|
||||
utyi ();
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
ask(f,s)
|
||||
|
||||
{while (1)
|
||||
{tyos (s);
|
||||
tyos (" (Y or N)? ");
|
||||
while (1)
|
||||
{switch (lower (utyi ())) {
|
||||
case 'y': tyos ("yes\r"); return ('y');
|
||||
case EOF:
|
||||
case 'n': tyos ("no\r"); return ('n');
|
||||
case '\014': tyo ('\r'); break;
|
||||
default: tyo (007); continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inhibit ()
|
||||
|
||||
{if (++n_inhibit == 1)
|
||||
{int b[3], ch;
|
||||
ttyget (ch = tyiopn (), b);
|
||||
b[2] =| 02000000;
|
||||
ttyset (ch, b);
|
||||
}
|
||||
}
|
||||
|
||||
uninhibit ()
|
||||
|
||||
{if (n_inhibit == 0) return;
|
||||
if (--n_inhibit == 0)
|
||||
{int b[3], ch;
|
||||
ttyget (ch = tyiopn (), b);
|
||||
b[2] =& ~02000000;
|
||||
ttyset (ch, b);
|
||||
}
|
||||
}
|
||||
|
||||
setrand ()
|
||||
{int tv[2], x;
|
||||
time (tv);
|
||||
x = tv[1];
|
||||
x =^ cputm ();
|
||||
srand (x);
|
||||
x = 20;
|
||||
while (--x >= 0) rand();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef unix
|
||||
checkuser () {;}
|
||||
spctty (c) {;}
|
||||
stdio () {nice(12);}
|
||||
lower (c) {if (c>='A' && c<='Z') return (c+32); return (c);}
|
||||
isdisplay ()
|
||||
{struct {char ispeed,ospeed;int x,y;} ttt;
|
||||
gtty (1,&ttt);
|
||||
return (ttt.ospeed >= 11);
|
||||
}
|
||||
|
||||
setsuper () {;}
|
||||
setwizard ()
|
||||
{if (username[0] == 's' &&
|
||||
username[1] == 'n') wizard = TRUE;
|
||||
}
|
||||
|
||||
prnews () {;}
|
||||
|
||||
pause ()
|
||||
|
||||
{fastchar c;
|
||||
printf ("Type NL...");
|
||||
while ((c = getchar ()) != '\n' && c != EOF);
|
||||
}
|
||||
|
||||
ask(f,s)
|
||||
register FILE *f;
|
||||
register char *s;
|
||||
|
||||
{fastchar a, c;
|
||||
printf("%s? ", s);
|
||||
c = a = skipbl(f);
|
||||
while (c != '\n' && c != EOF) c = getc(f);
|
||||
return (lower (a));
|
||||
}
|
||||
|
||||
cputm()
|
||||
|
||||
{struct tbuffer { long user,system,childu,childs; } xxx;
|
||||
int i;
|
||||
|
||||
times(&xxx); i = xxx.user;
|
||||
return(i);
|
||||
}
|
||||
|
||||
inhibit () {;}
|
||||
uninhibit () {;}
|
||||
|
||||
#define SIGINT 2
|
||||
#define SIGQIT 3
|
||||
unix()
|
||||
|
||||
{int rc, status, unixpid;
|
||||
if ((unixpid=fork())==0)
|
||||
{execl("/bin/sh","sh","-t",0);
|
||||
exit(255);
|
||||
}
|
||||
else if (unixpid == -1) return(0);
|
||||
else {while ((rc = wait(&status)) != unixpid && rc != -1);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
setrand ()
|
||||
{int tv[2];
|
||||
time (tv);
|
||||
srand (tv[1]);
|
||||
}
|
||||
|
||||
tyo_flush ()
|
||||
{;}
|
||||
|
||||
#endif
|
||||
|
||||
BIN
src/as/o/o1.rel
Normal file
BIN
src/as/o/o1.rel
Normal file
Binary file not shown.
630
src/as/o/o2.c
Normal file
630
src/as/o/o2.c
Normal file
@@ -0,0 +1,630 @@
|
||||
#include "o.h"
|
||||
|
||||
extern int eflag;
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
EDGEVAL - Evaluate C's taking the edge square at P?
|
||||
|
||||
*
|
||||
* Scores:
|
||||
*
|
||||
* +4 = win 2 corners
|
||||
* +2 = win 1 corner
|
||||
* +1 = no corners taken, moved last
|
||||
* 0 = each won 1 corner
|
||||
*
|
||||
*
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int edepth, ddepth;
|
||||
color ecolor;
|
||||
|
||||
int edgeval (b,c,o,p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{direction d;
|
||||
board a;
|
||||
|
||||
ecolor = c;
|
||||
if (eflag)
|
||||
{printf ("\n *** edgeval (");
|
||||
putcolor (c, stdout);
|
||||
printf (", ");
|
||||
putpos (p, stdout);
|
||||
printf ("):\n");
|
||||
}
|
||||
if (horizedge(p)) d=WEST; else d=NORTH;
|
||||
cpybrd (a,b);
|
||||
putmov (a,c,p);
|
||||
return (-eeval (b,a,o,c,p,d,TRUE));
|
||||
}
|
||||
|
||||
int eeval (oldb,b,c,o,p,d,pass_ok) /* return score from C's point of view */
|
||||
board oldb, b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
int pass_ok;
|
||||
|
||||
/*
|
||||
* Pass_ok is set to false when we are evaluating
|
||||
* the result of O not moving on this edge on the
|
||||
* previous turn. In this case, C can always not
|
||||
* move and get 1 point for moving last.
|
||||
*
|
||||
*/
|
||||
|
||||
{int s; /* best score for C */
|
||||
int t; /* temporary score for C */
|
||||
|
||||
if (edepth > 4 && c==ecolor) return (1);
|
||||
++edepth;
|
||||
if (eflag)
|
||||
{putn (edepth);
|
||||
printf ("eeval (");
|
||||
putcolor (c, stdout);
|
||||
printf (", ");
|
||||
putdir (d, stdout);
|
||||
printf ("):\n");
|
||||
}
|
||||
if (pass_ok) s = -100; else s = 1;
|
||||
t = e1move (oldb, b, c, o, p, d);
|
||||
if (t>s) s = t;
|
||||
t = e1move (oldb, b, c, o, p, oppdir(d));
|
||||
if (t>s) s = t;
|
||||
if (pass_ok && edepth < 4)
|
||||
{t = -eeval (oldb, b, o, c, p, d, FALSE);
|
||||
if (t>s) s = t;
|
||||
}
|
||||
if (s == -100) s = -1;
|
||||
if (eflag)
|
||||
{putn (edepth);
|
||||
printf ("eeval (");
|
||||
putcolor (c, stdout);
|
||||
printf (", ");
|
||||
putdir (d, stdout);
|
||||
printf (") = %d\n", s);
|
||||
}
|
||||
--edepth;
|
||||
return (s);
|
||||
}
|
||||
|
||||
int e1move (oldb,b,c,o,p,d) /* return score from C's point of view */
|
||||
board oldb, b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{position findempty ();
|
||||
int rc;
|
||||
|
||||
rc = -100;
|
||||
++edepth;
|
||||
if (eflag)
|
||||
{putn (edepth);
|
||||
printf ("e1move (");
|
||||
putcolor (c, stdout);
|
||||
printf (", ");
|
||||
putdir (d, stdout);
|
||||
printf (") ");
|
||||
}
|
||||
p = findempty (b, p, d);
|
||||
if (valid (p) && ismove (b, c, p))
|
||||
{int s, t;
|
||||
board a;
|
||||
cpybrd (a, b);
|
||||
putmov (a, c, p);
|
||||
if (eflag)
|
||||
{printf ("move at ");
|
||||
putpos (p, stdout);
|
||||
printf ("\n");
|
||||
}
|
||||
t = 0;
|
||||
if (corner(p) && !ismove (oldb, c, p)) t = 2;
|
||||
s = -eeval (oldb,a,o,c,p,d,TRUE);
|
||||
if (t==0 || s<-1 || s>1)
|
||||
t =+ s;
|
||||
/* only count 1 pt. if no corners */
|
||||
rc = t;
|
||||
}
|
||||
else if (eflag) printf ("no move\n");
|
||||
--edepth;
|
||||
return (rc);
|
||||
}
|
||||
|
||||
position findempty (b, p, d)
|
||||
board b;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{while (valid (nextpos (p, d)) && b[p] != EMPTY);
|
||||
return (p);
|
||||
}
|
||||
|
||||
putn (n)
|
||||
{printf ("%2d", n);
|
||||
while (--n>=0) {putchar (' '); putchar (' ');}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
DEFEDGE - Does the move at edge P have defensive value?
|
||||
|
||||
(Move has not yet been made.)
|
||||
|
||||
An edge move has defensive value if it prevents the opponent
|
||||
from capturing along an edge.
|
||||
|
||||
look for: ~o X o+ c+ _
|
||||
where the _ is not a bad move (W,X,Y,Z) for O
|
||||
look for: o c* X c* o
|
||||
where there is a hole
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int defedge (b,c,o,p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{direction d;
|
||||
position p1;
|
||||
int rc;
|
||||
p1 = p;
|
||||
if (ddepth>0) return (FALSE); /* avoid useless recursion */
|
||||
++ddepth;
|
||||
if (horizedge(p)) d=WEST; else d=NORTH;
|
||||
rc = def1edge (b,c,o,p,d) ||
|
||||
def1edge (b,c,o,p,oppdir(d)) ||
|
||||
def2edge (b,c,o,p,d);
|
||||
--ddepth;
|
||||
return (rc);
|
||||
}
|
||||
|
||||
int def1edge (b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{position p1;
|
||||
direction d1;
|
||||
d1 = oppdir (d);
|
||||
p1 = p;
|
||||
if (valid (nextpos (p1, d1)) && b[p1]==o) return (FALSE);
|
||||
if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != o) return (FALSE);
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != c) return (FALSE);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
return (s_move (b,o,c,p,b) < 'W');
|
||||
}
|
||||
|
||||
int def2edge (b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{if (!def3edge (b,c,o,p,d)) return (FALSE);
|
||||
if (!def3edge (b,c,o,p,oppdir(d))) return (FALSE);
|
||||
while (b[p] != o) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
return (hole (b,o,c,p));
|
||||
}
|
||||
|
||||
int def3edge (b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{if (!valid (nextpos (p, d))) return (FALSE);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
return (b[p] == o);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
SAFEDGE - Is the move at edge P safe?
|
||||
|
||||
(Move must have been made.)
|
||||
|
||||
An edge move is considered safe if neither of the nearest
|
||||
empty edge squares can be taken by the opponent and
|
||||
(if not a corner) have defensive value for the opponent.
|
||||
|
||||
Return TRUE if the move is safe.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int safedge (b,c,o,p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{direction d;
|
||||
if (horizedge(p)) d=WEST; else d=NORTH;
|
||||
return (saf1edge (b,c,o,p,d) && saf1edge (b,c,o,p,oppdir(d)));
|
||||
}
|
||||
|
||||
int saf1edge (b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{p = findempty (b, p, d);
|
||||
if (valid (p) && ismove (b, o, p))
|
||||
return (!(corner(p) || defedge (b, o, c, p)));
|
||||
else return (TRUE);
|
||||
}
|
||||
|
||||
#define FHOLE 1
|
||||
#define FCORNER 2
|
||||
|
||||
/*
|
||||
* hole - does the position resulting from a move at P by C contain a
|
||||
* hole for O? If so, what value square is given up?
|
||||
*
|
||||
* (The move has already been made.)
|
||||
*
|
||||
*/
|
||||
|
||||
hole(b,c,o,p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{register int h;
|
||||
if (horizedge (p))
|
||||
h = hole1 (b,c,o,p,EAST) | hole1 (b,c,o,p,WEST);
|
||||
else
|
||||
h = hole1 (b,c,o,p,NORTH) | hole1 (b,c,o,p,SOUTH);
|
||||
if (h > FHOLE) return (CORNERVALUE);
|
||||
if (h == FHOLE) return (EDGEVALUE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* case 1: _ c* X c* _ c+ _
|
||||
*
|
||||
* case 2: _ c* X c* o+ _ c+ _
|
||||
* o c* X c* o+ _ c+ _
|
||||
*
|
||||
* case 3: _ c* X c* _ o+ c+ _
|
||||
* _ c* X c* _ o+ c+ o
|
||||
*
|
||||
* case 4: ... c+ o+ c+
|
||||
* can be ignored since it will
|
||||
* be picked up by edgeval
|
||||
*
|
||||
* In all cases, inner _ may be any odd number of _s.
|
||||
* In all cases, outer _ may be [ or ].
|
||||
* In all cases, outer _ are the squares given up,
|
||||
* plus the inner edge square.
|
||||
*
|
||||
*/
|
||||
|
||||
hole1(b,c,o,p,d)
|
||||
board b;
|
||||
color c, o;
|
||||
register position p;
|
||||
direction d;
|
||||
|
||||
{int n_o_left, n_o_right, n_spaces;
|
||||
position p1;
|
||||
direction d1;
|
||||
|
||||
p1 = p;
|
||||
d1 = oppdir (d);
|
||||
nextpos (p1, d1);
|
||||
while (valid (p1) && b[p1] == c) nextpos (p1, d1);
|
||||
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (0);
|
||||
n_o_left = 0;
|
||||
while (b[p] == o)
|
||||
{if (!valid (nextpos (p, d))) return (0);
|
||||
++n_o_left;
|
||||
}
|
||||
if (b[p] != EMPTY) return (0);
|
||||
n_spaces = 0;
|
||||
while (b[p] == EMPTY)
|
||||
{if (!valid (nextpos (p, d))) return (0);
|
||||
++n_spaces;
|
||||
}
|
||||
if ((n_spaces & 1) == 0) return (0);
|
||||
n_o_right = 0;
|
||||
while (b[p] == o)
|
||||
{if (!valid (nextpos (p, d))) return (0);
|
||||
++n_o_right;
|
||||
}
|
||||
if (b[p] != c) return (0);
|
||||
while (b[p] == c)
|
||||
if (!valid (nextpos (p, d))) break;
|
||||
if (valid (p1) && b[p1] == o && n_o_left == 0) return (0);
|
||||
if (valid (p) && b[p] == o && n_o_right == 0) return (0);
|
||||
if (valid (p) && corner (p)) return (FCORNER);
|
||||
if (valid (p1) && corner (p1)) return (FCORNER);
|
||||
return (FHOLE);
|
||||
}
|
||||
|
||||
/*
|
||||
* trap1 - look to see if moving on the edge adjacent to a corner
|
||||
* is safe
|
||||
*
|
||||
* bad if: it turns over an opponent's piece on the adjacent diagonal
|
||||
* bad if: [_ X c* _ o* _ _
|
||||
* (unless the last _ is a corner or adjacent to a corner)
|
||||
* bad if: [_ X c* _ o* _ c* o
|
||||
*
|
||||
*/
|
||||
|
||||
trap1 (b, c, o, p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{direction d, d1;
|
||||
position p1;
|
||||
extern fastchar quadrant[];
|
||||
|
||||
switch (quadrant[p]) {
|
||||
case 1: d = EAST; d1 = SOUTH; break;
|
||||
case 2: d = WEST; d1 = SOUTH; break;
|
||||
case 3: d = EAST; d1 = NORTH; break;
|
||||
case 4: d = WEST; d1 = NORTH; break;
|
||||
}
|
||||
if (!horizedge (p))
|
||||
{direction temp;
|
||||
temp = d;
|
||||
d = d1;
|
||||
d1 = temp;
|
||||
}
|
||||
p1 = p;
|
||||
nextpos (p1, d1);
|
||||
if (b[p1] == o)
|
||||
{while (b[p1] == o) if (!valid (nextpos (p1, d1))) break;
|
||||
if (valid (p1) && b[p1] == c) return (TRUE);
|
||||
}
|
||||
nextpos (p, d);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
if (!valid (nextpos (p, d))) return (FALSE);
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (TRUE);
|
||||
if (b[p] != EMPTY) return (TRUE);
|
||||
if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] == EMPTY) return (sqval[p] == EDGEVALUE);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
return (b[p] == o);
|
||||
}
|
||||
|
||||
/*
|
||||
* trap2 - look to see if move on edge, which can be taken back,
|
||||
* is actually safe. Return CORNERVALUE if it results in taking
|
||||
* a corner, EDGEVALUE if it is otherwise safe, 0 if it is unsafe.
|
||||
*
|
||||
* CORNERVALUE if: [_ o+ X c* _ c+ ~o
|
||||
* CORNERVALUE if: [_ o+ X c* _ o+ c+
|
||||
* EDGEVALUE if: _ o+ X c* _ c+ ~o
|
||||
* EDGEVALUE if: _ o+ X c* _ o+ c+
|
||||
* EDGEVALUE if: c+ o+ c+ X _ _
|
||||
* EDGEVALUE if: _ o+ _ o+ X _ _
|
||||
*
|
||||
*/
|
||||
|
||||
trap2 (b, c, o, p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{direction d;
|
||||
int v;
|
||||
if (horizedge (p)) d = EAST;
|
||||
else d = NORTH;
|
||||
if ((v = trp2a (b, c, o, p, d)) > 0) return (v);
|
||||
if ((v = trp2a (b, c, o, p, oppdir(d))) > 0) return (v);
|
||||
if (trp2b (b, c, o, p, d) || trp2b (b, c, o, p, oppdir(d)))
|
||||
return (EDGEVALUE);
|
||||
return (0);
|
||||
}
|
||||
|
||||
trp2a (b, c, o, p, d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{direction od;
|
||||
position ip;
|
||||
int v, n;
|
||||
|
||||
ip = p;
|
||||
od = oppdir(d);
|
||||
if (!valid (nextpos (p, od))) return (0);
|
||||
if (b[p] != o) return (0);
|
||||
while (b[p] == o) if (!valid (nextpos (p, od))) return (0);
|
||||
if (b[p] != EMPTY) return (0);
|
||||
if (corner (p)) v = CORNERVALUE; else v = EDGEVALUE;
|
||||
p = ip;
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (0);
|
||||
if (b[p] != EMPTY) return (0);
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
n = 0;
|
||||
while (b[p] == o)
|
||||
if (!valid (nextpos (p, d))) return (0);
|
||||
else ++n;
|
||||
if (b[p] != c) return (0);
|
||||
if (n > 0) return (v);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (v);
|
||||
if (b[p] == EMPTY) return (v);
|
||||
return (0);
|
||||
}
|
||||
|
||||
trp2b (b, c, o, p, d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{direction od;
|
||||
position ip;
|
||||
|
||||
ip = p;
|
||||
od = oppdir (d);
|
||||
if (!valid (nextpos (p, od))) return (FALSE);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
if (!valid (nextpos (p, od))) return (FALSE);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
p = ip;
|
||||
if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != c)
|
||||
{if (b[p] != o) return (FALSE);
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != o) return (FALSE);
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (TRUE);
|
||||
return (b[p] == EMPTY);
|
||||
}
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
if (b[p] != o) return (FALSE);
|
||||
while (b[p] == o) if (!valid (nextpos (p, d))) return (FALSE);
|
||||
return (b[p] == c);
|
||||
}
|
||||
|
||||
/*
|
||||
* trap3 - look to see if move on edge, which cannot be taken back,
|
||||
* actually wins the corner
|
||||
*
|
||||
* look for: [_ o+ X c* o
|
||||
*
|
||||
*/
|
||||
|
||||
trap3 (b, c, o, p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{direction d;
|
||||
if (horizedge (p)) d = EAST;
|
||||
else d = NORTH;
|
||||
return (trp3a (b, c, o, p, d) || trp3a (b, c, o, p, oppdir(d)));
|
||||
}
|
||||
|
||||
trp3a (b, c, o, p, d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
{direction od;
|
||||
position ip;
|
||||
|
||||
ip = p;
|
||||
od = oppdir(d);
|
||||
if (!valid (nextpos (p, od))) return (FALSE);
|
||||
if (b[p] != o) return (FALSE);
|
||||
while (b[p] == o) if (!valid (nextpos (p, od))) return (FALSE);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
if (!corner (p)) return (FALSE);
|
||||
p = ip;
|
||||
if (!valid (nextpos (p, d))) return (FALSE);
|
||||
while (b[p] == c) if (!valid (nextpos (p, d))) return (TRUE);
|
||||
return (b[p] == o);
|
||||
}
|
||||
|
||||
/*
|
||||
* trap4 - look to see if move on edge, which creates a hole,
|
||||
* actually wins the corner
|
||||
*
|
||||
* look for: [_ o _ c _ X _ _
|
||||
* [_ o _ X _ c _ _
|
||||
*
|
||||
*/
|
||||
|
||||
trap4 (b, c, o, p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{int x, y;
|
||||
x = posx (p);
|
||||
y = posy (p);
|
||||
if (x == 2) return (trp4a (b, c, o, p, SOUTH));
|
||||
if (x == 5) return (trp4a (b, c, o, p, NORTH));
|
||||
if (y == 2) return (trp4a (b, c, o, p, EAST));
|
||||
if (y == 5) return (trp4a (b, c, o, p, WEST));
|
||||
if (x == 3) return (trp4b (b, c, o, p, NORTH));
|
||||
if (x == 4) return (trp4b (b, c, o, p, SOUTH));
|
||||
if (y == 3) return (trp4b (b, c, o, p, WEST));
|
||||
if (y == 4) return (trp4b (b, c, o, p, EAST));
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
trp4a (b, c, o, p, d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
/* look for: [_ o _ c _ X _ _ */
|
||||
|
||||
{position p1;
|
||||
|
||||
p1 = p;
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != c) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != o) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
p = p1;
|
||||
d = oppdir (d);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
trp4b (b, c, o, p, d)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
direction d;
|
||||
|
||||
/* look for: [_ o _ X _ c _ _ */
|
||||
|
||||
{position p1;
|
||||
|
||||
p1 = p;
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != o) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
p = p1;
|
||||
d = oppdir (d);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != c) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
nextpos (p, d);
|
||||
if (b[p] != EMPTY) return (FALSE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
BIN
src/as/o/o2.rel
Normal file
BIN
src/as/o/o2.rel
Normal file
Binary file not shown.
637
src/as/o/o3.c
Normal file
637
src/as/o/o3.c
Normal file
@@ -0,0 +1,637 @@
|
||||
# include "o.h"
|
||||
|
||||
extern int mvnhack;
|
||||
extern fastchar quadrant[100];
|
||||
int danger;
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
RELSCORE maps two values representing what I get and
|
||||
what my opponent gets into a letter score. The input
|
||||
values are:
|
||||
|
||||
0 - unsafe edge (can be taken back)
|
||||
1 - move that may give away corner
|
||||
2 - no move
|
||||
3 - adjacent to edge
|
||||
4 - interior
|
||||
5 - hole-making edge
|
||||
6 - safe edge
|
||||
7 - corner
|
||||
|
||||
note: A = move that wipes out opponent
|
||||
B = move that saves corner
|
||||
H = defensive taking of edge
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
# define GOODSCORE 'H' /* scores worse than this => movnum hack */
|
||||
# define BADSCORE 'U' /* scores better than this => movnum hack */
|
||||
|
||||
fastchar relscore[8][8] {
|
||||
'X', 'X', 'X', 'X', 'X', '?', 'X', 'Z',
|
||||
'Y', 'Y', 'Y', 'Y', 'Y', '?', 'Y', 'Z',
|
||||
'?', '?', '?', '?', '?', '?', '?', '?',
|
||||
'E', 'E', 'E', 'Q', 'R', '?', 'T', 'Z',
|
||||
'E', 'E', 'E', 'P', 'P', '?', 'S', 'Z',
|
||||
'?', '?', '?', '?', '?', '?', 'V', 'Z',
|
||||
'D', 'D', 'D', 'J', 'K', '?', 'N', 'Z',
|
||||
'C', 'C', 'C', 'C', 'C', '?', 'F', 'U',
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
MY_MOV - Select a move from the set of best moves.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
position my_mov (b,c,o)
|
||||
board b;
|
||||
color c, o;
|
||||
|
||||
{struct mt t[64], *tp[64];
|
||||
register int k;
|
||||
|
||||
k = bk_lookup (t, tp);
|
||||
if (k > 0)
|
||||
{position p;
|
||||
p = tp[0]->p;
|
||||
if (k > 1) p = tp[(rand() & 017777) % k]->p;
|
||||
if (ismove (b,c,p)) return (p);
|
||||
cprint ("Book returns illegal move.\n");
|
||||
}
|
||||
k = getcandidates (b,c,o,tp,t);
|
||||
if (k==0) return (0);
|
||||
if (k==1) return (tp[0]->p);
|
||||
k = (rand() & 017777) % k;
|
||||
return (tp[k]->p);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
GETCANDIDATES - Get all best moves.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int getcandidates (b,c,o,tp,t)
|
||||
board b;
|
||||
color c, o;
|
||||
struct mt *tp[], t[];
|
||||
|
||||
{extern int movnum;
|
||||
int k, omvnhack;
|
||||
|
||||
omvnhack = mvnhack;
|
||||
sethack (b, c);
|
||||
k = igetcandidates (b,c,o,tp,t,movnum>=MIDDLEMOVE);
|
||||
if (movnum<MIDDLEMOVE && danger && k>0 && tp[0]->c <= -80)
|
||||
{mvnhack = 0;
|
||||
k = igetcandidates (b,c,o,tp,t,'V');
|
||||
if (tp[0]->c <= -80)
|
||||
{k = igetcandidates (b,c,o,tp,t,'X');
|
||||
if (tp[0]->c <= -85)
|
||||
k = igetcandidates (b,c,o,tp,t,1);
|
||||
}
|
||||
}
|
||||
mvnhack = omvnhack;
|
||||
return (k);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
SETHACK - Determine if we are in danger of being
|
||||
wiped out.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int sethack (b, c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{int ccount, ocount;
|
||||
extern int handicap;
|
||||
ccount = cntbrd (b, c);
|
||||
ocount = cntbrd (b, oppcolor(c));
|
||||
if (handicap < 0) ccount =+ handicap;
|
||||
danger = ccount<6;
|
||||
if (movnum >= MIDDLEMOVE) mvnhack=0;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
IGETBEST - Get best (letterwise) moves
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int igetbest (b,c,o,tp,t,tryall)
|
||||
board b;
|
||||
color c, o;
|
||||
struct mt *tp[], t[];
|
||||
int tryall;
|
||||
|
||||
{extern int mmdepth;
|
||||
int k, best;
|
||||
|
||||
mmdepth = 2;
|
||||
k = pmvgen (b,c,o,tp,t,tryall==1,tryall!=1);
|
||||
if (k==0) return (0);
|
||||
best = tp[0]->s;
|
||||
if (tryall > 1 && best < tryall) k = exprange (tp, t, tryall);
|
||||
else if (tryall == 0)
|
||||
{if (best == 'P' && !mvnhack)
|
||||
{int oldk;
|
||||
oldk = k;
|
||||
k = exprange (tp, t, 'S');
|
||||
if (k > oldk) ++mmdepth;
|
||||
}
|
||||
}
|
||||
return (k);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
IGETCANDIDATES - Get possible moves.
|
||||
|
||||
tryall == 0: use normal selection
|
||||
tryall == 1: try all moves
|
||||
other value: try all moves <= value
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int igetcandidates (b,c,o,tp,t,tryall)
|
||||
board b;
|
||||
color c, o;
|
||||
struct mt *tp[], t[];
|
||||
int tryall;
|
||||
|
||||
{register int k;
|
||||
|
||||
k = igetbest (b,c,o,tp,t,tryall);
|
||||
if (k==0) return (0);
|
||||
if (k==1 && !danger)
|
||||
{tp[0]->c = -1000;
|
||||
return (1);
|
||||
}
|
||||
return (dosearch (b,c,o,tp,t,k,tryall));
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
DOSEARCH
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int dosearch (b,c,o,tp,t,k,tryall)
|
||||
board b;
|
||||
color c, o;
|
||||
struct mt *tp[], t[];
|
||||
int tryall;
|
||||
|
||||
{extern int debug, mmdepth, movnum;
|
||||
register struct mt **bp, **mp, **ep;
|
||||
int best;
|
||||
|
||||
ep = tp + k;
|
||||
bp = tp;
|
||||
mp = tp;
|
||||
|
||||
best = tp[0]->s;
|
||||
if (mvnhack && !danger && best < 'V' && best != 'B')
|
||||
{while (mp < ep)
|
||||
{struct mt *p;
|
||||
p = *mp++;
|
||||
p->c = -1000;
|
||||
}
|
||||
return (k);
|
||||
}
|
||||
|
||||
if (best >= 'X')
|
||||
{mmdepth = 4;
|
||||
mvnhack = 0;
|
||||
}
|
||||
else if (best >= 'V') mmdepth = 3;
|
||||
if (movnum>=ENDGAMEMOVE) mmdepth = 6;
|
||||
else if (movnum>=MIDDLEMOVE)
|
||||
{if (k<=3) mmdepth = 6;
|
||||
else mmdepth = 4;
|
||||
}
|
||||
else if (movnum>=16)
|
||||
{if (k<=3) mmdepth = 4;}
|
||||
else if (movnum>=4)
|
||||
{if (k==2) mmdepth = 4;}
|
||||
|
||||
if (danger && mmdepth<4) mmdepth=4;
|
||||
|
||||
if (debug>0) printf ("\nsearch depth %d\n", mmdepth);
|
||||
tp[0]->c = -1000;
|
||||
while (mp < ep)
|
||||
{struct mt *p;
|
||||
p = *mp++;
|
||||
p->c = meval (b,c,o,p->p,tp[0]->c);
|
||||
if (debug>0) printf (" %d-%d %c %d\n", posx(p->p)+1,
|
||||
posy(p->p)+1, p->s, p->c);
|
||||
if (p->c > tp[0]->c) {bp = tp; *bp++ = p;}
|
||||
else if (p->c == tp[0]->c) *bp++ = p;
|
||||
}
|
||||
return (bp-tp);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
EXPRANGE - Return all moves in an already-computed set that
|
||||
are not worse than a given LETTER score
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int exprange (tp,t,letter)
|
||||
struct mt *tp[], t[];
|
||||
|
||||
{register struct mt **bp, *mp;
|
||||
mp = t;
|
||||
bp = tp;
|
||||
while (mp->p >= 0)
|
||||
{if (mp->s <= letter) *bp++ = mp;
|
||||
++mp;
|
||||
}
|
||||
return (bp-tp);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
PMVGEN - Probable Move Generator
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int pmvgen (b,c,o,tp,t,allmoves,wantscores)
|
||||
board b;
|
||||
color c,o;
|
||||
struct mt *tp[],t[];
|
||||
|
||||
{struct mt *ep;
|
||||
register struct mt **bp, *mp;
|
||||
int k;
|
||||
|
||||
k = fillmt(b,c,o,t,wantscores);
|
||||
if (k==0) return (0);
|
||||
if (k==1) {tp[0] = t; return (1);}
|
||||
ep = t+k;
|
||||
mp = t;
|
||||
bp = tp;
|
||||
*bp++ = mp;
|
||||
while (++mp < ep)
|
||||
if (allmoves) *bp++ = mp;
|
||||
else
|
||||
{if (mp->s < tp[0]->s) {bp = tp; *bp++ = mp;}
|
||||
else if (mp->s == tp[0]->s) *bp++ = mp;
|
||||
}
|
||||
return (bp-tp);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
FILLMT - Legal Move Generator
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
fillmt(b,c,o,t,wantscores)
|
||||
board b;
|
||||
color c, o;
|
||||
struct mt t[64];
|
||||
|
||||
{register position p;
|
||||
register struct mt *tp;
|
||||
board omb;
|
||||
|
||||
filmvs(b,o,omb);
|
||||
tp = t;
|
||||
forallpos (p) if (ismove (b,c,p))
|
||||
{tp->p = p;
|
||||
tp->s = (wantscores ? s_move(b,c,o,p,omb) : 'O');
|
||||
++tp;
|
||||
}
|
||||
tp->p = -1;
|
||||
return (tp-t);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
S_MOVE - Simple Move Evaluator
|
||||
|
||||
OMB is a board where all of O's moves are marked with
|
||||
a printing character.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
s_move(b,c,o,p,omb)
|
||||
board b, omb;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{board a; /* board after move */
|
||||
register int myscore, hisscore;
|
||||
int nmoves, nsaves;
|
||||
extern int machine[], ddepth;
|
||||
|
||||
cpybrd (a, b);
|
||||
putmov (a, c, p);
|
||||
if (bscore (a, o) == 0 && cntbrd (a, o) == 0) return ('A');
|
||||
if (debug>0 && ddepth==0)
|
||||
{printf ("\n");
|
||||
putpos (p, stdout);
|
||||
}
|
||||
hisscore = aeval (a, p, o, c, omb, &nmoves, &nsaves);
|
||||
myscore = sqeval (b,c,o,p);
|
||||
if (ddepth == 0)
|
||||
{if (debug>0)
|
||||
{printf (" ");
|
||||
putcolor (c, stdout);
|
||||
printf ("=%d ", myscore);
|
||||
putcolor (o, stdout);
|
||||
printf ("=%d (", hisscore);
|
||||
putletter (relscore[myscore][hisscore]);
|
||||
printf (")");
|
||||
}
|
||||
if (edge (p) && !corner (p))
|
||||
{int escore;
|
||||
escore = edgeval (b, c, o, p);
|
||||
if (escore > 1) myscore = CORNERVALUE;
|
||||
else if (escore < -1) hisscore = CORNERVALUE;
|
||||
else if (escore == 0) myscore = hisscore = CORNERVALUE;
|
||||
else if (myscore < CORNERVALUE)
|
||||
{register int temp;
|
||||
if (escore < 0 && myscore == EDGEVALUE) myscore = 0;
|
||||
temp = hole (a,c,o,p);
|
||||
if (temp>0 && trap4 (b, c, o, p))
|
||||
myscore = CORNERVALUE;
|
||||
else
|
||||
{if (temp>hisscore) hisscore=temp;
|
||||
if (temp>0 &&
|
||||
(myscore>=HEDGEVALUE || myscore==0))
|
||||
myscore = HEDGEVALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myscore = relscore[myscore][hisscore];
|
||||
if (ddepth == 0)
|
||||
{if (!corner (p) && edge (p) &&
|
||||
myscore>GOODSCORE && (myscore<BADSCORE || myscore=='X')
|
||||
&& defedge (b,c,o,p))
|
||||
myscore = 'H';
|
||||
else if (mvnhack && myscore>GOODSCORE &&
|
||||
(myscore<BADSCORE || myscore=='X'))
|
||||
myscore = mvneval (myscore, a, c, o, nmoves);
|
||||
}
|
||||
if (nsaves>0 && myscore<'Z') myscore='B';
|
||||
return (myscore);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
MVNEVAL
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int mvneval (myscore, a, c, o, nmoves)
|
||||
board a;
|
||||
color c, o;
|
||||
|
||||
{int nmymoves, bias;
|
||||
if (myscore=='X') bias = 3; else bias = 0;
|
||||
nmymoves = cntokmoves (a, c);
|
||||
myscore=(GOODSCORE+10)+nmoves-nmymoves+bias;
|
||||
if (nmymoves<6) myscore =+ (6-nmymoves)*2;
|
||||
if (debug>0)
|
||||
{printf ("; ");
|
||||
putcolor (c, stdout);
|
||||
printf ("=%d ", nmymoves);
|
||||
putcolor (o, stdout);
|
||||
printf ("=%d sum=%d score=%d", nmoves,
|
||||
nmoves-nmymoves, myscore - (GOODSCORE+1));
|
||||
}
|
||||
if (myscore>(GOODSCORE+3))
|
||||
myscore = (GOODSCORE+3) + (myscore-(GOODSCORE+3))/4;
|
||||
if (myscore>=BADSCORE) myscore = BADSCORE-1;
|
||||
else if (myscore<=GOODSCORE) myscore = GOODSCORE+1;
|
||||
return (myscore);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
AEVAL - Evaluate replies
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
aeval (b, oldp, c, o, omb, pnmoves, pnsaves)
|
||||
board b, omb;
|
||||
position oldp;
|
||||
color c, o;
|
||||
int *pnmoves, *pnsaves;
|
||||
|
||||
{register int s;
|
||||
register position p;
|
||||
position bestp;
|
||||
int nmoves, nsaves;
|
||||
|
||||
s = -1;
|
||||
nmoves = nsaves = 0;
|
||||
if (debug>0 && ddepth == 0) printf (" [");
|
||||
forallpos (p)
|
||||
{if (ismove (b,c,p))
|
||||
{register int temp;
|
||||
++nmoves;
|
||||
if (danger && ddepth==0)
|
||||
{board a;
|
||||
cpybrd (a, b);
|
||||
putmov (a, c, p);
|
||||
if (bscore (a, o) == 0 && cntbrd (a, o) == 0)
|
||||
return (CORNERVALUE);
|
||||
}
|
||||
temp = sqeval (b,c,o,p);
|
||||
if (temp > 2 && temp != 5) /* count only good moves */
|
||||
{++nmoves;
|
||||
if (edge (p)) nmoves=+2; /* count edges higher */
|
||||
}
|
||||
if (omb[p] >= ' ') /* can already move there */
|
||||
{if (temp>INTERIORVALUE && corner (p)
|
||||
&& !adjedge(oldp))
|
||||
temp = INTERIORVALUE;
|
||||
}
|
||||
if (debug>1 && ddepth == 0)
|
||||
{putpos (p, stdout);
|
||||
printf (":%d ", temp);
|
||||
}
|
||||
if (temp>s) {s=temp; bestp = p;}
|
||||
}
|
||||
else
|
||||
{if ((omb[p] >= ' ') && corner(p)) ++nsaves;}
|
||||
}
|
||||
*pnmoves = nmoves;
|
||||
*pnsaves = nsaves;
|
||||
if (debug>0 && ddepth == 0)
|
||||
{if (s<0) printf ("no reply");
|
||||
else
|
||||
{printf ("best reply is ");
|
||||
putpos (bestp, stdout);
|
||||
}
|
||||
printf ("]");
|
||||
}
|
||||
if (s<0) return (2);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
CNTOKMOVES - Count non-possibly-corner-losing-moves by C
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
cntokmoves (b, c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{register position p;
|
||||
register int nmoves;
|
||||
|
||||
nmoves = 0;
|
||||
forallpos (p)
|
||||
if (ismove (b,c,p) && !adjcorner(p)) ++nmoves;
|
||||
return (nmoves);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
SQEVAL - Simple Square Evaluator
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
sqeval (b, c, o, p)
|
||||
board b;
|
||||
color c, o;
|
||||
position p;
|
||||
|
||||
{register int val;
|
||||
extern fastchar selfplay;
|
||||
extern int movnum, machine[];
|
||||
|
||||
val = sqval[p];
|
||||
if (adjcorner (p)) /* adjacent to corner on edge or diagonal */
|
||||
{register position cp;
|
||||
cp = nrcorner (p); /* the corner */
|
||||
if (adjdiag (p)) val = INTERIORVALUE;
|
||||
else val = EDGEVALUE;
|
||||
if (b[cp] == EMPTY)
|
||||
{if (adjdiag(p)) val = 1;
|
||||
else if (machine[c] && trap1 (b, c, o, p)) val = 1;
|
||||
/* this move bad only for the machine
|
||||
since the machine is not particularly
|
||||
good at taking advantage of it */
|
||||
}
|
||||
}
|
||||
if (val == EDGEVALUE)
|
||||
{board a;
|
||||
cpybrd (a,b);
|
||||
putmov (a,c,p); /* try move */
|
||||
if (safedge (a,c,o,p))
|
||||
{if (trap3 (b,c,o,p)) val = CORNERVALUE;
|
||||
}
|
||||
else
|
||||
{int v;
|
||||
if ((v = trap2 (a,c,o,p)) > 0) val = v;
|
||||
else val = 0;
|
||||
}
|
||||
}
|
||||
return (val);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
NRCORNER - Return position of nearest corner
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
position nrcorner(p)
|
||||
position p;
|
||||
|
||||
{switch (quadrant [p]) {
|
||||
case 1: return (pos(0,0));
|
||||
case 2: return (pos(0,7));
|
||||
case 3: return (pos(7,0));
|
||||
case 4: return (pos(7,7));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
DOTREE - Print tree of possible future machine play.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
static int treedepth 0;
|
||||
|
||||
dotree (b, c, o, depth, fd)
|
||||
board b;
|
||||
color c, o;
|
||||
|
||||
{
|
||||
#ifdef unix
|
||||
struct mt t[32], *tp[32];
|
||||
board a;
|
||||
#endif
|
||||
#ifndef unix
|
||||
struct mt *t, **tp;
|
||||
board *a;
|
||||
#endif
|
||||
register int k, n;
|
||||
|
||||
#ifndef unix
|
||||
{int *ip;
|
||||
ip = salloc (100+64+64);
|
||||
t = ip;
|
||||
tp = ip + 64;
|
||||
a = ip + (64 + 64);
|
||||
}
|
||||
# endif
|
||||
|
||||
++treedepth;
|
||||
k = getcandidates (b,c,o,tp,t);
|
||||
if (k>10) k=10;
|
||||
if (k == 0)
|
||||
{treindent (fd);
|
||||
if (anymvs (b,o))
|
||||
{fprintf (fd, "Forfeit\n");
|
||||
dotree (b,o,c,depth,fd);
|
||||
}
|
||||
else fprintf (fd, "(%d-%d)\n", cntbrd(b,c),cntbrd(b,o));
|
||||
}
|
||||
else for (n=0;n<k;++n)
|
||||
{position p;
|
||||
treindent (fd);
|
||||
p = tp[n]->p;
|
||||
fprintf (fd, "%d-%d %c", posx(p)+1, posy(p)+1, tp[n]->s);
|
||||
if (tp[n]->c != -1000) fprintf (fd, " %d", tp[n]->c);
|
||||
putc ('\n', fd);
|
||||
if (treedepth < depth)
|
||||
{cpybrd (a,b);
|
||||
putmov (a,c,p);
|
||||
dotree (a,o,c,depth,fd);
|
||||
}
|
||||
}
|
||||
--treedepth;
|
||||
|
||||
# ifndef unix
|
||||
sfree (t);
|
||||
# endif
|
||||
}
|
||||
|
||||
treindent (fd)
|
||||
|
||||
{register int n;
|
||||
n = treedepth;
|
||||
fprintf (fd, "%2d", treedepth);
|
||||
putc ('\t', fd);
|
||||
while (n >= 8) {putc ('\t', fd); n =- 8;}
|
||||
while (--n >= 0) putc (' ', fd);
|
||||
}
|
||||
|
||||
BIN
src/as/o/o3.rel
Normal file
BIN
src/as/o/o3.rel
Normal file
Binary file not shown.
104
src/as/o/o4.c
Normal file
104
src/as/o/o4.c
Normal file
@@ -0,0 +1,104 @@
|
||||
# include "o.h"
|
||||
|
||||
/*
|
||||
* o5 - static evaluator and minimax
|
||||
*
|
||||
*/
|
||||
|
||||
extern int debug, movnum, mvnhack;
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
SEVAL - Static Evaluator
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int mmquantile 100;
|
||||
|
||||
int seval (b, c, o)
|
||||
board b;
|
||||
color c, o;
|
||||
|
||||
{register int ccount, ocount;
|
||||
|
||||
ccount = bscore (b, c);
|
||||
ocount = bscore (b, o);
|
||||
return (((ccount - ocount) * mmquantile) / (ccount + ocount));
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
MEVAL - minimax move evaluator
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int mdepth 0;
|
||||
int mmdepth;
|
||||
|
||||
int meval (b,c,o,p,alpha)
|
||||
|
||||
{board a;
|
||||
int minmove;
|
||||
|
||||
cpybrd (a,b);
|
||||
putmov (a,c,p);
|
||||
if (++mdepth == mmdepth) minmove = seval (a,c,o);
|
||||
else
|
||||
{minmove = 1000;
|
||||
{register position *qq, q;
|
||||
extern position trymov[];
|
||||
qq = trymov;
|
||||
while ((q = *qq++) >= 0) if (ismove (a,o,q))
|
||||
{register int temp;
|
||||
temp = -meval(a,o,c,q,-minmove);
|
||||
if (temp<minmove)
|
||||
{minmove=temp;
|
||||
if (minmove<alpha) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (minmove==1000) /* o forfeits */
|
||||
{minmove = -1000;
|
||||
{register position *qq, q;
|
||||
extern position trymov[];
|
||||
qq = trymov;
|
||||
while ((q = *qq++) >= 0) if (ismove (a,c,q))
|
||||
{register int temp;
|
||||
temp = meval(a,c,o,q,minmove);
|
||||
if (temp>minmove) minmove=temp;
|
||||
}
|
||||
}
|
||||
if (minmove == -1000) /* c forfeits */
|
||||
minmove = seval(a,c,o);
|
||||
}
|
||||
}
|
||||
--mdepth;
|
||||
if (debug>1)
|
||||
{printf ("%2d ", mdepth);
|
||||
putn (mdepth);
|
||||
putpos (p, stdout);
|
||||
printf (" %d\n", minmove);
|
||||
}
|
||||
return (minmove);
|
||||
}
|
||||
|
||||
# define C CORNERSCORE
|
||||
# define E EDGESCORE
|
||||
# define P POINTSCORE
|
||||
# define I INTERIORSCORE
|
||||
# define D DANGERSCORE
|
||||
|
||||
fastchar ssqval[100] {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, C, E, E, E, E, E, E, C, 0,
|
||||
0, E, D, D, D, D, D, D, E, 0,
|
||||
0, E, D, P, I, I, P, D, E, 0,
|
||||
0, E, D, I, I, I, I, D, E, 0,
|
||||
0, E, D, I, I, I, I, D, E, 0,
|
||||
0, E, D, P, I, I, P, D, E, 0,
|
||||
0, E, D, D, D, D, D, D, E, 0,
|
||||
0, C, E, E, E, E, E, E, C, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
|
||||
BIN
src/as/o/o4.rel
Normal file
BIN
src/as/o/o4.rel
Normal file
Binary file not shown.
196
src/as/o/o5.c
Normal file
196
src/as/o/o5.c
Normal file
@@ -0,0 +1,196 @@
|
||||
#include "o.h"
|
||||
|
||||
fastchar pcolor[] {'-', '@', '*'};
|
||||
|
||||
fastchar quadrant[100] {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 1, 1, 1, 2, 2, 2, 2, 0,
|
||||
0, 1, 1, 1, 1, 2, 2, 2, 2, 0,
|
||||
0, 1, 1, 1, 1, 2, 2, 2, 2, 0,
|
||||
0, 1, 1, 1, 1, 2, 2, 2, 2, 0,
|
||||
0, 3, 3, 3, 3, 4, 4, 4, 4, 0,
|
||||
0, 3, 3, 3, 3, 4, 4, 4, 4, 0,
|
||||
0, 3, 3, 3, 3, 4, 4, 4, 4, 0,
|
||||
0, 3, 3, 3, 3, 4, 4, 4, 4, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
position trymov[] {
|
||||
pos(0,0), pos(0,7), pos(7,0), pos(7,7),
|
||||
pos(0,1), pos(0,2), pos(0,3), pos(0,4),
|
||||
pos(0,5), pos(0,6), pos(1,0), pos(1,7),
|
||||
pos(2,0), pos(2,7), pos(3,0), pos(3,7),
|
||||
pos(4,0), pos(4,7), pos(5,0), pos(5,7),
|
||||
pos(6,0), pos(6,7), pos(7,1), pos(7,2),
|
||||
pos(7,3), pos(7,4), pos(7,5), pos(7,6),
|
||||
pos(2,2), pos(2,5), pos(5,2), pos(5,5),
|
||||
pos(2,3), pos(2,4), pos(3,2), pos(3,5),
|
||||
pos(4,2), pos(4,5), pos(5,3), pos(5,4),
|
||||
pos(1,2), pos(1,3), pos(1,4), pos(1,5),
|
||||
pos(2,1), pos(2,6), pos(3,1), pos(3,6),
|
||||
pos(4,1), pos(4,6), pos(5,1), pos(5,6),
|
||||
pos(6,2), pos(6,3), pos(6,4), pos(6,5),
|
||||
pos(1,1), pos(1,6), pos(6,1), pos(6,6),
|
||||
pos(3,3), pos(3,4), pos(4,3), pos(4,4),
|
||||
-1
|
||||
};
|
||||
|
||||
clrbrd(b)
|
||||
board b;
|
||||
|
||||
{register int i;
|
||||
i = 100;
|
||||
while (--i>=0) b[i] = EMPTY;
|
||||
b[pos(3,3)] = b[pos(4,4)] = WHITE;
|
||||
b[pos(4,3)] = b[pos(3,4)] = BLACK;
|
||||
b[WHITE] = b[BLACK] = 2;
|
||||
}
|
||||
|
||||
#ifdef unix
|
||||
cpybrd (a,b)
|
||||
register fastchar *a, *b;
|
||||
|
||||
{register int i;
|
||||
i = 100;
|
||||
while (--i>=0) *a++ = *b++;
|
||||
}
|
||||
#endif
|
||||
|
||||
cntbrd (b,c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{register position p;
|
||||
int count;
|
||||
count = 0;
|
||||
forallpos (p) {if (b[p] == c) ++count;}
|
||||
return (count);
|
||||
}
|
||||
|
||||
anymvs(b,c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{register position p;
|
||||
forallpos (p) {if (ismove (b,c,p)) return (TRUE);}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
direction dirlist[]
|
||||
{NORTH, EAST, SOUTH, WEST,
|
||||
NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST,
|
||||
0};
|
||||
|
||||
# ifdef unix
|
||||
ismov1(b,c,p1)
|
||||
board b;
|
||||
color c;
|
||||
position p1;
|
||||
|
||||
{register direction d;
|
||||
direction *dd;
|
||||
dd = dirlist;
|
||||
while (d = *dd++)
|
||||
{register position p;
|
||||
int k;
|
||||
p = p1;
|
||||
k = 0;
|
||||
while (valid (nextpos (p, d)))
|
||||
{register color x;
|
||||
if ((x = b[p]) == EMPTY) break;
|
||||
if (x == c)
|
||||
{if (k) return (TRUE);
|
||||
break;
|
||||
}
|
||||
++k;
|
||||
}
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
# endif
|
||||
|
||||
putmov(b,c,p1)
|
||||
board b;
|
||||
color c;
|
||||
position p1;
|
||||
|
||||
{register direction d;
|
||||
direction *dd;
|
||||
color o;
|
||||
|
||||
b[p1] = c;
|
||||
b[c] =+ sqscore (p1);
|
||||
o = oppcolor (c);
|
||||
dd = dirlist;
|
||||
while (d = *dd++)
|
||||
{register position p;
|
||||
int k;
|
||||
p = p1;
|
||||
k = 0;
|
||||
while (valid (nextpos (p, d)))
|
||||
{{register color x;
|
||||
if ((x = b[p]) == EMPTY) break;
|
||||
if (x != c) {++k; continue;}
|
||||
}
|
||||
if (k==0) break;
|
||||
p = p1;
|
||||
while (valid (nextpos (p, d)))
|
||||
{register int sscore;
|
||||
if (b[p] != o) break;
|
||||
b[p] = c;
|
||||
b[c] =+ (sscore = sqscore (p));
|
||||
b[o] =- sscore;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
putpos (p, fd)
|
||||
position p;
|
||||
FILE *fd;
|
||||
|
||||
{fprintf(fd, "%d-%d",posx(p)+1,posy(p)+1);
|
||||
}
|
||||
|
||||
putcolor (c, fd)
|
||||
color c;
|
||||
FILE *fd;
|
||||
|
||||
{if (c>=0 && c<=2) putc (pcolor[c], fd);
|
||||
else putc ('?', fd);
|
||||
}
|
||||
|
||||
putdir (d, fd)
|
||||
direction d;
|
||||
FILE *fd;
|
||||
|
||||
{char *s;
|
||||
if (d==NORTH) s="NORTH";
|
||||
else if (d==SOUTH) s="SOUTH";
|
||||
else if (d==EAST) s="EAST";
|
||||
else if (d==WEST) s="WEST";
|
||||
else if (d==NORTHEAST) s="NORTHEAST";
|
||||
else if (d==NORTHWEST) s="NORTHWEST";
|
||||
else if (d==SOUTHEAST) s="SOUTHEAST";
|
||||
else if (d==SOUTHWEST) s="SOUTHWEST";
|
||||
else s="?";
|
||||
fprintf (fd, "%s", s);
|
||||
}
|
||||
|
||||
# define C CORNERVALUE
|
||||
# define E EDGEVALUE
|
||||
# define I INTERIORVALUE
|
||||
|
||||
fastchar sqval[100] {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, C, 2, E, E, E, E, 2, C, 0,
|
||||
0, 2, 1, 3, 3, 3, 3, 1, 2, 0,
|
||||
0, E, 3, I, I, I, I, 3, E, 0,
|
||||
0, E, 3, I, I, I, I, 3, E, 0,
|
||||
0, E, 3, I, I, I, I, 3, E, 0,
|
||||
0, E, 3, I, I, I, I, 3, E, 0,
|
||||
0, 2, 1, 3, 3, 3, 3, 1, 2, 0,
|
||||
0, C, 2, E, E, E, E, 2, C, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
BIN
src/as/o/o5.rel
Normal file
BIN
src/as/o/o5.rel
Normal file
Binary file not shown.
334
src/as/o/o6.c
Normal file
334
src/as/o/o6.c
Normal file
@@ -0,0 +1,334 @@
|
||||
#include "o.h"
|
||||
|
||||
extern int display, explain;
|
||||
extern fastchar pcolor[];
|
||||
|
||||
# define LEFT 0
|
||||
# define RIGHT 1
|
||||
# define TYOSIZ 1000
|
||||
|
||||
static board leftb, rightb;
|
||||
static int cboard;
|
||||
static int left_exists, right_exists;
|
||||
static char tyobuf[TYOSIZ], *ctyop {tyobuf};
|
||||
|
||||
# define tyo(c) *ctyop++ = (c)
|
||||
|
||||
# ifndef unix
|
||||
# rename tyochn "TYOCHN"
|
||||
extern int tyochn;
|
||||
# define tyocrlf() (tyo('\r'))
|
||||
# define down() (tyo(16),tyo('D'))
|
||||
# define top() (tyo(16),tyo('T'))
|
||||
# define horiz(n) (tyo(16),tyo('H'),tyo(8+(n)))
|
||||
# define vertical(n) (tyo(16),tyo('V'),tyo(8+(n)))
|
||||
# define erasechar() (tyo(16),tyo('K'))
|
||||
# define eraseline() (tyo(16),tyo('L'))
|
||||
# define erasescreen() (tyo(16),tyo('E'))
|
||||
clrscreen () {spctty ('C');}
|
||||
# define savepos() (tyo(16),tyo('S'))
|
||||
# define rstrpos() (tyo(16),tyo('R'))
|
||||
# endif
|
||||
|
||||
# ifdef unix
|
||||
static int hpos, vpos, svhpos, svvpos;
|
||||
static char cmm[] {0, 10, 0, 11, 0377, 0377};
|
||||
getpos ()
|
||||
{ttymod (1, cmm);
|
||||
vpos = cmm[0];
|
||||
hpos = cmm[2];
|
||||
vpos=11;
|
||||
hpos=0;
|
||||
}
|
||||
# define tyocrlf() (++vpos,hpos=0,tyo('\n'),eraseline())
|
||||
# define down() (++vpos, tyo(033), tyo('B'))
|
||||
# define tyoreset() (tyo(033),tyo('Y'),tyo(vpos+040),tyo(hpos+040))
|
||||
# define top() (vpos=0,hpos=0,tyoreset())
|
||||
# define horiz(n) (hpos=(n),tyoreset())
|
||||
# define vertical(n) (vpos=(n),tyoreset())
|
||||
# define erasechar()
|
||||
# define eraseline() (tyo(033),tyo('K'))
|
||||
# define erasescreen() (tyo(033),tyo('J'))
|
||||
clrscreen () {top();erasescreen();}
|
||||
# define savepos() (getpos(),svhpos=hpos,svvpos=vpos)
|
||||
# define rstrpos() (hpos=svhpos,vpos=svvpos,tyoreset(),erasescreen())
|
||||
# endif
|
||||
|
||||
# ifndef unix
|
||||
tyoflush ()
|
||||
{int ptr;
|
||||
if (ctyop > tyobuf)
|
||||
{ptr = tyobuf;
|
||||
ptr =| 0444400000000;
|
||||
siot (tyochn, ptr, ctyop-tyobuf);
|
||||
ctyop = tyobuf;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
# ifdef unix
|
||||
tyoflush ()
|
||||
{if (ctyop > tyobuf)
|
||||
{write (1, tyobuf, ctyop-tyobuf);
|
||||
ctyop = tyobuf;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
styo (s)
|
||||
char *s;
|
||||
{int c;
|
||||
while (c = *s++) tyo(c);
|
||||
}
|
||||
|
||||
dpyempty ()
|
||||
|
||||
{
|
||||
right_exists = 0;
|
||||
left_exists = 0;
|
||||
vertical (11);
|
||||
erasescreen ();
|
||||
tyoflush ();
|
||||
}
|
||||
|
||||
prtbrd (b)
|
||||
board b;
|
||||
|
||||
{
|
||||
if (display)
|
||||
{if (cboard == LEFT || !explain) right_exists = 0;
|
||||
cpybrd (leftb,b);
|
||||
cboard = LEFT;
|
||||
erasescreen();
|
||||
newleft ();
|
||||
left_exists = TRUE;
|
||||
eraseline();
|
||||
tyoflush();
|
||||
}
|
||||
else
|
||||
outbrd (b);
|
||||
}
|
||||
|
||||
auxbrd(b)
|
||||
board b;
|
||||
|
||||
{
|
||||
if (display)
|
||||
{cboard = RIGHT;
|
||||
cpybrd (rightb,b);
|
||||
savepos();
|
||||
newright ();
|
||||
right_exists = TRUE;
|
||||
rstrpos ();
|
||||
tyoflush();
|
||||
}
|
||||
else
|
||||
outbrd (b);
|
||||
}
|
||||
|
||||
shwbrd(b)
|
||||
board b;
|
||||
|
||||
{
|
||||
if (display)
|
||||
{if (cboard == LEFT || !explain) right_exists = 0;
|
||||
cpybrd (leftb,b);
|
||||
cboard = LEFT;
|
||||
savepos ();
|
||||
newleft ();
|
||||
rstrpos ();
|
||||
left_exists = TRUE;
|
||||
tyoflush();
|
||||
}
|
||||
else
|
||||
outbrd (b);
|
||||
}
|
||||
|
||||
newleft ()
|
||||
|
||||
{
|
||||
register int x, y;
|
||||
if (!right_exists || !left_exists) {redisplay (); return;}
|
||||
top();
|
||||
eraseline();
|
||||
horiz (0);
|
||||
down();
|
||||
down();
|
||||
for (x=0; x<8; ++x)
|
||||
{horiz (1);
|
||||
for (y=0; y<8; ++y) dpysq (leftb,x,y);
|
||||
horiz (0);
|
||||
down();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
newright ()
|
||||
|
||||
{register int x, y;
|
||||
if (!left_exists) {redisplay (); return;}
|
||||
top();
|
||||
eraseline();
|
||||
horiz (0);
|
||||
down();
|
||||
if (!right_exists)
|
||||
{horiz (32);
|
||||
styo (" 1 2 3 4 5 6 7 8");
|
||||
horiz (0);
|
||||
}
|
||||
down();
|
||||
for (x=0; x<8; ++x)
|
||||
{horiz (32);
|
||||
eraseline();
|
||||
tyo (x+'1');
|
||||
for (y=0; y<8; ++y) tyosq (rightb,x,y);
|
||||
horiz (0);
|
||||
down ();
|
||||
}
|
||||
}
|
||||
|
||||
redisplay ()
|
||||
|
||||
{
|
||||
register int x, y;
|
||||
top();
|
||||
eraseline();
|
||||
tyocrlf ();
|
||||
styo(" 1 2 3 4 5 6 7 8");
|
||||
if (right_exists) styo ("\t\t 1 2 3 4 5 6 7 8");
|
||||
tyocrlf ();
|
||||
for (x=0; x<8; ++x)
|
||||
{tyo (x+'1');
|
||||
for (y=0; y<8; ++y) tyosq (leftb,x,y);
|
||||
if (right_exists)
|
||||
{styo ("\t\t");
|
||||
tyo (x+'1');
|
||||
for (y=0; y<8; ++y) tyosq (rightb,x,y);
|
||||
}
|
||||
tyocrlf();
|
||||
}
|
||||
}
|
||||
|
||||
tyosq (b, x, y)
|
||||
board b;
|
||||
position x, y;
|
||||
|
||||
{register int z;
|
||||
tyo(' ');
|
||||
z = b[pos(x,y)];
|
||||
if (z<=2) tyo(pcolor[z]);
|
||||
else tyoletter(z);
|
||||
}
|
||||
|
||||
dpysq (b, x, y)
|
||||
board b;
|
||||
position x, y;
|
||||
|
||||
{register int z;
|
||||
tyo (' ');
|
||||
z = b[pos(x,y)];
|
||||
erasechar ();
|
||||
if (z<=2) tyo(pcolor[z]);
|
||||
else tyoletter(z);
|
||||
}
|
||||
|
||||
tyoletter (c)
|
||||
{tyo(c);
|
||||
}
|
||||
|
||||
outbrd (b)
|
||||
board b;
|
||||
|
||||
{register int x, y;
|
||||
printf("\n 1 2 3 4 5 6 7 8\n");
|
||||
for (x=0; x<8; ++x)
|
||||
{printf("%1d",x+1);
|
||||
for (y=0; y<8; ++y) outsq (b,x,y);
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
outsq (b, x, y)
|
||||
board b;
|
||||
position x, y;
|
||||
|
||||
{register int z;
|
||||
putchar(' ');
|
||||
z = b[pos(x,y)];
|
||||
if (z<=2) putchar(pcolor[z]);
|
||||
else putletter(z);
|
||||
}
|
||||
|
||||
putletter (c)
|
||||
{putchar(c);
|
||||
}
|
||||
|
||||
extern char gambuf[];
|
||||
extern FILE *gamefile;
|
||||
|
||||
writbd(b, s)
|
||||
board b;
|
||||
char *s;
|
||||
|
||||
{register int x, y;
|
||||
register FILE *f;
|
||||
char *e;
|
||||
|
||||
if (s[0] == 0) s = "o.save";
|
||||
if ((f = fopen (s, "w")) == NULL) return (0);
|
||||
for (x=0; x<8; ++x)
|
||||
{for (y=0; y<8; ++y) putc(pcolor[b[pos(x,y)]], f);
|
||||
putc('\n', f);
|
||||
}
|
||||
# ifndef unix
|
||||
putc ('\n', f);
|
||||
s = gambuf;
|
||||
e = cclose (gamefile);
|
||||
while (s < e) putc (*s++, f);
|
||||
gamefile = copen (e, 'w', "s");
|
||||
# endif
|
||||
fclose (f);
|
||||
return (1);
|
||||
}
|
||||
|
||||
readbd(b, s)
|
||||
board b;
|
||||
char *s;
|
||||
|
||||
{register int x, y;
|
||||
register FILE *f;
|
||||
extern int fcnt[], handicap;
|
||||
if (s[0] == 0) s = "o.save";
|
||||
if ((f = fopen (s, "r")) == NULL) return (0);
|
||||
for (x=0; x<8; ++x)
|
||||
{for (y=0; y<8; ++y) switch (getc (f)) {
|
||||
case '*': b[pos(x,y)] = BLACK; continue;
|
||||
case '@': b[pos(x,y)] = WHITE; continue;
|
||||
default: b[pos(x,y)] = EMPTY; continue;
|
||||
}
|
||||
getc(f);
|
||||
}
|
||||
# ifndef unix
|
||||
getc (f);
|
||||
cclose (gamefile);
|
||||
gamefile = copen (gambuf, 'w', "s");
|
||||
while ((x = getc (f)) > 0) putc (x, gamefile);
|
||||
# endif
|
||||
fclose (f);
|
||||
endgame = -1000;
|
||||
setmov (b, (cntbrd (b,WHITE) + cntbrd (b,BLACK) - 1)/2);
|
||||
fcnt[WHITE] = fcnt[BLACK] = handicap = 0;
|
||||
right_exists = FALSE;
|
||||
return (1);
|
||||
}
|
||||
|
||||
fixbrd (b)
|
||||
board b;
|
||||
|
||||
{register position p;
|
||||
b[0] = b[1] = b[2] = 0;
|
||||
forallpos (p)
|
||||
{register color c;
|
||||
if ((c = b[p]) != EMPTY) b[c] =+ sqscore (p);
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/as/o/o6.rel
Normal file
BIN
src/as/o/o6.rel
Normal file
Binary file not shown.
2
src/as/o/o7.c
Normal file
2
src/as/o/o7.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "obk.code"
|
||||
|
||||
BIN
src/as/o/o7.rel
Normal file
BIN
src/as/o/o7.rel
Normal file
Binary file not shown.
429
src/as/o/o8.c
Normal file
429
src/as/o/o8.c
Normal file
@@ -0,0 +1,429 @@
|
||||
int book[] {0, 1, 4, 4522016, 5701671, 7405605, 8585250,
|
||||
2, 3, 4325424, 4587584, 7012432,
|
||||
3, 4, 4194560, 5701904, 7340320, 8519984,
|
||||
4, 5, 3408048, 4784320, 6029520, 7340256, 8650992,
|
||||
5, 5, 8126560, 8257648, 8388736, 8585360, 8716448,
|
||||
6, 5, 3146928, 4326592, 4588752, 4785376, 6817008,
|
||||
7, 3, 4326528, 4654224, 9569440,
|
||||
8, 4, 4326464, 4654160, 9569376, 9831536,
|
||||
9, 5, 3146736, 4588544, 4719632, 7406624, 9962544,
|
||||
10, 4, 3146672, 4588480, 4719568, 7406560,
|
||||
11, 6, 3015504, 3277664, 4391792, 5702528, 6947728, 8324000,
|
||||
12, 3, 3277600, 4326192, 7013184,
|
||||
13, 4, 4391648, 4850416, 6947584, 7471888,
|
||||
14, 3, 4391600, 6947520, 8520400,
|
||||
15, 6, 3015248, 4391520, 5636720, 6947456, 8258192, 8520352,
|
||||
16, 5, 3146240, 4653584, 6029856, 6947376, 8389184,
|
||||
17, 2, 4653536, 7012839,
|
||||
18, 5, 3146128, 4653472, 6029744, 8389056, 8651216,
|
||||
19, 5, 3146048, 4653392, 6029664, 8388976, 8651136,
|
||||
20, 3, 1906912, 3021056, 5642512,
|
||||
21, 4, 3086496, 3152048, 3283136, 5707984,
|
||||
22, 5, 4266048, 4593744, 4724832, 4855920, 7346304,
|
||||
23, 6, 4199536, 5642208, 7018480, 8263680, 9574416, 9705504,
|
||||
24, 4, 4200384, 5707399, 7411333, 8787906,
|
||||
25, 3, 1906560, 3020704, 5642160,
|
||||
26, 4, 3086160, 3150352, 3282784, 5707632,
|
||||
27, 4, 4200208, 4658976, 4724528, 4855616,
|
||||
28, 6, 4200096, 5641904, 7018176, 8263376, 9574112, 9705200,
|
||||
29, 4, 4200048, 5707392, 8590981, 9967221,
|
||||
30, 8, 3085824, 3151376, 3282464, 3413552, 4724288, 6033680, 7345744, 8656480,
|
||||
32, 8, 1905968, 1971520, 3085648, 4592992, 5707120, 7345536, 8525200, 8656288,
|
||||
33, 3, 4787952, 7410960, 8656160,
|
||||
34, 3, 4723936, 7410928, 8656128,
|
||||
35, 5, 5706912, 8259424, 8393904, 8524992, 8721616,
|
||||
36, 5, 5706832, 8262752, 8524912, 8656000, 9704592,
|
||||
37, 5, 3150864, 3281952, 3411600, 4789296, 6034496,
|
||||
38, 5, 3150784, 3281872, 3412960, 4789232, 6034432,
|
||||
39, 6, 3281744, 4199264, 4330352, 4789120, 6820752, 7345056,
|
||||
40, 5, 3281664, 4330256, 4789024, 6820656, 7344960,
|
||||
41, 7, 3281568, 3411136, 4788912, 6034112, 6951632, 7344864, 8393456,
|
||||
42, 6, 3412544, 4723280, 6034016, 7410288, 8393344, 9966224,
|
||||
43, 4, 3084800, 3150352, 3281440, 3412528,
|
||||
44, 5, 3281328, 4395456, 4723152, 5638807, 6820320,
|
||||
45, 6, 3412304, 4723040, 6099312, 8655232, 9703824, 9965984,
|
||||
46, 7, 3084512, 3150064, 3281152, 5640464, 7344416, 8393008, 8524096,
|
||||
47, 7, 3281008, 3412096, 4788368, 6164640, 7344304, 8523968, 8655056,
|
||||
48, 7, 3149824, 3280912, 4788256, 5640240, 8261696, 8392784, 8523872,
|
||||
49, 7, 3280784, 3411872, 4788144, 6164416, 7344080, 8523744, 8654832,
|
||||
50, 6, 1838896, 2101056, 3411792, 6098784, 7343984, 8720256,
|
||||
51, 5, 4198128, 5638007, 7016192, 7343888, 8523552,
|
||||
52, 5, 8130208, 8261296, 8392384, 8589008, 8720096,
|
||||
53, 7, 3149360, 4329024, 4787792, 6032992, 7343728, 8523392, 8654480,
|
||||
54, 6, 2100688, 3149280, 4787696, 6032896, 7343632, 8654368,
|
||||
55, 5, 4197760, 4787600, 6950304, 7343536, 8523200,
|
||||
56, 6, 4197664, 4721968, 6819136, 6950224, 7343456, 8588656,
|
||||
57, 6, 6032592, 7408864, 8127888, 8391920, 8523008, 8654096,
|
||||
58, 5, 6098048, 7343248, 8391840, 8522928, 8654016,
|
||||
59, 5, 3083312, 4328512, 5639248, 6818912, 8260720,
|
||||
60, 7, 3279808, 4328400, 4787168, 5639152, 6818816, 8260624, 8391712,
|
||||
61, 6, 4655984, 6032256, 6818704, 7343008, 8127872, 8391600,
|
||||
62, 6, 6032160, 8129328, 8260416, 8391504, 8587728, 8784736,
|
||||
63, 5, 3017424, 4393696, 5638896, 6818560, 8260368,
|
||||
64, 7, 3279456, 4393584, 4721280, 5638800, 6818464, 8260272, 8391360,
|
||||
65, 7, 4590064, 5638656, 6031888, 6818336, 7408176, 8129088, 8391248,
|
||||
66, 7, 5638528, 6162832, 8128928, 8260016, 8391104, 8718800, 8784352,
|
||||
67, 5, 6818096, 8194368, 8259920, 8391008, 9832816,
|
||||
68, 7, 4196544, 5507280, 5703904, 6031600, 6818048, 7342352, 8522016,
|
||||
69, 5, 4786288, 5507200, 6031504, 6817952, 7342256,
|
||||
70, 6, 6817808, 7407648, 8128560, 8521792, 8652880, 9701472,
|
||||
71, 6, 6817712, 7407552, 8128464, 8521696, 8718320, 9701376,
|
||||
72, 5, 4196192, 5703536, 6817664, 7341968, 8521632,
|
||||
73, 4, 4785952, 5703472, 6817600, 7341904,
|
||||
74, 5, 6817472, 7341776, 8128224, 8521456, 8718080,
|
||||
75, 6, 3081824, 4589168, 5637760, 7341712, 8259232, 8521392,
|
||||
76, 7, 4195824, 4654592, 5637648, 7341600, 8259120, 8390208, 8521296,
|
||||
77, 6, 3409296, 4720032, 6030768, 7407040, 8390096, 8652256,
|
||||
78, 4, 6096208, 7341408, 8390000, 8652160,
|
||||
79, 5, 5506304, 8324368, 8389920, 8521008, 8652096,
|
||||
80, 6, 4653056, 4325376, 4718592, 4063232, 6684672, 3145728,
|
||||
81, 4, 4653056, 4325376, 9568256, 9699328,
|
||||
82, 4, 4653056, 4325376, 9568256, 9830400,
|
||||
83, 5, 4587520, 7340032, 4784128, 3145728, 10027008,
|
||||
84, 4, 4587520, 7340032, 4784128, 3145728,
|
||||
85, 6, 4653056, 7340032, 4325376, 3145728, 4849664, 6815744,
|
||||
86, 1, 8323072,
|
||||
87, 6, 5701632, 4325376, 8257536, 3014656, 6815744, 9568256,
|
||||
88, 6, 5701632, 7340032, 8519680, 3014656, 3145728, 6815744,
|
||||
89, 6, 5636096, 4390912, 3014656, 3145728, 3276800, 6815744,
|
||||
90, 6, 5701632, 4325376, 3014656, 3145728, 3276800, 6815744,
|
||||
91, 6, 4325376, 4784128, 3145728, 4849664, 6815744, 7471104,
|
||||
92, 2, 8585216, 4325376,
|
||||
93, 6, 5636096, 4390912, 8257536, 3014656, 6815744, 9568256,
|
||||
94, 7, 5636096, 7340032, 8519680, 4390912, 3080192, 3145728, 6815744,
|
||||
95, 5, 4653056, 6029312, 4784128, 3145728, 6815744,
|
||||
96, 4, 4784128, 3145728, 3276800, 6815744,
|
||||
97, 6, 4587520, 4718592, 8323079, 3145728, 4194304, 6815744,
|
||||
98, 5, 4587520, 6094848, 8388608, 8650752, 3145728,
|
||||
99, 5, 4653056, 6029312, 8388608, 3145728, 6815744,
|
||||
100, 3, 4653056, 6815744, 9568256,
|
||||
101, 8, 4587520, 6094848, 7340032, 4718592, 8650754, 3145728, 6815744, 9961472,
|
||||
102, 4, 4653056, 6029312, 4784128, 6815744,
|
||||
103, 6, 6029312, 7340032, 4325376, 4784128, 3276800, 6815744,
|
||||
104, 6, 4653056, 7340032, 4325376, 4718592, 4194304, 6815744,
|
||||
105, 4, 6029312, 8388608, 8716288, 8781824,
|
||||
106, 5, 4587520, 6029312, 7340032, 8454144, 6815744,
|
||||
107, 6, 6094848, 7340032, 4784128, 8716290, 6815744, 9961472,
|
||||
108, 6, 4587520, 5636096, 4325376, 4784128, 5373952, 6684672,
|
||||
109, 3, 4653056, 4718592, 7471104,
|
||||
110, 7, 4587520, 5636096, 4325376, 4784128, 6684672, 7995392, 6815744,
|
||||
111, 3, 4587520, 7405568, 4784128,
|
||||
112, 3, 4653056, 7405568, 4784128,
|
||||
114, 6, 6094848, 8388608, 3145728, 3276800, 3473408, 9568256,
|
||||
115, 7, 8454144, 4325376, 3080192, 3145728, 5505024, 6815744, 8126464,
|
||||
116, 6, 8388608, 4325376, 6684672, 3080192, 3145728, 8126464,
|
||||
117, 8, 6029312, 8388608, 8585216, 4390912, 8650752, 3145728, 7471104, 9568256,
|
||||
118, 5, 4587520, 6029312, 8454144, 3145728, 9568256,
|
||||
119, 3, 4653056, 6815744, 9568263,
|
||||
120, 6, 4653056, 6029312, 8388608, 6684672, 3145728, 8126464,
|
||||
121, 7, 4653056, 6029312, 8454144, 8650757, 3145728, 7471104, 9568256,
|
||||
122, 7, 4653056, 6029312, 7340032, 8454144, 8650754, 3145728, 9568256,
|
||||
123, 5, 4653056, 4325376, 6684672, 3145728, 5505024,
|
||||
124, 4, 4653056, 6094848, 3145728, 7471104,
|
||||
125, 5, 4653056, 4325376, 3145728, 5505024, 6815744,
|
||||
126, 5, 4587520, 6029312, 7340032, 8716288, 3145728,
|
||||
127, 5, 4587520, 6029312, 7405568, 3145728, 7471104,
|
||||
128, 3, 4653056, 4325376, 9568256,
|
||||
129, 5, 4653056, 4325376, 6684672, 3145728, 5505024,
|
||||
130, 4, 4653056, 6094848, 3145728, 7471104,
|
||||
131, 6, 4653056, 4325376, 6684672, 3145728, 5505024, 6815744,
|
||||
132, 5, 4587520, 6029312, 7340032, 8716288, 3145728,
|
||||
133, 4, 4587520, 6094848, 7405568, 3145728,
|
||||
134, 3, 4653056, 4325376, 9830400,
|
||||
135, 7, 6094848, 3145728, 3276800, 3407872, 9568256, 9699328, 9830400,
|
||||
136, 8, 4325376, 8257536, 3014656, 3145728, 6815744, 8192000, 9568256, 9699328,
|
||||
137, 11, 7340032, 8519680, 4325376, 8323072, 8650752, 3014656, 3145728, 6160384, 7471104, 9699328, 9830400,
|
||||
138, 8, 4325376, 8257536, 6684672, 3014656, 3145728, 8192000, 9568256, 9699328,
|
||||
139, 8, 6094848, 8585216, 4325376, 8650752, 3145728, 7471104, 9699328, 9830400,
|
||||
140, 6, 4653056, 6029312, 3145728, 9568256, 9699328, 9830400,
|
||||
141, 8, 4653056, 6094848, 6684672, 3145728, 6815744, 8126464, 9568256, 9699328,
|
||||
142, 3, 4653056, 9568256, 9830400,
|
||||
143, 7, 4653056, 7340032, 8650752, 3145728, 6160384, 9699328, 9830400,
|
||||
144, 7, 4653056, 6029312, 6684672, 3145728, 8126464, 9568256, 9699328,
|
||||
145, 7, 4587520, 6094848, 8650757, 3145728, 7471104, 9699328, 9830400,
|
||||
146, 7, 4653056, 6094848, 7340032, 8716290, 3145728, 9699328, 9830400,
|
||||
147, 2, 4587520, 5701632,
|
||||
148, 5, 4587520, 7340032, 4784128, 3145728, 6815744,
|
||||
149, 4, 4653056, 5636096, 7340032, 9568256,
|
||||
150, 5, 4587520, 5636096, 7340032, 8323072, 9830400,
|
||||
151, 5, 4653056, 7340032, 4718592, 3145728, 9699328,
|
||||
152, 5, 4587520, 4390912, 3014656, 9699328, 9830400,
|
||||
153, 7, 4653056, 4325376, 4718592, 3145728, 7471104, 9830400, 9961472,
|
||||
154, 9, 4653056, 4325376, 4718592, 3014656, 3145728, 6815744, 9699328, 9830400, 9961472,
|
||||
155, 6, 4653056, 4325376, 3014656, 9568256, 9699328, 9830400,
|
||||
156, 6, 4653056, 4325376, 3014656, 9568256, 9699328, 9830400,
|
||||
157, 6, 4587520, 4718592, 3014656, 3145728, 9699328, 10027008,
|
||||
158, 7, 4653056, 4325376, 4718592, 3145728, 7471104, 9830400, 9961472,
|
||||
159, 5, 7340032, 4325376, 3145728, 3407872, 10027008,
|
||||
160, 7, 4587520, 7340032, 4390912, 8257536, 3014656, 5505024, 9830400,
|
||||
161, 4, 4587520, 7405568, 3145728, 9961472,
|
||||
162, 4, 5636096, 8323072, 3014656, 9830400,
|
||||
163, 4, 4653056, 3145728, 7471104, 9961472,
|
||||
164, 7, 5701632, 7340032, 3014656, 3145728, 6815744, 9830400, 9961472,
|
||||
165, 6, 4587520, 5701632, 7340032, 8257536, 3014656, 9830400,
|
||||
166, 7, 6029312, 7340032, 4784128, 8650752, 3145728, 3407872, 9961472,
|
||||
167, 6, 7340032, 4718592, 3145728, 4194304, 9830400, 10027008,
|
||||
168, 6, 6094848, 7340032, 8716288, 3145728, 3407872, 9961472,
|
||||
169, 3, 7340032, 4390912, 9830400,
|
||||
170, 7, 6029312, 8388608, 4390912, 8650752, 3145728, 8126464, 9830400,
|
||||
171, 8, 6029312, 7340032, 8388608, 4390912, 8650752, 3145728, 9568256, 9830400,
|
||||
172, 3, 7340032, 4390912, 9830400,
|
||||
173, 5, 6094848, 7340032, 4718592, 8716288, 9961472,
|
||||
174, 6, 4653056, 7340032, 4784128, 4194304, 5505024, 9961472,
|
||||
175, 5, 4587520, 7340032, 8388608, 4390912, 6815744,
|
||||
176, 5, 6029312, 7340032, 8388608, 8650752, 8192000,
|
||||
177, 5, 6029312, 7340032, 8388608, 8716288, 9568256,
|
||||
178, 6, 4587520, 4325376, 4784128, 3145728, 4849664, 7471104,
|
||||
179, 7, 4587520, 4325376, 4718592, 3080192, 3145728, 6815744, 9961472,
|
||||
180, 5, 4653056, 4325376, 3014656, 9568256, 9961472,
|
||||
181, 6, 4653056, 4325376, 3014656, 9568256, 9830400, 9961472,
|
||||
182, 5, 4653056, 4325376, 4718592, 3145728, 7471104,
|
||||
183, 4, 7340032, 4325376, 3145728, 3473408,
|
||||
184, 3, 4587520, 7405568, 3145728,
|
||||
185, 4, 5636096, 8519680, 8323072, 3014656,
|
||||
186, 3, 4653056, 3145728, 7471104,
|
||||
187, 7, 4653056, 5636096, 7340032, 8519680, 8257536, 3014656, 9830400,
|
||||
188, 5, 6094848, 7340032, 4784128, 3145728, 3407872,
|
||||
189, 5, 7340032, 8585216, 4784128, 3145728, 4194304,
|
||||
190, 4, 6029312, 7340032, 3145728, 3473408,
|
||||
191, 6, 7340032, 8585216, 4390912, 4784128, 3145728, 4259840,
|
||||
192, 6, 6029312, 8388608, 8585216, 4390912, 3145728, 8126464,
|
||||
193, 7, 6029312, 7340032, 8454144, 8519680, 4390912, 3145728, 9568256,
|
||||
194, 4, 7340032, 8585216, 4325376, 9830400,
|
||||
195, 3, 6094848, 7340032, 4784128,
|
||||
196, 5, 4587520, 7405568, 4718592, 4194304, 5505024,
|
||||
197, 6, 4587520, 7340032, 4390912, 4718592, 4194304, 6815744,
|
||||
198, 4, 6094848, 7340032, 8388608, 8192000,
|
||||
199, 4, 6029312, 7405568, 8388608, 9568256,
|
||||
200, 5, 4390912, 4784128, 3145728, 3276800, 4915200,
|
||||
201, 5, 4325376, 4784128, 3145728, 3276800, 7471104,
|
||||
202, 7, 5636096, 7012352, 8519680, 4325376, 3014656, 3276800, 9568256,
|
||||
203, 4, 7405568, 4784128, 3145728, 9961472,
|
||||
204, 6, 5636096, 7340032, 8585216, 3014656, 3145728, 3276800,
|
||||
205, 5, 4325376, 4718592, 3145728, 3276800, 4915200,
|
||||
206, 5, 4325376, 4784128, 3145728, 3276800, 7471104,
|
||||
207, 7, 5636096, 4325376, 8323072, 3014656, 3276800, 9568256, 9830400,
|
||||
208, 4, 7340032, 4718592, 3145728, 10027008,
|
||||
209, 6, 5636096, 7340032, 8585216, 3014656, 3145728, 3276800,
|
||||
210, 7, 6946816, 8388608, 8323072, 3014656, 3145728, 3276800, 5505024,
|
||||
211, 6, 6029312, 6946816, 8454144, 8519680, 3145728, 3276800,
|
||||
212, 7, 6946816, 8388608, 8323072, 3014656, 3145728, 3276800, 5505024,
|
||||
213, 6, 8519680, 4390912, 8257536, 3014656, 3276800, 6815744,
|
||||
214, 6, 6029312, 8454144, 8519680, 8650752, 3145728, 3276800,
|
||||
215, 6, 6094848, 8454144, 8650752, 3145728, 3276800, 9961472,
|
||||
216, 6, 6946816, 8454144, 8323072, 3014656, 3145728, 3276800,
|
||||
217, 6, 6094848, 6946816, 8388608, 3145728, 3276800, 4849664,
|
||||
218, 6, 5701632, 4718592, 8257536, 3014656, 3276800, 6815744,
|
||||
219, 5, 6094848, 8388608, 4718592, 8650752, 3145728,
|
||||
220, 5, 6094848, 8454144, 4784128, 8650752, 3145728,
|
||||
221, 6, 5636096, 6946816, 4325376, 8323072, 1966080, 3014656,
|
||||
222, 7, 5636096, 6946816, 4390912, 8257536, 1703936, 1966080, 3080192,
|
||||
223, 4, 5701632, 6946816, 4325376, 6160384,
|
||||
224, 5, 5701632, 6946816, 4325376, 4849664, 7471104,
|
||||
225, 4, 5636096, 6946816, 8519680, 4390912,
|
||||
226, 6, 5636096, 6946816, 8519680, 4390912, 8257536, 3014656,
|
||||
227, 5, 5701632, 6946816, 4390912, 8257536, 3276800,
|
||||
228, 4, 5701632, 6946816, 8257536, 3276800,
|
||||
229, 6, 6946816, 7340032, 8388608, 4390912, 3276800, 4849664,
|
||||
230, 7, 6946816, 7340032, 8388608, 4325376, 4784128, 3276800, 4849664,
|
||||
231, 7, 5636096, 8388608, 8519680, 4784128, 8257536, 3276800, 8781824,
|
||||
232, 3, 7340032, 8388608, 4784128,
|
||||
233, 6, 5636096, 8388608, 8519680, 4784128, 8257536, 3276800,
|
||||
234, 4, 4390912, 3145728, 3276800, 6815744,
|
||||
235, 4, 4325376, 3276800, 3473408, 9568256,
|
||||
236, 5, 4325376, 3276800, 3473408, 9568256, 9830400,
|
||||
237, 4, 7405568, 3145728, 3407872, 9961472,
|
||||
238, 3, 7405568, 3145728, 3473408,
|
||||
239, 6, 6094848, 6946816, 8388608, 3145728, 3342336, 3407872,
|
||||
240, 3, 3276800, 4915200, 6815744,
|
||||
241, 6, 6094848, 8388608, 8650757, 3145728, 3407872, 4849664,
|
||||
242, 6, 6094848, 8388608, 8650754, 3145728, 3407872, 4849664,
|
||||
243, 7, 5701632, 6946816, 4325376, 8257536, 1966080, 3014656, 4849664,
|
||||
244, 7, 5701632, 6946816, 4325376, 8257536, 1966080, 3014656, 4849664,
|
||||
245, 6, 5636096, 6946816, 4390912, 8257536, 3014656, 6160384,
|
||||
246, 6, 5636096, 6946816, 4390912, 4849664, 6160384, 7471104,
|
||||
247, 6, 5636096, 7012352, 8519680, 4325376, 4849664, 6160384,
|
||||
248, 8, 5636096, 7012352, 8519680, 4325376, 8257536, 3014656, 4849664, 6160384,
|
||||
249, 5, 5636096, 6946816, 4390912, 1966080, 3145728,
|
||||
250, 5, 5701632, 6946816, 4325376, 3145728, 3276800,
|
||||
251, 6, 5701632, 6946816, 4325376, 3145728, 3276800, 3407872,
|
||||
252, 3, 6946816, 4390912, 4849664,
|
||||
253, 6, 5636096, 6946816, 8388608, 8519680, 4325376, 8716288,
|
||||
254, 5, 5701632, 6946816, 8388608, 4325376, 9830400,
|
||||
255, 6, 5636096, 6946816, 8388608, 8519680, 4390912, 9830400,
|
||||
256, 6, 4718592, 1835008, 3276800, 3407872, 4915200, 6160384,
|
||||
257, 6, 4718592, 1966080, 3145728, 3407872, 4915200, 6160384,
|
||||
258, 5, 3145728, 3276800, 3407872, 4849664, 6225920,
|
||||
259, 6, 4390912, 4718592, 3145728, 4194304, 4849664, 7471104,
|
||||
260, 7, 8454144, 4390912, 3145728, 4849664, 6160384, 7471104, 9568256,
|
||||
261, 5, 7340032, 8519680, 4390912, 7471104, 9830400,
|
||||
262, 9, 7340032, 4390912, 4718592, 8650754, 3145728, 6160384, 7471104, 9830400, 9961472,
|
||||
263, 5, 5701632, 7012352, 4325376, 1966080, 3145728,
|
||||
264, 6, 5636096, 7012352, 4325376, 1966080, 3145728, 3276800,
|
||||
265, 6, 5701632, 6946816, 4325376, 3145728, 3276800, 3407872,
|
||||
266, 3, 7012352, 4390912, 7471104,
|
||||
267, 6, 5636096, 6946816, 8388608, 8519680, 4325376, 8716288,
|
||||
268, 5, 5636096, 6946816, 8388608, 4390912, 9830400,
|
||||
269, 5, 5636096, 6946816, 8388608, 8519680, 4390912,
|
||||
270, 7, 7012352, 8388608, 1769472, 3145728, 4849664, 6160384, 7471104,
|
||||
271, 5, 6946816, 4784128, 1966080, 3276800, 4849664,
|
||||
272, 9, 7012352, 7340032, 8388608, 4784128, 1966080, 2097152, 3473408, 4849664, 6160384,
|
||||
273, 6, 7012352, 7340032, 8388608, 4849664, 6815744, 7471104,
|
||||
274, 6, 8454144, 8519680, 8650757, 6160384, 7471104, 8781824,
|
||||
275, 6, 7405568, 8585216, 8716288, 6160384, 7471104, 9699328,
|
||||
276, 6, 7340032, 8454144, 8650754, 6160384, 7471104, 9830400,
|
||||
277, 9, 5636096, 6946816, 4390912, 8257536, 3014656, 3276800, 6160384, 7471104, 8781824,
|
||||
278, 6, 5636096, 6946816, 4390912, 3276800, 6160384, 7471104,
|
||||
279, 6, 5636096, 6946816, 4390912, 4849664, 6160384, 7471104,
|
||||
280, 7, 5636096, 7012352, 4325376, 8257536, 3014656, 6160384, 8781824,
|
||||
281, 8, 5701632, 6946816, 4390912, 8257536, 3014656, 7471104, 8781824, 9830400,
|
||||
282, 8, 5701632, 6946816, 4325376, 8257536, 3014656, 7471104, 8781824, 9830400,
|
||||
283, 6, 6094848, 8388608, 8716288, 3145728, 3407872, 7471104,
|
||||
284, 3, 8585216, 4194304, 7471104,
|
||||
285, 6, 6094848, 8388608, 8650752, 3145728, 3407872, 7471104,
|
||||
286, 7, 6029312, 8388608, 8585216, 4325376, 8650752, 3145728, 8126464,
|
||||
288, 4, 6946816, 8519680, 8716288, 1769472,
|
||||
289, 5, 6946816, 8519680, 8716288, 1703936, 1966080,
|
||||
290, 5, 8388608, 4718592, 8716288, 2097152, 8781824,
|
||||
291, 4, 8388608, 4784128, 8650752, 8781824,
|
||||
292, 7, 5636096, 6946816, 4325376, 8323072, 3014656, 3276800, 8781824,
|
||||
293, 5, 5701632, 6946816, 4325376, 3276800, 8781824,
|
||||
294, 6, 5701632, 6946816, 4325376, 4849664, 7471104, 8781824,
|
||||
295, 5, 5701632, 6946816, 4390912, 6160384, 8781824,
|
||||
296, 7, 5701632, 6946816, 4325376, 8323072, 3014656, 9568256, 9830400,
|
||||
297, 6, 5701632, 6946816, 4325376, 8257536, 3014656, 9830400,
|
||||
298, 3, 7405568, 4718592, 3145728,
|
||||
299, 6, 5636096, 7340032, 8585216, 3014656, 3145728, 3276800,
|
||||
300, 7, 3145728, 4325376, 4718592, 6946816, 7405568, 7471104, 8519680,
|
||||
301, 5, 3014656, 4390912, 5636096, 8126464, 8519680,
|
||||
302, 6, 3145728, 4325376, 4784128, 6946816, 7471104, 8519680,
|
||||
303, 5, 3014656, 4325376, 5636096, 7012352, 8519680,
|
||||
304, 5, 3145728, 3407872, 6029312, 7405568, 8454144,
|
||||
305, 6, 3014656, 4194304, 5701632, 7340032, 8257536, 8519680,
|
||||
306, 5, 3145728, 3407872, 6094848, 7340032, 8454144,
|
||||
307, 7, 3080192, 3145728, 4390912, 8192000, 8323072, 8454144, 8585216,
|
||||
308, 6, 3145728, 4325376, 6029312, 7471104, 8388608, 8585216,
|
||||
309, 6, 2097152, 3145728, 3407872, 6094848, 8454144, 8585216,
|
||||
310, 7, 3014656, 3145728, 4390912, 5505024, 8257536, 8388608, 8519680,
|
||||
311, 6, 3014656, 3276800, 4194304, 7012352, 8257536, 8519680,
|
||||
312, 6, 3145728, 3276800, 3473408, 6094848, 8388608, 8519680,
|
||||
313, 7, 3014656, 3145728, 4390912, 5505024, 8323072, 8388608, 8519680,
|
||||
314, 6, 3145728, 3276800, 4390912, 6029312, 8388608, 8519680,
|
||||
316, 7, 1703936, 1966080, 3014656, 5636096, 7012352, 8257536, 8519680,
|
||||
317, 4, 2097152, 4784128, 7340032, 8454144,
|
||||
318, 6, 3276800, 4718592, 5701632, 8257536, 8388608, 8519680,
|
||||
319, 5, 4849664, 6946816, 7405568, 8388608, 8585216,
|
||||
320, 5, 6946816, 7405568, 7471104, 8388608, 8519680,
|
||||
321, 7, 1703936, 3276800, 4390912, 5636096, 6946816, 8257536, 8519680,
|
||||
322, 4, 2097152, 4784128, 7340032, 8388608,
|
||||
323, 5, 4849664, 6946816, 7340032, 8388608, 8585216,
|
||||
324, 5, 6946816, 7405568, 7471104, 8388608, 8519680,
|
||||
325, 3, 3145728, 4653056, 4784128,
|
||||
326, 5, 3145728, 4587520, 6029312, 7012352, 8126464,
|
||||
327, 6, 3145728, 4784128, 6029312, 7405568, 8650752, 9961472,
|
||||
328, 4, 3145728, 4718592, 6094848, 7340032,
|
||||
329, 3, 4587520, 6946816, 9633792,
|
||||
330, 4, 3014663, 3145728, 4653056, 4718592,
|
||||
331, 3, 4653056, 9633792, 9830400,
|
||||
332, 6, 3145728, 4784128, 6029312, 7340032, 8716288, 9961472,
|
||||
333, 4, 3145728, 4653056, 4784128, 7405568,
|
||||
334, 5, 3145728, 3407872, 4653056, 6946816, 8388608,
|
||||
335, 3, 3145728, 8388608, 8716288,
|
||||
336, 5, 3014656, 5636096, 8323072, 8388608, 8519680,
|
||||
337, 6, 3145728, 4128768, 6094848, 8388608, 8585216, 8650752,
|
||||
338, 6, 3014656, 4063232, 5701632, 6946816, 8257536, 8519680,
|
||||
339, 2, 4653056, 7012352,
|
||||
340, 7, 1835008, 4063232, 4653056, 6029312, 6946816, 7340032, 8388608,
|
||||
341, 5, 4653056, 5505024, 6029312, 6946816, 8388608,
|
||||
342, 6, 3342336, 3407872, 5505024, 6094848, 6946816, 8388608,
|
||||
343, 7, 4063232, 4587520, 5505024, 6815744, 6946816, 7405568, 8388608,
|
||||
344, 6, 4128768, 5505024, 6029312, 8388608, 8650752, 8781824,
|
||||
345, 6, 4128768, 5505024, 6029312, 7340032, 8388608, 8650752,
|
||||
346, 4, 4128768, 5505024, 7340032, 8388608,
|
||||
352, 6, 4194304, 5505024, 6815744, 6946816, 8323072, 8454144,
|
||||
353, 6, 1703936, 1966080, 3014656, 5505024, 7012352, 8257536,
|
||||
354, 5, 1966080, 3080192, 5570560, 7012352, 8323072,
|
||||
355, 7, 3276800, 4784128, 5505024, 6815744, 6946816, 8257536, 8388608,
|
||||
356, 5, 4849664, 6815744, 7012352, 7340032, 8388608,
|
||||
357, 8, 5505024, 6815744, 6946816, 8323072, 8388608, 8519680, 8650752, 8781824,
|
||||
358, 6, 5505024, 6881280, 7012352, 8257536, 8388608, 8519680,
|
||||
359, 6, 3145728, 4587520, 6094848, 6946816, 7471104, 8388608,
|
||||
360, 4, 4587520, 6094848, 6946816, 7471104,
|
||||
362, 5, 3145728, 4784128, 6094848, 7471104, 8650752,
|
||||
363, 8, 3145728, 4194304, 4587520, 4718592, 6029312, 7012352, 7471104, 8650752,
|
||||
364, 6, 3145728, 4653056, 5505024, 6094848, 8126464, 8716288,
|
||||
365, 5, 3145728, 4587520, 6094848, 8126464, 8650752,
|
||||
366, 7, 3145728, 4587520, 4784128, 6029312, 7471104, 8650752, 9699328,
|
||||
367, 2, 4587520, 8716288,
|
||||
369, 7, 3014656, 3145728, 8257536, 8388608, 8519680, 8716288, 8781824,
|
||||
370, 5, 3145728, 3407872, 4784128, 8388608, 8650752,
|
||||
371, 5, 3145728, 4653056, 6160384, 8388608, 8650752,
|
||||
372, 9, 3014656, 3145728, 4653056, 6160384, 8257536, 8454144, 8519680, 8650752, 8781824,
|
||||
373, 6, 1769472, 3145728, 6094848, 8388608, 8519680, 8650752,
|
||||
374, 7, 2097152, 3407872, 4718592, 6029312, 8388608, 8716288, 8847360,
|
||||
375, 6, 6815744, 7012359, 8388608, 8519680, 8650757, 8781824,
|
||||
376, 3, 1966080, 4587520, 8716288,
|
||||
378, 5, 1769472, 4587520, 6029312, 8388608, 8650752,
|
||||
379, 5, 6815744, 7012352, 8388608, 8650752, 8781824,
|
||||
380, 6, 3145728, 4587520, 6029312, 7012352, 8388608, 9830400,
|
||||
382, 5, 3145728, 4587520, 6029312, 7012352, 8650752,
|
||||
383, 6, 3145728, 4653056, 5505024, 6029312, 8126464, 8650752,
|
||||
384, 5, 3145728, 4653056, 6029312, 8650752, 9699328,
|
||||
385, 8, 3145728, 4587520, 4784128, 6094848, 7340032, 8650752, 9699328, 9961472,
|
||||
386, 2, 4587520, 8716288,
|
||||
388, 6, 3080192, 3145728, 8323072, 8388608, 8650752, 9830400,
|
||||
389, 5, 3145728, 3407872, 4784128, 8388608, 8650752,
|
||||
390, 5, 3145728, 3407872, 4653056, 8388608, 8650752,
|
||||
391, 8, 3014656, 3145728, 4653056, 6160384, 8257536, 8388608, 8650752, 9830400,
|
||||
392, 4, 3145728, 4653056, 8388608, 8650752,
|
||||
394, 6, 1769472, 3145728, 6029312, 8388608, 8650752, 9830400,
|
||||
395, 5, 1703936, 1966080, 6946816, 8716288, 9830400,
|
||||
396, 7, 2097152, 3407872, 4784128, 6029312, 7405568, 8388608, 8716288,
|
||||
397, 6, 6815744, 7012352, 7340032, 8388608, 8650752, 9830400,
|
||||
398, 3, 2031616, 4587520, 8716288,
|
||||
400, 5, 1769472, 4587520, 6029312, 8388608, 8650752,
|
||||
401, 5, 6815744, 7012352, 7340032, 8388608, 8650752,
|
||||
};
|
||||
int *bnlist[] {0, 1, 7, 12, 18, 25, 32, 39, 44, 50, 57,
|
||||
63, 71, 76, 82, 87, 95, 102, 106, 113, 120,
|
||||
125, 131, 138, 146, 152, 157, 163, 169, 177, 183,
|
||||
0, 193, 203, 208, 213, 220, 227, 234, 241, 249,
|
||||
256, 265, 273, 279, 286, 294, 303, 312, 321, 330,
|
||||
338, 345, 352, 361, 369, 376, 384, 392, 399, 406,
|
||||
415, 423, 431, 438, 447, 456, 465, 472, 481, 488,
|
||||
496, 504, 511, 517, 524, 532, 541, 549, 555, 562,
|
||||
570, 576, 582, 589, 595, 603, 606, 614, 622, 630,
|
||||
638, 646, 650, 658, 667, 674, 680, 688, 695, 702,
|
||||
707, 717, 723, 731, 739, 745, 752, 760, 768, 773,
|
||||
782, 787, 0, 792, 800, 809, 817, 827, 834, 839,
|
||||
847, 856, 865, 872, 878, 885, 892, 899, 904, 911,
|
||||
917, 925, 932, 938, 943, 952, 962, 975, 985, 995,
|
||||
1003, 1013, 1018, 1027, 1036, 1045, 1054, 1058, 1065, 1071,
|
||||
1078, 1085, 1092, 1101, 1112, 1120, 1128, 1136, 1145, 1152,
|
||||
1161, 1167, 1173, 1179, 1188, 1196, 1205, 1213, 1221, 1226,
|
||||
1235, 1245, 1250, 1257, 1265, 1272, 1279, 1286, 1294, 1303,
|
||||
1310, 1318, 1325, 1331, 1336, 1342, 1347, 1356, 1363, 1370,
|
||||
1376, 1384, 1392, 1401, 1407, 1412, 1419, 1427, 1433, 1439,
|
||||
1446, 1453, 1462, 1468, 1476, 1483, 1490, 1499, 1505, 1513,
|
||||
1522, 1530, 1539, 1547, 1555, 1563, 1571, 1579, 1587, 1594,
|
||||
1601, 1609, 1618, 1624, 1631, 1637, 1645, 1652, 1658, 1666,
|
||||
1675, 1684, 1689, 1697, 1703, 1709, 1716, 1722, 1727, 1735,
|
||||
1740, 1748, 1756, 1765, 1774, 1782, 1790, 1798, 1808, 1815,
|
||||
1822, 1830, 1835, 1843, 1850, 1858, 1866, 1874, 1881, 1889,
|
||||
1898, 1905, 1916, 1923, 1931, 1939, 1944, 1952, 1959, 1966,
|
||||
1975, 1982, 1993, 2001, 2009, 2017, 2025, 2036, 2044, 2052,
|
||||
2061, 2071, 2081, 2089, 2094, 2102, 0, 2111, 2117, 2124,
|
||||
2131, 2137, 2146, 2153, 2161, 2168, 2177, 2185, 2190, 2198,
|
||||
2207, 2214, 2222, 2229, 2236, 2244, 2251, 2260, 2268, 2276,
|
||||
2285, 2293, 2301, 2310, 0, 2318, 2327, 2333, 2341, 2348,
|
||||
2355, 2364, 2370, 2377, 2384, 2389, 2396, 2404, 2410, 2415,
|
||||
2421, 2426, 2434, 2440, 2447, 2452, 2459, 2467, 2475, 2479,
|
||||
2488, 2495, 2503, 2512, 2520, 2528, 0, 0, 0, 0,
|
||||
0, 2534, 2542, 2550, 2557, 2566, 2573, 2583, 2591, 2599,
|
||||
0, 2605, 2612, 2622, 2630, 2637, 2646, 0, 2650, 2659,
|
||||
2666, 2673, 2684, 2692, 2701, 2709, 0, 2714, 2721, 2728,
|
||||
0, 2736, 2743, 2751, 2758, 2768, 0, 2772, 2780, 2787,
|
||||
2794, 2804, 0, 2810, 2818, 2825, 2834, 2842, 0, 2847,
|
||||
2854};
|
||||
int nnodes {401};
|
||||
|
||||
1511
src/as/o/o8.record
Normal file
1511
src/as/o/o8.record
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/as/o/o8.rel
Normal file
BIN
src/as/o/o8.rel
Normal file
Binary file not shown.
68
src/as/o/ob.h
Normal file
68
src/as/o/ob.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#define MAXEXIT 12
|
||||
#define MAXNODE 2200
|
||||
#define NOT_EVAL -1000
|
||||
#include "o.h"
|
||||
|
||||
typedef int rotation;
|
||||
|
||||
struct _exit {
|
||||
int data;
|
||||
|
||||
/* encoded as follows:
|
||||
|
||||
bit 23:17 - position
|
||||
bit 16 - goodness flag
|
||||
bit 15:4 - next bnode (number)
|
||||
bit 3:0 - rotation factor for viewing next node
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
#define getpos(e) (((e)->data>>17) & 0177)
|
||||
#define getnext(e) (((e)->data>>4) & 07777)
|
||||
#define getgood(e) (((e)->data>>16) & 01)
|
||||
#define getrot(e) ((e)->data & 017)
|
||||
|
||||
#define consexit(e,pos,good,rot,next)((e)->data=((((((pos<<1)|good)<<12)|next)<<4)|rot))
|
||||
#define setgood(e) ((e)->data =| (1<<16))
|
||||
|
||||
struct _bnode {
|
||||
int nodenum; /* node number - for identification */
|
||||
int nmoves; /* number of exiting moves */
|
||||
|
||||
# ifdef GENBOOK
|
||||
int eval; /* evaluation (NOT_EVAL if not evalled) */
|
||||
int depth; /* depth of node in search tree */
|
||||
board b; /* current position */
|
||||
color c; /* side to move */
|
||||
# endif
|
||||
|
||||
struct _exit moves[MAXEXIT]; /* the exits */
|
||||
/* must be last */
|
||||
};
|
||||
|
||||
typedef struct _exit exit;
|
||||
typedef struct _bnode bnode;
|
||||
|
||||
# define R0 0
|
||||
# define R90 1
|
||||
# define R180 2
|
||||
# define R270 3
|
||||
# define H0 4
|
||||
# define H90 5
|
||||
# define H180 6
|
||||
# define H270 7
|
||||
# define V0 8
|
||||
# define V90 9
|
||||
# define V180 10
|
||||
# define V270 11
|
||||
|
||||
extern bnode *bnlist[MAXNODE];
|
||||
extern bnode *curbn;
|
||||
extern bnode *bnfind();
|
||||
extern rotation currot;
|
||||
extern int nnodes;
|
||||
extern position movlst[];
|
||||
|
||||
# define forallpos(p,pp) for(pp=movlst;(p = *pp++)>=0;)
|
||||
|
||||
613
src/as/o/ob1.c
Normal file
613
src/as/o/ob1.c
Normal file
@@ -0,0 +1,613 @@
|
||||
#define GENBOOK 1
|
||||
#include "ob.h"
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
bk_read (fd) read book from file
|
||||
bk_write (fd) write book to file
|
||||
bk_parse (fd) read book in readable form
|
||||
bk_print (fd) print book in readable form
|
||||
bk_clear (c) reset to beginning of game
|
||||
bk_move (p) make move at p
|
||||
bk_lookup (t, tp) -> k return current book move(s)
|
||||
|
||||
bk_grow (n) grow n nodes
|
||||
bn_grow (b) grow successors to node b
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
bnode *bnlist[MAXNODE];
|
||||
int nnodes 0;
|
||||
extern bnode *curbn;
|
||||
extern rotation currot;
|
||||
int book[];
|
||||
|
||||
bnode *bnfind(), *extrace();
|
||||
position rotate();
|
||||
|
||||
position movlst[] {
|
||||
pos(3,3), pos(3,4), pos(4,3), pos(4,4),
|
||||
pos(2,3), pos(2,4), pos(3,2), pos(3,5),
|
||||
pos(4,2), pos(4,5), pos(5,3), pos(5,4),
|
||||
pos(7,3), pos(7,4), pos(7,5), pos(7,6),
|
||||
pos(2,2), pos(2,5), pos(5,2), pos(5,5),
|
||||
pos(0,0), pos(0,7), pos(7,0), pos(7,7),
|
||||
pos(0,1), pos(0,2), pos(0,3), pos(0,4),
|
||||
pos(0,5), pos(0,6), pos(1,0), pos(1,7),
|
||||
pos(2,0), pos(2,7), pos(3,0), pos(3,7),
|
||||
pos(4,0), pos(4,7), pos(5,0), pos(5,7),
|
||||
pos(6,0), pos(6,7), pos(7,1), pos(7,2),
|
||||
pos(1,2), pos(1,3), pos(1,4), pos(1,5),
|
||||
pos(2,1), pos(2,6), pos(3,1), pos(3,6),
|
||||
pos(4,1), pos(4,6), pos(5,1), pos(5,6),
|
||||
pos(6,2), pos(6,3), pos(6,4), pos(6,5),
|
||||
pos(1,1), pos(1,6), pos(6,1), pos(6,6),
|
||||
-1
|
||||
};
|
||||
|
||||
bnode *bnalloc ()
|
||||
|
||||
{return (calloc (sizeof (*curbn)/sizeof (0)));}
|
||||
|
||||
bnode *bntrim (bn)
|
||||
bnode *bn;
|
||||
|
||||
{bnode *nn;
|
||||
int save, sz, *d, *s;
|
||||
if (bn->nmoves == MAXEXIT) return (bn);
|
||||
sz = sizeof (bn->moves[0]);
|
||||
save = sz * (MAXEXIT - bn->nmoves);
|
||||
sz = ((sizeof (*curbn) - save)/sizeof(0));
|
||||
nn = calloc (sz);
|
||||
s = bn;
|
||||
d = nn;
|
||||
while (--sz >= 0) *d++ = *s++;
|
||||
bnlist[nn->nodenum] = nn;
|
||||
cfree (bn);
|
||||
return (nn);
|
||||
}
|
||||
|
||||
bnode *bnexpand (bn)
|
||||
bnode *bn;
|
||||
|
||||
{bnode *nn;
|
||||
int save, sz, *d, *s;
|
||||
if (bn->nmoves == MAXEXIT) return (bn);
|
||||
sz = sizeof (bn->moves[0]);
|
||||
save = sz * (MAXEXIT - bn->nmoves);
|
||||
sz = ((sizeof (*curbn) - save)/sizeof(0));
|
||||
nn = calloc (sizeof (*curbn)/sizeof(0));
|
||||
s = bn;
|
||||
d = nn;
|
||||
while (--sz >= 0) *d++ = *s++;
|
||||
bnlist[nn->nodenum] = nn;
|
||||
cfree (bn);
|
||||
return (nn);
|
||||
}
|
||||
|
||||
bnode *bnuniq (b, pr)
|
||||
bnode *b;
|
||||
rotation *pr;
|
||||
|
||||
{int i;
|
||||
*pr = R0;
|
||||
for (i=1;i<=nnodes;++i)
|
||||
{bnode *ob;
|
||||
ob = bnlist[i];
|
||||
if (ob == b) return (ob);
|
||||
if (ob)
|
||||
{rotation r;
|
||||
if ((r = bncompare (b, ob)) >= 0)
|
||||
{*pr = r;
|
||||
cfree (b);
|
||||
return (ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
b->nodenum = ++nnodes;
|
||||
bnlist[nnodes] = b;
|
||||
return (bntrim (b));
|
||||
}
|
||||
|
||||
rotation bncompare (b1, b2)
|
||||
bnode *b1, *b2;
|
||||
|
||||
{rotation r;
|
||||
int *bd1, *bd2;
|
||||
if (b1->c != b2->c) return (-1);
|
||||
bd1 = b1->b;
|
||||
bd2 = b2->b;
|
||||
if (bscore (bd1, WHITE) != bscore (bd2, WHITE)) return (-1);
|
||||
if (bscore (bd1, BLACK) != bscore (bd2, BLACK)) return (-1);
|
||||
for (r=0;r<12;++r) if (brcomp (bd1, bd2, r)) return (r);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int brcomp (b1, b2, r)
|
||||
board b1, b2;
|
||||
rotation r;
|
||||
|
||||
{position p, *pp;
|
||||
forallpos (p, pp)
|
||||
if (b1[p] != b2[rotate(p,r)]) return (FALSE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
# ifdef GENBOOK
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
bk_grow
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
bk_grow (n)
|
||||
|
||||
{int depth, count;
|
||||
if (nnodes == 0)
|
||||
{int i;
|
||||
bnode *b;
|
||||
b = bnalloc ();
|
||||
clrbrd (b->b);
|
||||
b->c = BLACK;
|
||||
b->nmoves = 0;
|
||||
b->depth = 1;
|
||||
b->eval = NOT_EVAL;
|
||||
bnuniq (b, &i);
|
||||
}
|
||||
depth = 1;
|
||||
count = 0;
|
||||
show (count);
|
||||
while (TRUE)
|
||||
{int i;
|
||||
bnode *b;
|
||||
for (i=1;i<=nnodes;++i)
|
||||
{b = bnlist[i];
|
||||
if (b && b->depth == depth && b->nmoves == 0)
|
||||
{bn_grow (b);
|
||||
++count;
|
||||
show (count);
|
||||
if (count >= n) return;
|
||||
if ((count%10)==0) savbook ();
|
||||
}
|
||||
}
|
||||
if (count == 0 && depth == 12) return;
|
||||
++depth;
|
||||
}
|
||||
}
|
||||
|
||||
bk_eval (n)
|
||||
|
||||
{int i, count;
|
||||
|
||||
count = 0;
|
||||
show (count);
|
||||
for (i=1;i<=nnodes;++i)
|
||||
{bnode *b;
|
||||
b = bnfind (i);
|
||||
if (b && b->eval == NOT_EVAL && b->nmoves==0)
|
||||
{b->eval = geval (b->b, b->c);
|
||||
++count;
|
||||
show (count);
|
||||
if (count >= n) return;
|
||||
if ((count%10)==0) savbook ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bk_clean ()
|
||||
|
||||
{int i;
|
||||
|
||||
for (i=1;i<=nnodes;++i)
|
||||
{bnode *b;
|
||||
b = bnfind (i);
|
||||
if (b) b->eval = NOT_EVAL;
|
||||
}
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
static int wrcount;
|
||||
|
||||
bk_write (fd)
|
||||
int fd;
|
||||
|
||||
{int i, maxn, o[MAXNODE];
|
||||
maxn = 0;
|
||||
wrcount = 1;
|
||||
cprint (fd, "int book[] {0, ");
|
||||
for (i=1;i<=nnodes;++i)
|
||||
{bnode *bn;
|
||||
o[i] = wrcount;
|
||||
bn = bnfind (i);
|
||||
if (bn && bn->nmoves>0)
|
||||
{bn_write (bn, fd);
|
||||
maxn = i;
|
||||
}
|
||||
}
|
||||
cprint (fd, "};\nint *bnlist[] {0, ");
|
||||
for (i=1;i<=maxn;++i)
|
||||
{bnode *bn;
|
||||
bn = bnfind (i);
|
||||
if (bn && bn->nmoves>0)
|
||||
cprint (fd, "%d", o[i]);
|
||||
else cprint (fd, "0");
|
||||
if (i < maxn)
|
||||
{if ((i%10) == 0) cprint (fd, ",\n");
|
||||
else cprint (fd, ", ");
|
||||
}
|
||||
}
|
||||
cprint (fd, "};\n");
|
||||
cprint (fd, "int nnodes {%d};\n", maxn);
|
||||
}
|
||||
|
||||
bn_write (bn, fd)
|
||||
bnode *bn;
|
||||
|
||||
{int i;
|
||||
|
||||
cprint (fd, "%d, %d", bn->nodenum, bn->nmoves);
|
||||
wrcount =+ 2;
|
||||
for (i=0;i<bn->nmoves;++i)
|
||||
{exit *e, temp;
|
||||
bnode *b;
|
||||
int next, sz, *p;
|
||||
e = &bn->moves[i];
|
||||
next = getnext(e);
|
||||
b = bnfind (next);
|
||||
if (!b || b->nmoves == 0) next = 0;
|
||||
{position ep;
|
||||
rotation er;
|
||||
int eg;
|
||||
ep = getpos (e);
|
||||
er = getrot (e);
|
||||
eg = getgood (e);
|
||||
consexit (&temp, ep, eg, er, next);
|
||||
}
|
||||
p = &temp;
|
||||
sz = sizeof(temp)/sizeof(0);
|
||||
while (--sz >= 0)
|
||||
{cprint (fd, ", %d", *p++);
|
||||
++wrcount;
|
||||
}
|
||||
}
|
||||
cprint (fd, ",\n");
|
||||
}
|
||||
|
||||
bk_print (fd)
|
||||
int fd;
|
||||
|
||||
{int i;
|
||||
for (i=1;i<=nnodes;++i)
|
||||
{bnode *bn;
|
||||
bn = bnfind (i);
|
||||
if (bn) bn_print (bn, fd);
|
||||
}
|
||||
}
|
||||
|
||||
bn_print (b, fd)
|
||||
bnode *b;
|
||||
|
||||
{int j, nmoves;
|
||||
#ifdef GENBOOK
|
||||
if (b->depth==0) return;
|
||||
#endif
|
||||
cprint (fd, "%3d: ", b->nodenum);
|
||||
j = b->eval;
|
||||
if (j != NOT_EVAL)
|
||||
cprint (fd, "[%d] ", j);
|
||||
nmoves = b->nmoves;
|
||||
for (j=0;j<nmoves;++j)
|
||||
{exit *e;
|
||||
e = &b->moves[j];
|
||||
cprint (fd, " ");
|
||||
prpos (getpos(e), fd);
|
||||
if (getrot(e) != R0)
|
||||
{cprint (fd, " ");
|
||||
prrot (getrot(e), fd);
|
||||
}
|
||||
cprint (fd, " %d", getnext(e));
|
||||
if (getgood(e)) cprint (fd, "g");
|
||||
if (j<nmoves-1) cprint (fd, ",");
|
||||
}
|
||||
cprint (fd, ";\n");
|
||||
}
|
||||
|
||||
bk_parse (fd)
|
||||
int fd;
|
||||
|
||||
{while (bn_parse (fd));
|
||||
# ifdef GENBOOK
|
||||
bkfixup ();
|
||||
# endif
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
parse bnode
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int bn_parse (fd)
|
||||
int fd;
|
||||
|
||||
{int bnum, i;
|
||||
bnode *b;
|
||||
|
||||
bnum = scani (fd);
|
||||
if (bnum<0) return (FALSE);
|
||||
b = bnalloc ();
|
||||
b->nodenum = bnum;
|
||||
if (bnum > nnodes) nnodes = bnum;
|
||||
bnlist[bnum] = b;
|
||||
b->nmoves = 0;
|
||||
b->eval = NOT_EVAL;
|
||||
# ifdef GENBOOK
|
||||
b->depth = 0;
|
||||
b->c = EMPTY;
|
||||
# endif
|
||||
if (scanc (fd, ':') == FALSE) return (FALSE);
|
||||
if (scanc (fd, '['))
|
||||
{b->eval = scani (fd);
|
||||
scanc (fd, ']');
|
||||
}
|
||||
i = 0;
|
||||
while (bkpex (fd, b, i)) ++i;
|
||||
bntrim (b);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
parse exit
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int bkpex (fd, b, i)
|
||||
int fd;
|
||||
bnode *b;
|
||||
int i;
|
||||
|
||||
{position p;
|
||||
rotation r;
|
||||
int bnnum;
|
||||
|
||||
p = scanpos (fd);
|
||||
if (p>=0)
|
||||
{r = scanrot (fd);
|
||||
bnnum = scani (fd);
|
||||
if (bnnum>=0)
|
||||
{int good;
|
||||
good = scanc (fd, 'g');
|
||||
consexit (&b->moves[i],p,good,r,bnnum);
|
||||
++b->nmoves;
|
||||
if (scanc (fd, ',')) return (TRUE);
|
||||
}
|
||||
}
|
||||
skipc (fd, ';');
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
skipc - skip to a character
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
skipc (fd, match)
|
||||
int fd;
|
||||
char match;
|
||||
|
||||
{int c;
|
||||
while (TRUE)
|
||||
{c = cgetc (fd);
|
||||
if (c <= 0 && ceof (fd)) return;
|
||||
if (c == match) return;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
scanc - scan for a character
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int scanc (fd, match)
|
||||
int fd;
|
||||
char match;
|
||||
|
||||
{int c;
|
||||
c = skipb (fd);
|
||||
if (c==match) return (TRUE);
|
||||
ungetc (c, fd);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
skipb - skip blanks
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int skipb (fd)
|
||||
|
||||
{int c;
|
||||
while (TRUE)
|
||||
{c = cgetc (fd);
|
||||
if (c<=0 && ceof(fd)) return (0);
|
||||
if (c==' ' || c=='\t' || c=='\n') continue;
|
||||
return (c);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
skipw - skip a word and its terminator
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
skipw (fd)
|
||||
|
||||
{int c;
|
||||
while (TRUE)
|
||||
{c = cgetc (fd);
|
||||
if (c<=0 && ceof(fd)) return;
|
||||
if (c==' ' || c=='\t' || c=='\n') return;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
scani - read an integer
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
int scani (fd)
|
||||
int fd;
|
||||
|
||||
{int c, sum, negflag;
|
||||
sum = -1;
|
||||
|
||||
negflag = FALSE;
|
||||
c = skipb (fd);
|
||||
if (c == '-')
|
||||
{negflag = TRUE;
|
||||
c = cgetc (fd);
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
{sum = 0;
|
||||
while (c >= '0' && c <= '9')
|
||||
{sum = (sum * 10) + c-'0';
|
||||
c = cgetc (fd);
|
||||
}
|
||||
if (negflag) sum = -sum;
|
||||
}
|
||||
if (c > 0) ungetc (c, fd);
|
||||
return (sum);
|
||||
}
|
||||
|
||||
position scanpos (fd)
|
||||
int fd;
|
||||
|
||||
{int x, y;
|
||||
if (scanc (fd, 'f'))
|
||||
{skipw (fd);
|
||||
return (0);
|
||||
}
|
||||
x = scani (fd);
|
||||
if (x<0) return (-1);
|
||||
if (scanc (fd, '-') == FALSE) return (-1);
|
||||
y = scani (fd);
|
||||
if (y<0) return (-1);
|
||||
return (pos (x-1, y-1));
|
||||
}
|
||||
|
||||
prpos (p, fd)
|
||||
position p;
|
||||
|
||||
{if (p==0) cprint (fd, "forfeit");
|
||||
else cprint (fd, "%d-%d",posx(p)+1,posy(p)+1);
|
||||
}
|
||||
|
||||
rotation scanrot (fd)
|
||||
int fd;
|
||||
|
||||
{if (scanc (fd, 'r'))
|
||||
return (scani (fd)/90);
|
||||
if (scanc (fd, 'h'))
|
||||
return (4 + scani (fd)/90);
|
||||
if (scanc (fd, 'v'))
|
||||
return (8 + scani (fd)/90);
|
||||
return (0);
|
||||
}
|
||||
|
||||
prrot (r, fd)
|
||||
rotation r;
|
||||
|
||||
{switch (r/4) {
|
||||
case 0: cprint (fd, "r"); break;
|
||||
case 1: cprint (fd, "h"); break;
|
||||
case 2: cprint (fd, "v"); break;
|
||||
}
|
||||
cprint (fd, "%d", 90*(r%4));
|
||||
}
|
||||
|
||||
# ifdef GENBOOK
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
bn_grow (b)
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
bn_grow (b)
|
||||
bnode *b;
|
||||
|
||||
{position p, *pp;
|
||||
if (b->nmoves > 0) return;
|
||||
b = bnexpand (b);
|
||||
forallpos (p, pp) if (!adjcorner(p) && ismove (b->b, b->c, p))
|
||||
{bnode *nb;
|
||||
rotation r;
|
||||
if (b->nmoves == MAXEXIT)
|
||||
{cprint ("Node %d too many exits.\n", b->nodenum);
|
||||
return;
|
||||
}
|
||||
nb = bnalloc ();
|
||||
nb->depth = b->depth + 1;
|
||||
nb->c = oppcolor (b->c);
|
||||
nb->nmoves = 0;
|
||||
nb->eval = NOT_EVAL;
|
||||
cpybrd (nb->b, b->b);
|
||||
putmov (nb->b, b->c, p);
|
||||
nb = bnuniq (nb, &r);
|
||||
consexit (&b->moves[b->nmoves],p,FALSE,r,nb->nodenum);
|
||||
++b->nmoves;
|
||||
}
|
||||
bntrim (b);
|
||||
}
|
||||
|
||||
bkfixup ()
|
||||
|
||||
{board b;
|
||||
clrbrd (b);
|
||||
bkfxnode (bnfind (1), 1, b, BLACK);
|
||||
}
|
||||
|
||||
bkfxnode (bn, depth, b, c)
|
||||
bnode *bn;
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{int i;
|
||||
color o;
|
||||
if (bn == 0) return;
|
||||
if (bn->c != EMPTY) return;
|
||||
if (bn->depth != 0) return;
|
||||
bn->c = c;
|
||||
bn->depth = depth;
|
||||
cpybrd (bn->b, b);
|
||||
++depth;
|
||||
o = oppcolor (c);
|
||||
i = bn->nmoves;
|
||||
while (--i >= 0) if (getrot(&bn->moves[i]) == R0)
|
||||
{board a;
|
||||
position p;
|
||||
bnode *next;
|
||||
p = getpos (&bn->moves[i]);
|
||||
if (!ismove (b, c, p))
|
||||
{cprint ("Node %d move at ");
|
||||
prpos (p);
|
||||
cprint (" is not legal.\n");
|
||||
return;
|
||||
}
|
||||
cpybrd (a, b);
|
||||
putmov (a, c, p);
|
||||
next = extrace (bn, i);
|
||||
bkfxnode (next, depth, a, o);
|
||||
}
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
BIN
src/as/o/ob1.rel
Normal file
BIN
src/as/o/ob1.rel
Normal file
Binary file not shown.
107
src/as/o/ob2.c
Normal file
107
src/as/o/ob2.c
Normal file
@@ -0,0 +1,107 @@
|
||||
#define GENBOOK 1
|
||||
#include "ob.h"
|
||||
|
||||
int gmdepth 0;
|
||||
int gmmdepth 4;
|
||||
|
||||
int geval (b,c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{color o;
|
||||
o = oppcolor (c);
|
||||
return (gmeval (b,c,o));
|
||||
}
|
||||
|
||||
int gmeval (b,c,o)
|
||||
board b;
|
||||
color c, o;
|
||||
|
||||
{int myscore;
|
||||
if (++gmdepth == gmmdepth) myscore = gseval (b,c);
|
||||
else
|
||||
{register position *pp, p;
|
||||
myscore = -1000;
|
||||
forallpos (p, pp) if (ismove (b,c,p))
|
||||
{register int temp;
|
||||
board a;
|
||||
cpybrd (a,b);
|
||||
putmov (a,c,p);
|
||||
temp = -gmeval(a,o,c);
|
||||
if (temp>myscore) myscore=temp;
|
||||
}
|
||||
}
|
||||
--gmdepth;
|
||||
return (myscore);
|
||||
}
|
||||
|
||||
gseval (b, c)
|
||||
board b;
|
||||
color c;
|
||||
|
||||
{color o;
|
||||
position p, *pp;
|
||||
int nmymoves, nopmoves, s, myscore;
|
||||
|
||||
o = oppcolor (c);
|
||||
s = -1;
|
||||
nopmoves = nmymoves = 0;
|
||||
forallpos (p, pp)
|
||||
{if (ismove (b,c,p))
|
||||
{register int temp;
|
||||
temp = sqeval (b,c,o,p);
|
||||
if (temp > 2 && temp != 5) /* count only good moves */
|
||||
{++nmymoves;
|
||||
if (edge (p)) nmymoves=+2; /* count edges higher */
|
||||
}
|
||||
}
|
||||
if (ismove (b,o,p))
|
||||
{register int temp;
|
||||
temp = sqeval (b,o,c,p);
|
||||
if (temp > 2 && temp != 5) /* count only good moves */
|
||||
{++nopmoves;
|
||||
if (edge (p)) nopmoves=+2; /* count edges higher */
|
||||
}
|
||||
if (temp>s) {s=temp;}
|
||||
}
|
||||
}
|
||||
myscore = nmymoves-nopmoves;
|
||||
if (nmymoves<6) myscore =- (6-nmymoves)*2;
|
||||
if (nopmoves<6) myscore =+ (6-nopmoves)*2;
|
||||
if (s == CORNERVALUE) myscore =- 100;
|
||||
return (myscore);
|
||||
}
|
||||
|
||||
bkminimax ()
|
||||
|
||||
{bkmxnode (bnfind (1));
|
||||
}
|
||||
|
||||
bkmxnode (bn)
|
||||
bnode *bn;
|
||||
|
||||
{int i, myscore;
|
||||
if (bn == 0) return;
|
||||
i = bn->nmoves;
|
||||
if (i == 0) return;
|
||||
myscore = NOT_EVAL;
|
||||
while (--i >= 0)
|
||||
{bnode *next;
|
||||
int temp;
|
||||
next = extrace (bn, i);
|
||||
bkmxnode (next);
|
||||
temp = -(next->eval);
|
||||
if (temp > myscore) myscore = temp;
|
||||
}
|
||||
bn->eval = myscore;
|
||||
i = bn->nmoves;
|
||||
while (--i >= 0)
|
||||
{bnode *next;
|
||||
int temp;
|
||||
next = extrace (bn, i);
|
||||
temp = -(next->eval);
|
||||
if (temp == myscore) setgood (&bn->moves[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BIN
src/as/o/ob2.rel
Normal file
BIN
src/as/o/ob2.rel
Normal file
Binary file not shown.
2
src/as/o/ob3.c
Normal file
2
src/as/o/ob3.c
Normal file
@@ -0,0 +1,2 @@
|
||||
#define GENBOOK 1
|
||||
#include "obk.code"
|
||||
BIN
src/as/o/ob3.rel
Normal file
BIN
src/as/o/ob3.rel
Normal file
Binary file not shown.
151
src/as/o/obk.code
Normal file
151
src/as/o/obk.code
Normal file
@@ -0,0 +1,151 @@
|
||||
#include "ob.h"
|
||||
|
||||
extern bnode *bnlist[MAXNODE];
|
||||
extern int nnodes;
|
||||
bnode *curbn;
|
||||
bnode *bnfind();
|
||||
rotation currot;
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
rotation code
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
position rotate (p, r)
|
||||
position p;
|
||||
rotation r;
|
||||
|
||||
{int x, y;
|
||||
|
||||
x = posx (p);
|
||||
y = posy (p);
|
||||
switch (r/4) {
|
||||
case 0: break;
|
||||
case 1: y = 7 - y; break;
|
||||
case 2: x = 7 - x; break;
|
||||
default: cprint ("bad flip");
|
||||
}
|
||||
r =% 4;
|
||||
while (--r >= 0)
|
||||
{int temp;
|
||||
temp = y;
|
||||
y = 7 - x;
|
||||
x = temp;
|
||||
}
|
||||
return (pos (x, y));
|
||||
}
|
||||
|
||||
rotation rotadd (r1, r2)
|
||||
rotation r1, r2;
|
||||
|
||||
{int flip1, flip2;
|
||||
|
||||
if (r1 == R0) return (r2);
|
||||
if (r2 == R0) return (r1);
|
||||
flip1 = r1 / 4;
|
||||
r1 = r1 % 4;
|
||||
flip2 = r2 / 4;
|
||||
r2 = r2 % 4;
|
||||
if (flip2==0)
|
||||
return (flip1*4 + ((r1 + r2) % 4));
|
||||
if ((r1 % 2) != 0) flip2 = oppflip (flip2);
|
||||
return (rotadd (flipadd (flip1, flip2), (r1 + r2) % 4));
|
||||
}
|
||||
|
||||
rotation flipadd (f1, f2)
|
||||
|
||||
{if (f1 == f2) return (R0);
|
||||
if (f1 == 0) return (f2*4);
|
||||
if (f2 == 0) return (f1*4);
|
||||
return (R180);
|
||||
}
|
||||
|
||||
int oppflip (f1)
|
||||
|
||||
{if (f1 == 0) return (0);
|
||||
return (3 - f1);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
bk_clear
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
bk_init ()
|
||||
|
||||
{int i;
|
||||
extern int book[];
|
||||
for (i=1;i<nnodes;++i)
|
||||
{int o;
|
||||
o = bnlist[i];
|
||||
if (o) bnlist[i] = book+o;
|
||||
}
|
||||
}
|
||||
|
||||
bk_clear (c)
|
||||
color c;
|
||||
|
||||
{curbn = bnfind (1);
|
||||
currot = R0;
|
||||
if (c == WHITE) currot = V0;
|
||||
}
|
||||
|
||||
bk_flush ()
|
||||
|
||||
{curbn = 0;
|
||||
}
|
||||
|
||||
position bkmvn (n)
|
||||
|
||||
{return (rotate (getpos (&curbn->moves[n]), currot));}
|
||||
|
||||
bk_move (p)
|
||||
|
||||
{bnode *extrace ();
|
||||
if (curbn)
|
||||
{int n;
|
||||
n = curbn->nmoves;
|
||||
while (--n >= 0)
|
||||
{if (p == bkmvn (n))
|
||||
{currot = rotadd (getrot (&curbn->moves[n]), currot);
|
||||
curbn = extrace (curbn, n);
|
||||
return;
|
||||
}
|
||||
}
|
||||
curbn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bnode *extrace (bn, n)
|
||||
bnode *bn;
|
||||
|
||||
{return (bnfind (getnext (&bn->moves[n])));
|
||||
}
|
||||
|
||||
int bk_lookup (t, tp)
|
||||
struct mt t[64], *tp[64];
|
||||
|
||||
{int n, k;
|
||||
if (curbn == 0) return (0);
|
||||
|
||||
k = 0;
|
||||
n = curbn->nmoves;
|
||||
while (--n >= 0)
|
||||
{if (getgood (&curbn->moves[n]))
|
||||
{t[k].p = bkmvn (n);
|
||||
tp[k] = &t[k];
|
||||
++k;
|
||||
}
|
||||
}
|
||||
return (k);
|
||||
}
|
||||
|
||||
bnode *bnfind (n)
|
||||
|
||||
{if (n>0 && n<=nnodes) return (bnlist[n]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
191
src/as/o/obktst.c
Normal file
191
src/as/o/obktst.c
Normal file
@@ -0,0 +1,191 @@
|
||||
#include "o.h"
|
||||
#include "c/c.defs"
|
||||
int eflag 0, debug 0, endgame 0, stdout, printf, fprintf;
|
||||
int movnum 15;
|
||||
int mvnhack 1;
|
||||
int handicap 0;
|
||||
|
||||
#define USNAME 016
|
||||
static int oldsname;
|
||||
extern int cin, cout;
|
||||
|
||||
main ()
|
||||
|
||||
{oldsname = rsuset (USNAME);
|
||||
rdbook ("book");
|
||||
while (TRUE) docommand ();
|
||||
}
|
||||
|
||||
rdbook (s)
|
||||
char *s;
|
||||
|
||||
{int fd;
|
||||
fd = xopen (s, 'r');
|
||||
if (fd <= 0) return;
|
||||
bk_parse (fd);
|
||||
cclose (fd);
|
||||
}
|
||||
|
||||
int xopen (fname, mode)
|
||||
char *fname;
|
||||
|
||||
{int fd, temp;
|
||||
temp = rsuset (USNAME);
|
||||
wsuset (USNAME, oldsname);
|
||||
fd = copen (fname, mode);
|
||||
wsuset (USNAME, temp);
|
||||
return (fd);
|
||||
}
|
||||
|
||||
int xdelete (fname)
|
||||
char *fname;
|
||||
|
||||
{int temp;
|
||||
temp = rsuset (USNAME);
|
||||
wsuset (USNAME, oldsname);
|
||||
delete (fname);
|
||||
wsuset (USNAME, temp);
|
||||
}
|
||||
|
||||
savbook ()
|
||||
|
||||
{int fd, n;
|
||||
filespec fs;
|
||||
char *itoa ();
|
||||
static char fnbuf[20] {'b', 'o', 'o', 'k', '.'};
|
||||
|
||||
fd = xopen ("book", 'w');
|
||||
if (fd <= 0) {cprint ("Can't save book.\n"); cexit ();}
|
||||
filnam (itschan (fd), &fs);
|
||||
c6tos (fs.fn2, fnbuf+5);
|
||||
n = atoi (fnbuf+5);
|
||||
bk_print (fd);
|
||||
cclose (fd);
|
||||
n = n - 4;
|
||||
itoa (n, fnbuf+5);
|
||||
xdelete (fnbuf);
|
||||
}
|
||||
|
||||
docommand ()
|
||||
|
||||
{int c;
|
||||
putchar ('%');
|
||||
c = utyi ();
|
||||
switch (c) {
|
||||
case 'g': cprint ("Grow tree\n"); dogrow (); break;
|
||||
case 'e': cprint ("Evaluate\n"); doeval (); break;
|
||||
case 'f': cprint ("Flush evaluations\n"); doflush (); break;
|
||||
case 'm': cprint ("Minimax\n"); bkminimax(); break;
|
||||
case 't': cprint ("Test moves\n"); testmoves(); return;
|
||||
case 'w': cprint ("Write tree\n"); dowrite(); return;
|
||||
default: putchar ('?'); return;
|
||||
}
|
||||
savbook ();
|
||||
}
|
||||
|
||||
dowrite ()
|
||||
|
||||
{int fd;
|
||||
fd = xopen ("cbook", 'w');
|
||||
if (fd != OPENLOSS)
|
||||
{bk_write (fd);
|
||||
cclose (fd);
|
||||
}
|
||||
else cprint ("Cant write file\n");
|
||||
}
|
||||
|
||||
dogrow ()
|
||||
|
||||
{int n;
|
||||
cprint ("Enter number of leaf nodes to grow: ");
|
||||
n = scani (cin);
|
||||
if (n<=0) return;
|
||||
bk_grow (n);
|
||||
}
|
||||
|
||||
doeval ()
|
||||
|
||||
{int n;
|
||||
cprint ("Enter number of leaf nodes to evaluate: ");
|
||||
n = scani (cin);
|
||||
if (n<=0) return;
|
||||
bk_eval (n);
|
||||
}
|
||||
|
||||
doflush ()
|
||||
|
||||
{bk_clean ();
|
||||
}
|
||||
|
||||
show (n)
|
||||
|
||||
{char buf[20];
|
||||
int fd, w;
|
||||
|
||||
fd = copen (buf, 'w', "s");
|
||||
cprint (fd, "%d", n);
|
||||
cclose (fd);
|
||||
w = csto6 (buf);
|
||||
wsuset (USNAME, w);
|
||||
}
|
||||
|
||||
testmoves ()
|
||||
|
||||
{cprint ("Black moving first:\n");
|
||||
bk_clear (BLACK);
|
||||
tmoves (BLACK);
|
||||
cprint ("White moving first:\n");
|
||||
bk_clear (WHITE);
|
||||
tmoves (WHITE);
|
||||
}
|
||||
|
||||
tmoves (c)
|
||||
color c;
|
||||
|
||||
{while (TRUE)
|
||||
{position p;
|
||||
struct mt t[64], *tp[64];
|
||||
int k, i;
|
||||
|
||||
k = bk_lookup (t, tp);
|
||||
if (k == 0)
|
||||
{cprint ("Book has no moves.\n");
|
||||
return;
|
||||
}
|
||||
if (c==BLACK) cprint ("Moves for * are: ");
|
||||
else cprint ("Moves for @ are: ");
|
||||
for (i=0;i<k;++i)
|
||||
{p = tp[i]->p;
|
||||
cprint (" ");
|
||||
prpos (p, cout);
|
||||
cprint (",");
|
||||
}
|
||||
cprint ("\n");
|
||||
cprint ("Move: ");
|
||||
p = scanpos (cin);
|
||||
if (p < 0 || p > 100) return;
|
||||
bk_move (p);
|
||||
c = oppcolor (c);
|
||||
}
|
||||
}
|
||||
|
||||
atoi (s)
|
||||
char *s;
|
||||
|
||||
{int n, c;
|
||||
n = 0;
|
||||
while (c = *s++) n = (n * 10) + (c - '0');
|
||||
return (n);
|
||||
}
|
||||
|
||||
char *itoa (n, s)
|
||||
char *s;
|
||||
|
||||
{int a;
|
||||
if (n<0) n=0;
|
||||
if (a = (n / 10)) s = itoa (a, s);
|
||||
*s++ = '0' + n%10;
|
||||
*s = 0;
|
||||
return (s);
|
||||
}
|
||||
|
||||
BIN
src/as/o/obktst.rel
Normal file
BIN
src/as/o/obktst.rel
Normal file
Binary file not shown.
12
src/as/o/obktst.stinkr
Normal file
12
src/as/o/obktst.stinkr
Normal file
@@ -0,0 +1,12 @@
|
||||
x c/clib
|
||||
l blt
|
||||
l ismove
|
||||
l o2
|
||||
l o3
|
||||
l o4
|
||||
l o5
|
||||
l obktst
|
||||
l ob1
|
||||
l ob2
|
||||
l ob3
|
||||
o ts obktst
|
||||
167
src/as/o/oprint.c
Normal file
167
src/as/o/oprint.c
Normal file
@@ -0,0 +1,167 @@
|
||||
# include "o.h"
|
||||
|
||||
int movnum;
|
||||
|
||||
# define FORFEIT 1000
|
||||
# define NOMOVE 1001
|
||||
# define ILLEGAL 1002
|
||||
|
||||
main (argc, argv)
|
||||
char *argv[];
|
||||
|
||||
{char *infn, *outfn;
|
||||
int in, out;
|
||||
++argv;
|
||||
--argc;
|
||||
if (argc != 2)
|
||||
{puts ("Usage: oprint in.file out.file");
|
||||
return;
|
||||
}
|
||||
infn = argv[0];
|
||||
outfn = argv[1];
|
||||
in = copen (infn, 'r');
|
||||
if (in == -1)
|
||||
{cprint ("Can't open input: %s\n", infn);
|
||||
return;
|
||||
}
|
||||
out = copen (outfn, 'w');
|
||||
if (out == -1)
|
||||
{cprint ("Can't open output: %s\n", outfn);
|
||||
return;
|
||||
}
|
||||
oprint (in, out);
|
||||
cclose (in);
|
||||
cclose (out);
|
||||
}
|
||||
|
||||
oprint (in, out)
|
||||
|
||||
{board b;
|
||||
|
||||
clrbrd (b);
|
||||
movnum = 1;
|
||||
while (domove (b, in, out));
|
||||
op_score (b, out);
|
||||
}
|
||||
|
||||
domove (b, in, out)
|
||||
board b;
|
||||
|
||||
{position p1, p2;
|
||||
board b1;
|
||||
|
||||
rmovnum (in);
|
||||
p1 = doply (b, in, BLACK);
|
||||
if (p1 == ILLEGAL) return (0);
|
||||
cpybrd (b1, b);
|
||||
if (p1 < FORFEIT) putmov (b1, BLACK, p1);
|
||||
p2 = doply (b1, in, WHITE);
|
||||
if (p2 == ILLEGAL) return (0);
|
||||
prbrds (b, b1, out);
|
||||
prmvs (p1, p2, out);
|
||||
cpybrd (b,b1);
|
||||
if (p2 < FORFEIT) putmov (b, WHITE, p2);
|
||||
++movnum;
|
||||
return (p2 != NOMOVE);
|
||||
}
|
||||
|
||||
position doply (b, in, cc)
|
||||
board b;
|
||||
color cc;
|
||||
|
||||
{int c;
|
||||
position p;
|
||||
|
||||
p = ILLEGAL;
|
||||
c = cgetc (in);
|
||||
if (c <= 0) return (NOMOVE);
|
||||
while (c == ' ' || c == '\t') c = cgetc (in);
|
||||
if (c == 'F' && !anymvs (b, cc)) p = FORFEIT;
|
||||
else if (c == '.' && movnum == 1 && cc == BLACK) p = NOMOVE;
|
||||
else if (c >= '1' && c <= '8')
|
||||
{int x, y;
|
||||
x = c - '1';
|
||||
c = cgetc (in);
|
||||
if (c == '-')
|
||||
{c = cgetc (in);
|
||||
if (c >= '1' && c <= '8')
|
||||
{position p1;
|
||||
y = c - '1';
|
||||
p1 = pos (x, y);
|
||||
if (ismove (b, cc, p1)) p = p1;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (c != ' ' && c != '\n' && c)
|
||||
{if (c == '.')
|
||||
{cgetc (in);
|
||||
cgetc (in);
|
||||
break;
|
||||
}
|
||||
c = cgetc (in);
|
||||
}
|
||||
if (c == '\n' && cc == BLACK) ungetc (0, in);
|
||||
if (p == ILLEGAL) cprint ("Move %d is illegal.\n", movnum);
|
||||
return (p);
|
||||
}
|
||||
|
||||
prbrds (b, b1, out)
|
||||
board b, b1;
|
||||
|
||||
{int x, y;
|
||||
cprint (out, " 1 2 3 4 5 6 7 8\t 1 2 3 4 5 6 7 8\n");
|
||||
for (x=0;x<8;++x)
|
||||
{cprint (out, "%d", x+1);
|
||||
for (y=0;y<8;++y) opsq (b,x,y,out);
|
||||
cprint (out, "\t%d", x+1);
|
||||
for (y=0;y<8;++y) opsq (b1,x,y,out);
|
||||
cputc ('\n', out);
|
||||
}
|
||||
cputc ('\n', out);
|
||||
}
|
||||
|
||||
prmvs (p1, p2, out)
|
||||
position p1, p2;
|
||||
|
||||
{cprint (out, "%d. ", movnum);
|
||||
prmv (p1, out);
|
||||
cprint (out, " ... ");
|
||||
prmv (p2, out);
|
||||
cputc ('\n', out);
|
||||
if ((movnum % 5) == 0) cputc ('\p', out);
|
||||
else cputc ('\n', out);
|
||||
}
|
||||
|
||||
prmv (p, out)
|
||||
position p;
|
||||
|
||||
{switch (p) {
|
||||
case NOMOVE: cprint (out, " "); return;
|
||||
case FORFEIT: cprint (out, "Forfeit"); return;
|
||||
case ILLEGAL: return;
|
||||
}
|
||||
cprint (out, "%d-%d", posx(p)+1, posy(p)+1);
|
||||
}
|
||||
|
||||
opsq (b, x, y, out)
|
||||
board b;
|
||||
position x, y;
|
||||
|
||||
{register int z;
|
||||
extern char pcolor[];
|
||||
cputc (' ', out);
|
||||
z = b[pos(x,y)];
|
||||
if (z<=2) z = pcolor[z];
|
||||
cputc(z,out);
|
||||
}
|
||||
|
||||
rmovnum (in)
|
||||
|
||||
{int c;
|
||||
c = cgetc (in);
|
||||
while (c != ' ' && c != '\t' && c) c = cgetc (in);
|
||||
}
|
||||
|
||||
op_score (b, out)
|
||||
{;}
|
||||
|
||||
BIN
src/as/o/oprint.rel
Normal file
BIN
src/as/o/oprint.rel
Normal file
Binary file not shown.
10
src/as/o/oprint.stinkr
Normal file
10
src/as/o/oprint.stinkr
Normal file
@@ -0,0 +1,10 @@
|
||||
x c/clib
|
||||
l blt
|
||||
l ismove
|
||||
l o2
|
||||
l o3
|
||||
l o4
|
||||
l o5
|
||||
l oprint
|
||||
o ts oprint
|
||||
|
||||
577
src/as/o/ostat.c
Normal file
577
src/as/o/ostat.c
Normal file
@@ -0,0 +1,577 @@
|
||||
# include "c/c.defs"
|
||||
# include "c/its.bits"
|
||||
# define MAXUSER 300
|
||||
# define FNSIZE 40
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
Incremental Statistics Generator -- Othello
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
The following code is per-program:
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
# define BUFSIZ 20
|
||||
# define statfilename "/c/_ o.stat"
|
||||
# define sumfilename "/common/o.stats"
|
||||
# define accfilename "/dm/c/_ o. state"
|
||||
# define oldfilename "/dm/c/_ o.ostat"
|
||||
|
||||
char *mlist[] {
|
||||
"dm",
|
||||
"ml",
|
||||
"ai",
|
||||
"mc"
|
||||
};
|
||||
|
||||
int pflag {TRUE}; /* default is to print accumulated stats */
|
||||
|
||||
struct _stat {
|
||||
int name; /* user name - in SIXBIT */
|
||||
int user; /* user score */
|
||||
int machine; /* machine score */
|
||||
int hcap; /* handicap */
|
||||
int aflag; /* too much help? */
|
||||
int color; /* either 0, 1=*, or 2=@ */
|
||||
};
|
||||
|
||||
struct _user {
|
||||
int name; /* must be first */
|
||||
int total;
|
||||
int totalpercent;
|
||||
int won[3];
|
||||
int cheat[3];
|
||||
int lost[3];
|
||||
int drawn[3];
|
||||
int percent[3]; /* must be last */
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
The following code is common.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
typedef struct _stat stat;
|
||||
typedef struct _user user;
|
||||
|
||||
user usertab[MAXUSER], *cuser, *euser;
|
||||
extern int cout;
|
||||
cal thetime;
|
||||
int usersize;
|
||||
int changed;
|
||||
|
||||
main (argc, argv)
|
||||
char *argv[];
|
||||
|
||||
{int addstat(), wsummary();
|
||||
if (!wizard())
|
||||
{cprint ("Please do not run this program;\n");
|
||||
cprint ("you may screw up a permanent data base.\n");
|
||||
cprint ("Thank you for your cooperation.\n");
|
||||
return;
|
||||
}
|
||||
now (&thetime);
|
||||
usersize = sizeof (*cuser) / sizeof (pflag);
|
||||
changed = FALSE;
|
||||
cuser = usertab;
|
||||
euser = usertab+MAXUSER;
|
||||
if (argc>1 && stcmp (argv[1], "-p")) pflag = !pflag;
|
||||
foreach (addstat);
|
||||
if (!changed)
|
||||
{cprint ("No recent statistics.\n");
|
||||
rdacc ();
|
||||
sortuser ();
|
||||
}
|
||||
foreach (wsummary);
|
||||
if (pflag) wfacc (cout, FALSE);
|
||||
}
|
||||
|
||||
foreach (f)
|
||||
int (*f)();
|
||||
|
||||
{int n;
|
||||
char **p;
|
||||
n = sizeof(mlist)/sizeof(mlist[0]);
|
||||
p = mlist;
|
||||
while (--n >= 0)
|
||||
(*f)(*p++);
|
||||
}
|
||||
|
||||
wsummary (s) char *s;
|
||||
|
||||
{char *t, buf[FNSIZE];
|
||||
t = stcpy ("/", buf);
|
||||
t = stcpy (s, t);
|
||||
stcpy (sumfilename, t);
|
||||
wfnacc (buf, FALSE);
|
||||
}
|
||||
|
||||
char stfname[FNSIZE];
|
||||
|
||||
int wizard ()
|
||||
|
||||
{int xuname, option;
|
||||
xuname = rsuset (UXUNAME);
|
||||
option = rsuset (UOPTION);
|
||||
return (!(option & (010000<<18)) & (xuname == csto6 ("AS")));
|
||||
}
|
||||
|
||||
addstat (s) char *s;
|
||||
|
||||
{char *t;
|
||||
t = stcpy ("/", stfname);
|
||||
t = stcpy (s, t);
|
||||
stcpy (statfilename, t);
|
||||
if (yexists ()) /* if YSTAT file exists */
|
||||
{apy2o (s); /* append YSTAT file to OSTAT file */
|
||||
dely (); /* delete YSTAT file */
|
||||
changed = TRUE;
|
||||
}
|
||||
if (!xexists ()) /* if XSTAT file doesn't exist */
|
||||
{rns2x (); /* rename STAT file to XSTAT */
|
||||
if (!xexists ()) /* if XSTAT file doesn't exist */
|
||||
return;
|
||||
}
|
||||
changed = TRUE;
|
||||
rdacc (); /* read accumulated stats */
|
||||
rdxstat (); /* read XSTAT file - add to acc stats */
|
||||
sortuser (); /* sort accumulated stats */
|
||||
wfnacc (accfilename, TRUE); /* update accumulated stats */
|
||||
rnx2y (); /* rename XSTAT file to YSTAT file */
|
||||
apy2o (s); /* print YSTAT and append to OSTAT file */
|
||||
dely (); /* delete YSTAT file */
|
||||
}
|
||||
|
||||
int xexists ()
|
||||
|
||||
{char buf[FNSIZE];
|
||||
int fd;
|
||||
apfname (buf, stfname, "xstat");
|
||||
fd = copen (buf, 'r');
|
||||
if (fd != OPENLOSS)
|
||||
{cclose (fd);
|
||||
return (TRUE);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int yexists ()
|
||||
|
||||
{char buf[FNSIZE];
|
||||
int fd;
|
||||
apfname (buf, stfname, "ystat");
|
||||
fd = copen (buf, 'r');
|
||||
if (fd != OPENLOSS)
|
||||
{cclose (fd);
|
||||
return (TRUE);
|
||||
}
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
rns2x ()
|
||||
|
||||
{char buf[FNSIZE];
|
||||
apfname (buf, stfname, "xstat");
|
||||
rename (stfname, buf);
|
||||
}
|
||||
|
||||
rnx2y ()
|
||||
|
||||
{char buf1[FNSIZE], buf2[FNSIZE];
|
||||
apfname (buf1, stfname, "xstat");
|
||||
apfname (buf2, stfname, "ystat");
|
||||
rename (buf1, buf2);
|
||||
}
|
||||
|
||||
rdacc ()
|
||||
|
||||
{int fd, rc;
|
||||
|
||||
fd = copen (accfilename, 'r');
|
||||
if (fd == OPENLOSS)
|
||||
{cprint ("Can't read stats file: %s\n", accfilename);
|
||||
cexit (1);
|
||||
}
|
||||
rc = rdfacc (fd);
|
||||
cclose (fd);
|
||||
if (rc)
|
||||
{cprint ("Error in reading stats file: %s\n", accfilename);
|
||||
cexit (1);
|
||||
}
|
||||
}
|
||||
|
||||
rdxstat ()
|
||||
|
||||
{int fd, n, unk;
|
||||
char buf[FNSIZE];
|
||||
stat cstat;
|
||||
|
||||
apfname (buf, stfname, "xstat");
|
||||
fd = copen (buf, 'r');
|
||||
if (fd == OPENLOSS)
|
||||
{cprint ("Cant open %s\n", buf);
|
||||
cexit (1);
|
||||
}
|
||||
n = 0;
|
||||
unk = csto6 ("?");
|
||||
while (!ceof (fd))
|
||||
{++n;
|
||||
if (rdstat (fd, &cstat)) continue;
|
||||
if (cstat.name == unk)
|
||||
cprint ("File %s stat %d unknown user\n", buf, n);
|
||||
enterstat (&cstat);
|
||||
}
|
||||
cclose (fd);
|
||||
}
|
||||
|
||||
wfnacc (s, full)
|
||||
|
||||
{int fd;
|
||||
fd = copen (s, 'w');
|
||||
if (fd == OPENLOSS)
|
||||
{if (!full) cprint ("Warning: ");
|
||||
cprint ("Cant write stats file: %s\n", s);
|
||||
if (full) cexit (1);
|
||||
return;
|
||||
}
|
||||
wfacc (fd, full);
|
||||
cclose (fd);
|
||||
}
|
||||
|
||||
apy2o (s)
|
||||
char *s;
|
||||
|
||||
{char buf[FNSIZE];
|
||||
int fin, fout, c;
|
||||
|
||||
apfname (buf, stfname, "ystat");
|
||||
fin = copen (buf, 'r');
|
||||
if (fin == OPENLOSS)
|
||||
{cprint ("Cant read YSTAT file: %s\n", buf);
|
||||
cexit (1);
|
||||
}
|
||||
fout = copen (oldfilename, 'a');
|
||||
if (fout == OPENLOSS)
|
||||
{cprint ("Cant append to OSTAT file: %s\n", buf);
|
||||
cexit (1);
|
||||
}
|
||||
cprint ("\n %s:\n\n", s);
|
||||
while (c = cgetc (fin))
|
||||
{cputc (c, fout);
|
||||
putchar (c);
|
||||
}
|
||||
putchar ('\n');
|
||||
cclose (fin);
|
||||
cclose (fout);
|
||||
}
|
||||
|
||||
dely ()
|
||||
|
||||
{char buf[FNSIZE];
|
||||
|
||||
apfname (buf, stfname, "ystat");
|
||||
delete (buf);
|
||||
}
|
||||
|
||||
getfield (fd, s, n)
|
||||
char s[];
|
||||
|
||||
{char *ebuf;
|
||||
int c;
|
||||
|
||||
ebuf = s + (n-1);
|
||||
c = cgetc (fd);
|
||||
while (c == ' ' || c == '\t') c = cgetc (fd);
|
||||
while (TRUE)
|
||||
{if (c == ' ' || c == '\t')
|
||||
{*s = 0;
|
||||
return (0);
|
||||
}
|
||||
if (c == '\n' || c <= 0) return (1);
|
||||
if (s < ebuf) *s++ = c;
|
||||
c = cgetc (fd);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
GETLINE - Read a line into a buffer.
|
||||
Return 1 if EOF detected.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
getline (fd, s, n)
|
||||
char *s;
|
||||
|
||||
{return (scan (fd, s, n, '\n'));}
|
||||
|
||||
scan (fd, s, n, tc) char *s;
|
||||
|
||||
{char *ebuf;
|
||||
int c;
|
||||
|
||||
ebuf = s + (n-1);
|
||||
while (c = cgetc (fd))
|
||||
{if (c == tc)
|
||||
{*s = 0;
|
||||
return (0);
|
||||
}
|
||||
if (c == '\n') return (1);
|
||||
if (s < ebuf) *s++ = c;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int atoi (s) char s[];
|
||||
|
||||
{int i, sign, c;
|
||||
|
||||
if (!s) return (0);
|
||||
i = 0;
|
||||
sign = 1;
|
||||
while (*s == '-') {++s; sign = -sign;}
|
||||
while ((c = *s++)>='0' && c<='9') i = i*10 + c-'0';
|
||||
if (i<0)
|
||||
{i = -i;
|
||||
if (i<0)
|
||||
if (sign>0) return (-(i+1));
|
||||
else return (i);
|
||||
}
|
||||
return (sign*i);
|
||||
}
|
||||
|
||||
rename (s1, s2) char *s1, *s2;
|
||||
|
||||
{filespec f1, f2;
|
||||
fparse (s1, &f1);
|
||||
fparse (s2, &f2);
|
||||
sysrnm (&f1, &f2);
|
||||
}
|
||||
|
||||
int rd60th (s)
|
||||
char *s;
|
||||
|
||||
{int sum, done, n;
|
||||
char *e;
|
||||
|
||||
sum = 0;
|
||||
e = s;
|
||||
done = FALSE;
|
||||
while (!done)
|
||||
{while (*e != ':' && *e != '.' && *e) ++e;
|
||||
done = !*e;
|
||||
*e = 0;
|
||||
n = atoi (s);
|
||||
sum = sum * 60 + n;
|
||||
s = e+1;
|
||||
e = s;
|
||||
}
|
||||
return (sum);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
||||
particular code
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
sortuser ()
|
||||
|
||||
{user *up, *up1;
|
||||
|
||||
for (up=usertab;up<cuser;++up)
|
||||
{int i, totaltotal, totalwin;
|
||||
totaltotal = totalwin = 0;
|
||||
for (i=0;i<=2;++i)
|
||||
{int total;
|
||||
total = up->won[i] + up->lost[i];
|
||||
totaltotal =+ total;
|
||||
totalwin =+ up->won[i];
|
||||
up->percent[i] = up->won[i]*1000/total;
|
||||
}
|
||||
up->totalpercent = totalwin*1000/totaltotal;
|
||||
}
|
||||
for (up=usertab;up<cuser;++up)
|
||||
for (up1=up+1;up1<cuser;++up1)
|
||||
{int sz, n, *s, *d;
|
||||
user temp;
|
||||
if (up1->totalpercent < up->totalpercent) continue;
|
||||
if (up1->totalpercent == up->totalpercent)
|
||||
if (up1->total <= up->total) continue;
|
||||
sz = sizeof(temp)/sizeof(0);
|
||||
s = up; d = &temp; n = sz;
|
||||
while (--n >= 0) *d++ = *s++;
|
||||
s = up1; d = up; n = sz;
|
||||
while (--n >= 0) *d++ = *s++;
|
||||
s = &temp; d = up1; n = sz;
|
||||
while (--n >= 0) *d++ = *s++;
|
||||
}
|
||||
}
|
||||
|
||||
wfacc (fd, full)
|
||||
|
||||
{if (full) wrall (fd);
|
||||
else wrsum (fd);
|
||||
}
|
||||
|
||||
wrall (fd)
|
||||
|
||||
{user *up;
|
||||
|
||||
for (up=usertab;up<cuser;++up)
|
||||
{char buf[10];
|
||||
int sz, *p;
|
||||
c6tos (up->name, buf);
|
||||
cprint (fd, "%s", buf);
|
||||
sz = sizeof(*up)/sizeof(0);
|
||||
p = up;
|
||||
++p; --sz;
|
||||
while (--sz >= 0) cprint (fd, " %d", *p++);
|
||||
cputc ('\n', fd);
|
||||
}
|
||||
}
|
||||
|
||||
wrsum (fd)
|
||||
|
||||
{user *up;
|
||||
int cutoff, twon, tcheat, tlost, tdrawn, tpercent;
|
||||
int nuser, spercent;
|
||||
|
||||
cutoff = 4;
|
||||
twon = tcheat = tlost = tdrawn = nuser = spercent = 0;
|
||||
cprint (fd, "Othello Statistics as of ");
|
||||
prcal (&thetime, fd);
|
||||
cprint (fd, "\n\n note: cheat = win, but used analysis more than 10 times\n");
|
||||
cprint (fd, " users playing %d games or fewer not included\n", cutoff);
|
||||
cprint (fd,
|
||||
"\n\nuser\t won cheat lost drawn win %% win %% win %%\n");
|
||||
cprint (fd, "\t black white total\n\n");
|
||||
for (up=usertab;up<cuser;++up)
|
||||
{char buf[10];
|
||||
if (up->total > cutoff)
|
||||
{
|
||||
int swon, scheat, slost, sdrawn;
|
||||
++nuser;
|
||||
twon =+ (swon = up->won[0]+up->won[1]+up->won[2]);
|
||||
tcheat =+ (scheat = up->cheat[0]+up->cheat[1]+up->cheat[2]);
|
||||
tlost =+ (slost = up->lost[0]+up->lost[1]+up->lost[2]);
|
||||
tdrawn =+ (sdrawn = up->drawn[0]+up->drawn[1]+up->drawn[2]);
|
||||
spercent =+ up->totalpercent;
|
||||
c6tos (up->name, buf);
|
||||
cprint (fd, "%s\t%5d%8d%8d%8d", buf, swon,
|
||||
scheat, slost, sdrawn);
|
||||
prpercent (fd, up->percent[1]);
|
||||
prpercent (fd, up->percent[2]);
|
||||
prpercent (fd, up->totalpercent);
|
||||
cputc ('\n', fd);
|
||||
}
|
||||
}
|
||||
cprint (fd, "\ntotals\t%5d%8d%8d%8d", twon, tcheat, tlost, tdrawn);
|
||||
tpercent = twon*1000/(twon+tlost);
|
||||
cprint (fd, "%22d.%d\n", tpercent/10, tpercent%10);
|
||||
spercent = spercent/nuser;
|
||||
cprint (fd, "average\t%51d.%d\n", spercent/10, tpercent%10);
|
||||
}
|
||||
|
||||
prpercent (fd, n)
|
||||
{cprint (fd, "%6d.%d", n/10, n%10);
|
||||
}
|
||||
|
||||
enterstat (p) stat *p;
|
||||
|
||||
{user *up;
|
||||
|
||||
up = ulookup (p->name);
|
||||
if (up && p->hcap == 0)
|
||||
{if (p->user > p->machine)
|
||||
if (!p->aflag) ++up->won[p->color];
|
||||
else ++up->cheat[p->color];
|
||||
else if (p->user < p->machine) ++up->lost[p->color];
|
||||
else ++up->drawn[p->color];
|
||||
++up->total;
|
||||
}
|
||||
}
|
||||
|
||||
ulookup (n)
|
||||
|
||||
{user *up;
|
||||
|
||||
for (up=usertab;up<cuser;++up)
|
||||
if (up->name == n) return (up);
|
||||
if (cuser < euser)
|
||||
{int i;
|
||||
cuser->name = n;
|
||||
cuser->total = 0;
|
||||
for (i=0;i<=2;++i)
|
||||
{cuser->won[i] = 0;
|
||||
cuser->lost[i] = 0;
|
||||
cuser->cheat[i] = 0;
|
||||
cuser->drawn[i] = 0;
|
||||
}
|
||||
return (cuser++);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
rdstat (fd, p) stat *p;
|
||||
|
||||
{char buf[BUFSIZ], *s;
|
||||
|
||||
if (scan (fd, buf, BUFSIZ, '\t')) return (1);
|
||||
p->name = csto6 (buf);
|
||||
if (scan (fd, buf, BUFSIZ, '-')) return (1);
|
||||
p->user = atoi (buf);
|
||||
if (scan (fd, buf, BUFSIZ, '\t')) return (1);
|
||||
p->machine = atoi (buf);
|
||||
if (scan (fd, buf, BUFSIZ, '\t')) return (1);
|
||||
|
||||
s = buf;
|
||||
p->color = 0;
|
||||
if (*s == '*') {p->color = 1; ++s;}
|
||||
else if (*s == '@') {p->color = 2; ++s;}
|
||||
p->aflag = FALSE;
|
||||
if (*s == 'a') {p->aflag = TRUE; ++s;}
|
||||
else if (*s == 'r') {p->user = 0; p->machine = 100; ++s;}
|
||||
p->hcap = atoi (s);
|
||||
|
||||
if (scan (fd, buf, BUFSIZ, '\n')) return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
rdfacc (fd)
|
||||
|
||||
{cuser = usertab;
|
||||
while (rduser (fd));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int rduser (fd)
|
||||
|
||||
{char buf[BUFSIZ];
|
||||
int name, sz, *p;
|
||||
user *up;
|
||||
|
||||
if (getfield (fd, buf, BUFSIZ)) return (0);
|
||||
if (buf[0] == 0) return (0);
|
||||
name = csto6 (buf);
|
||||
up = ulookup (name);
|
||||
if (up->total)
|
||||
{c6tos (name, buf);
|
||||
cprint ("Duplicate stats entry for %s\n", buf);
|
||||
}
|
||||
sz = sizeof(*up)/sizeof(0);
|
||||
p = up;
|
||||
++p; --sz; sz =- 3; /* ignore percent fields */
|
||||
while (--sz >= 0)
|
||||
{if (getfield (fd, buf, BUFSIZ)) return (0);
|
||||
*p++ = atoi (buf);
|
||||
}
|
||||
if (getline (fd, buf, BUFSIZ)) return (0);
|
||||
return (1);
|
||||
}
|
||||
508
src/as/o/oxgp.c
Normal file
508
src/as/o/oxgp.c
Normal file
@@ -0,0 +1,508 @@
|
||||
# include "c/c.defs"
|
||||
# define FORFEIT 'F'
|
||||
|
||||
char *filename;
|
||||
char *itoa();
|
||||
|
||||
int formno; /* 0=old form (backwards init position),
|
||||
1=new form */
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
|
||||
{int fout, fin, n;
|
||||
static char opnstr[13]
|
||||
{'o', 'g', 'a', 'm', 'e', '.', '1' };
|
||||
fout = copen("o.xgp",'w'); /* open output file */
|
||||
prxgpheader (fout);
|
||||
--argc;
|
||||
++argv;
|
||||
n = 0;
|
||||
if (argc == 0)
|
||||
{filename = opnstr;
|
||||
fin = copen ("ogame.<", 'r');
|
||||
if (fin > 0)
|
||||
{filespec fs;
|
||||
filnam (itschan (fin), &fs);
|
||||
c6tos (fs.fn2, opnstr+6);
|
||||
n = atoi (opnstr+6);
|
||||
cclose (fin);
|
||||
while (TRUE)
|
||||
{fin = copen (opnstr, 'r');
|
||||
if (fin > 0) dofile (fin, fout, opnstr);
|
||||
else break;
|
||||
++n;
|
||||
itoa (n, opnstr+6);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{while (--argc >= 0)
|
||||
{filename = *argv;
|
||||
fin = copen (*argv, 'r');
|
||||
if (fin > 0) dofile (fin, fout, *argv);
|
||||
++argv;
|
||||
}
|
||||
}
|
||||
cclose(fout);
|
||||
}
|
||||
|
||||
prxgpheader (fout)
|
||||
{cprint(fout,";SKIP 1\n;VSP 0\n;LFTMAR 96\n;TOPMAR 0\n;BOTMAR 0\n");
|
||||
cprint(fout,";KSET DSK:FONTS1;O20,DSK:FONTS1;METM,DSK:FONTS;20FG\n");
|
||||
}
|
||||
|
||||
dofile(fin,fout,fname)
|
||||
char *fname;
|
||||
|
||||
{while (dogame (fin, fout, fname));
|
||||
cclose(fin);
|
||||
}
|
||||
|
||||
dogame (fin, fout, fname)
|
||||
char *fname;
|
||||
|
||||
{char board [8] [8] [8];
|
||||
char movstr [8][4], gmstr[200], title[100];
|
||||
int m, blen, scores [8][2], bnum;
|
||||
blen = parse(fin, gmstr, title);
|
||||
if (blen < 0) return (0);
|
||||
cprint(fout, "\p\nƒ\400`<60>%s (%s)\n\n<EFBFBD>\412", title, fname);
|
||||
initboard (board, scores);
|
||||
bnum=0;
|
||||
for (m=0;m<blen;m=+16)
|
||||
{doline (fout, blen, m, bnum, gmstr, board, scores, movstr);
|
||||
bnum =+ 4;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
initboard (board, scores)
|
||||
char board [8] [8] [8];
|
||||
int scores [8][2];
|
||||
|
||||
{register int i, j;
|
||||
|
||||
for(i=0; i<8; ++i) for(j=0; j<8; ++j) board[0][i][j] = '_';
|
||||
if (formno == 1)
|
||||
{board[0][3][3]='W';
|
||||
board[0][3][4]='B';
|
||||
board[0][4][3]='B';
|
||||
board[0][4][4]='W';
|
||||
}
|
||||
else
|
||||
{board[0][3][3]='B';
|
||||
board[0][3][4]='W';
|
||||
board[0][4][3]='W';
|
||||
board[0][4][4]='B';
|
||||
}
|
||||
scores[0][0]=2;
|
||||
scores[0][1]=2;
|
||||
}
|
||||
|
||||
int doline (fout, blen, m, bnum, gmstr, board, scores, movstr)
|
||||
char board [8] [8] [8];
|
||||
char movstr [8][4], gmstr[200];
|
||||
int scores [8][2], bnum;
|
||||
|
||||
{register int i, j, k;
|
||||
|
||||
/* start of making 2 elements of line of 8 */
|
||||
for (i=0;;)
|
||||
{if (gmstr[m]!=FORFEIT && gmstr[m]!=' ')
|
||||
{k=makmv(board[i], 'B', gmstr[m], gmstr[m+1], movstr[i]);
|
||||
if (k==0)
|
||||
cprint ("File %s, move %d invalid for black\n",
|
||||
filename, (m/4)+1);
|
||||
scores[i][0]=scores[i][0]+k+1;
|
||||
scores[i][1]=scores[i][1]-k;
|
||||
}
|
||||
else
|
||||
{if (gmstr[m]==' ') movstr[i][0]='\0';
|
||||
else movstr[i][0] = -1;
|
||||
}
|
||||
m = m + 2;
|
||||
if (m == blen)
|
||||
{movstr[++i][0] = -2;
|
||||
break;
|
||||
}
|
||||
for (j=0; j<8; ++j) for (k=0; k<8; ++k)
|
||||
board[i+1][j][k]=board[i][j][k];
|
||||
scores[i+1][0]=scores[i][0];
|
||||
scores[i+1][1]=scores[i][1];
|
||||
++i;
|
||||
if (gmstr[m] != FORFEIT)
|
||||
{k=makmv(board[i], 'W', gmstr[m], gmstr[m+1],
|
||||
movstr[i]);
|
||||
if (k==0)
|
||||
cprint ("File %s, move %d invalid for white\n",
|
||||
filename, (m/4)+1);
|
||||
scores[i][0]=scores[i][0]-k;
|
||||
scores[i][1]=scores[i][1]+k+1;
|
||||
}
|
||||
else movstr[i][0] = -1;
|
||||
m = m + 2;
|
||||
if (i==7) break;
|
||||
if (m == blen)
|
||||
{movstr[++i][0] = -2;
|
||||
break;
|
||||
}
|
||||
for (j=0; j<8; ++j) for (k=0; k<8; ++k)
|
||||
board[i+1][j][k]=board[i][j][k];
|
||||
scores[i+1][0]=scores[i][0];
|
||||
scores[i+1][1]=scores[i][1];
|
||||
++i;
|
||||
/* end of making pair of two of 8 */
|
||||
}
|
||||
|
||||
/* print the headings of the eight positions */
|
||||
pr8head (fout, movstr, bnum, scores);
|
||||
|
||||
/* print the eight board positions */
|
||||
pr8pos (fout, movstr, board);
|
||||
|
||||
/* print the bottom line */
|
||||
prbottom (fout, movstr);
|
||||
|
||||
if (blen < 73) cprint(fout, "\n\n<EFBFBD>\412");
|
||||
else cprint(fout, "\n<EFBFBD>\412");
|
||||
if (m < blen)
|
||||
{for (j=0; j<8; ++j) for (k=0; k<8; ++k)
|
||||
board[0][j][k]=board[7][j][k];
|
||||
scores[0][0]=scores[7][0];
|
||||
scores[0][1]=scores[7][1];
|
||||
}
|
||||
}
|
||||
|
||||
/* print the headings of the eight positions */
|
||||
|
||||
pr8head (fout, movstr, bnum, scores)
|
||||
char movstr [8][4];
|
||||
int scores [8][2], bnum;
|
||||
|
||||
{int i;
|
||||
|
||||
char static *xgpst1[7]
|
||||
{"<EFBFBD>%d.<2E> %s<> b<><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> N%s<> <13><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> \\%d.<2E> %s<> ^<5E><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> J%s<> <12><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> X%d.<2E> %s<> Z<><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> F%s<> \t<0E><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> \tT%d.<2E> \412%s<> \412V<EFBFBD><02>#\412%2d<08>#x%2d<32>",
|
||||
"<EFBFBD> B%s<> \p\412<EFBFBD><02>#\412%2d<08>#x%2d<32>" };
|
||||
char static *xgpst2[7]
|
||||
{"<EFBFBD>%d.<2E> Forfeit",
|
||||
"<EFBFBD> NForfeit",
|
||||
"<EFBFBD> \\%d.<2E> Forfeit",
|
||||
"<EFBFBD> JForfeit",
|
||||
"<EFBFBD> X%d.<2E> Forfeit",
|
||||
"<EFBFBD> FForfeit",
|
||||
"<EFBFBD> \tT%d.<2E> \412Forfeit",
|
||||
"<EFBFBD> BForfeit" };
|
||||
|
||||
for (i=0; i<8; ++i)
|
||||
{if (movstr[i] [0] >= 0)
|
||||
cprint(fout, xgpst1[i] , ++bnum, movstr [i],
|
||||
scores [i] [0], scores [i] [1]);
|
||||
else
|
||||
{if (movstr[i] [0] == -1)
|
||||
cprint(fout, xgpst2[i], ++bnum);
|
||||
else break;
|
||||
}
|
||||
if (movstr[++i] [0] >= 0)
|
||||
cprint(fout, xgpst1[i] , movstr [i],
|
||||
scores [i] [0], scores [i] [1]);
|
||||
else
|
||||
{if (movstr[i] [0] == -1)
|
||||
cprint(fout, xgpst2[i]);
|
||||
else break;
|
||||
}
|
||||
}
|
||||
cprint(fout, "\n<EFBFBD>\"\412<EFBFBD>\400");
|
||||
}
|
||||
|
||||
/* print the eight board positions */
|
||||
|
||||
pr8pos (fout, movstr, board)
|
||||
char board[8] [8] [8];
|
||||
char movstr [8][4];
|
||||
|
||||
{register int i, j, k;
|
||||
|
||||
for(j=0; j<8; ++j)
|
||||
{for (i=0;i<8;++i)
|
||||
{if (movstr[i] [0] == -2) break;
|
||||
for (k=0; k<8; ++k)
|
||||
cputc(board [i] [j] [k], fout);
|
||||
cputc(' ', fout);
|
||||
if (movstr [++i] [0] == -2) break;
|
||||
for (k=0; k<8; ++k)
|
||||
cputc(board [i] [j] [k], fout);
|
||||
cprint(fout, " ");
|
||||
}
|
||||
cprint(fout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* print the bottom line */
|
||||
|
||||
prbottom (fout, movstr)
|
||||
char movstr[8][4];
|
||||
|
||||
{register int j;
|
||||
char static *xgpst3[7]
|
||||
{"", "<EFBFBD> ", "<EFBFBD> \\", "<EFBFBD> ",
|
||||
"<EFBFBD> X", "<EFBFBD> \p", "<EFBFBD> \tT", "<EFBFBD> "};
|
||||
|
||||
for(j=0; j<8; ++j)
|
||||
{if (movstr[j][0] == -2) break;
|
||||
cprint(fout, "%s<>!j\"", xgpst3[j]);
|
||||
}
|
||||
}
|
||||
|
||||
int makmv(board, color, hpos, vpos, movstr)
|
||||
char board [8] [8];
|
||||
char movstr[4];
|
||||
int color, hpos, vpos;
|
||||
|
||||
{int i,j,ocolor;
|
||||
int nchng;
|
||||
|
||||
movstr[0] = hpos;
|
||||
movstr[1] = '-';
|
||||
movstr[2] = vpos;
|
||||
movstr[3] = '\0';
|
||||
hpos = hpos - '0';
|
||||
vpos = vpos - '0';
|
||||
|
||||
if (board[--hpos][--vpos] !='_') return(0);
|
||||
|
||||
nchng = 0;
|
||||
ocolor = 'B';
|
||||
if (color=='B') ocolor = 'W';
|
||||
|
||||
if ((hpos>1) && (board [hpos-1] [vpos] == ocolor))
|
||||
{
|
||||
{for (i=hpos-2;
|
||||
(i>=0)&&(board[i] [vpos]==ocolor);
|
||||
--i) ;
|
||||
}
|
||||
if ((i>=0)&&(board[i][vpos]==color))
|
||||
{nchng = nchng+(hpos-(++i));
|
||||
do board [i] [vpos] = color;
|
||||
while (++i < hpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hpos>1) && (vpos>1) && (board [hpos-1] [vpos-1] == ocolor))
|
||||
{
|
||||
{for (i=hpos-2, j=vpos-2;
|
||||
(i>=0)&&(j>=0)&&(board[i] [j]==ocolor);
|
||||
--i, --j) ;
|
||||
}
|
||||
if ((i>=0)&&(j>=0)&&(board[i][j]==color))
|
||||
{nchng = nchng+(hpos-(++i));
|
||||
do board[i][++j]=color;
|
||||
while (++i < hpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((vpos>1) && (board [hpos] [vpos-1] == ocolor))
|
||||
{
|
||||
{for (j=vpos-2;
|
||||
(j>=0)&&(board[hpos] [j]==ocolor);
|
||||
--j) ;
|
||||
}
|
||||
if ((j>=0)&&(board[hpos][j]==color))
|
||||
{nchng = nchng+(vpos-(++j));
|
||||
do board [hpos] [j] = color;
|
||||
while (++j < vpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hpos<6) && (vpos>1) && (board [hpos+1] [vpos-1] == ocolor))
|
||||
{
|
||||
{for (i=hpos+2, j=vpos-2;
|
||||
(i<=7)&&(j>=0)&&(board[i] [j]==ocolor);
|
||||
++i, --j) ;
|
||||
}
|
||||
if ((i<=7)&&(j>=0)&&(board[i][j]==color))
|
||||
{nchng = nchng+((--i)-hpos);
|
||||
do board [i][++j] = color;
|
||||
while (--i > hpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hpos<6) && (board [hpos+1] [vpos] == ocolor))
|
||||
{
|
||||
{for (i=hpos+2;
|
||||
(i<=7)&&(board[i] [vpos]==ocolor);
|
||||
++i) ;
|
||||
}
|
||||
if ((i<=7)&&(board[i][vpos]==color))
|
||||
{nchng = nchng+((--i)-hpos);
|
||||
do board [i] [vpos] = color;
|
||||
while (--i > hpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hpos<6) && (vpos<6) && (board [hpos+1] [vpos+1] == ocolor))
|
||||
{
|
||||
{for (i=hpos+2, j=vpos+2;
|
||||
(i<=7)&&(j<=7)&&(board[i] [j]==ocolor);
|
||||
++i, ++j) ;
|
||||
}
|
||||
if ((i<=7)&&(j<=7)&&(board[i][j]==color))
|
||||
{nchng = nchng+((--i)-hpos);
|
||||
do board[i][--j] = color;
|
||||
while (--i > hpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((vpos<6) && (board [hpos] [vpos+1] == ocolor))
|
||||
{
|
||||
{for (j=vpos+2;
|
||||
(j<=7)&&(board[hpos] [j]==ocolor);
|
||||
++j) ;
|
||||
}
|
||||
if ((j<=7)&&(board[hpos][j]==color))
|
||||
{nchng = nchng+((--j)-vpos);
|
||||
do board [hpos] [j] = color;
|
||||
while(--j > vpos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((hpos>1) && (vpos<6) && (board [hpos-1] [vpos+1] == ocolor))
|
||||
{
|
||||
{for (i=hpos-2, j=vpos+2;
|
||||
(i>=0)&&(j<=7)&&(board[i] [j]==ocolor);
|
||||
--i, ++j) ;
|
||||
}
|
||||
if ((i>=0)&&(j<=7)&&(board[i][j]==color))
|
||||
{nchng = nchng+(hpos-(++i));
|
||||
do board [i] [--j] = color;
|
||||
while(++i < hpos);
|
||||
}
|
||||
}
|
||||
|
||||
if (nchng) board [hpos] [vpos] = color;
|
||||
return(nchng);
|
||||
}
|
||||
|
||||
int parse (fin, gmstr, title)
|
||||
int fin;
|
||||
char gmstr[], title[];
|
||||
|
||||
{int n, i, c;
|
||||
if (ceof (fin)) return (-1);
|
||||
formno = 0;
|
||||
c = cgetc (fin);
|
||||
if (c && c != '1')
|
||||
{while (c && c == ' ') c = cgetc (fin);
|
||||
while (c && c != '\n' && c != '\p')
|
||||
{*title++ = c;
|
||||
if (c == '(') formno = 1;
|
||||
c = cgetc (fin);
|
||||
}
|
||||
if (c != '\n') return (-1);
|
||||
while (c != '1' && c) c = cgetc (fin);
|
||||
}
|
||||
*title = 0;
|
||||
|
||||
if (ceof (fin)) return (-1);
|
||||
n = 0;
|
||||
do
|
||||
{i = rdline (fin, gmstr, n);
|
||||
n =+ i;
|
||||
}
|
||||
while (i == 4);
|
||||
while (gmstr[n-2] == FORFEIT) n =- 2;
|
||||
return (n);
|
||||
}
|
||||
|
||||
int rdline (fin, gmstr, n)
|
||||
char gmstr[];
|
||||
|
||||
{int chr;
|
||||
|
||||
gmstr[n] = gmstr[n+2] = FORFEIT;
|
||||
if (ceof (fin)) return (0);
|
||||
if (n>0) /* initial 1 already read */
|
||||
{cgetc(fin);
|
||||
if (n>=((10-1)*4)) cgetc(fin);
|
||||
}
|
||||
if (cgetc(fin) != '.')
|
||||
{pskip (fin);
|
||||
return (0);
|
||||
}
|
||||
cgetc (fin);
|
||||
if ((chr=cgetc(fin)) == 'F') skip (fin, 6);
|
||||
else if (chr=='R')
|
||||
{pskip (fin);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{gmstr[n] = chr;
|
||||
cgetc(fin);
|
||||
gmstr[n+1] = cgetc(fin);
|
||||
}
|
||||
chr = cgetc (fin);
|
||||
if (chr == ' ')
|
||||
{chr = cgetc (fin);
|
||||
if (chr == '(')
|
||||
{do chr=cgetc (fin);
|
||||
while (chr && chr != '\n' && chr != '\p'
|
||||
&& chr != ')');
|
||||
if (chr==')') chr=cgetc (fin);
|
||||
}
|
||||
}
|
||||
if (chr != '.')
|
||||
{pskip (fin);
|
||||
return (2);
|
||||
}
|
||||
skip (fin, 2);
|
||||
if ((chr=cgetc(fin)) == 'F') skip (fin, 6);
|
||||
else if (chr=='R')
|
||||
{pskip (fin);
|
||||
return (2);
|
||||
}
|
||||
else
|
||||
{gmstr[n+2] = chr;
|
||||
cgetc(fin);
|
||||
gmstr[n+3] = cgetc(fin);
|
||||
}
|
||||
while ((chr=cgetc(fin)) != '\n' && chr != '\p' && chr);
|
||||
return (4);
|
||||
}
|
||||
|
||||
skip (f, n)
|
||||
{while (--n>=0) cgetc (f);
|
||||
}
|
||||
|
||||
pskip (f)
|
||||
{int c;
|
||||
while (((c = cgetc (f)) != '\p') && c);
|
||||
}
|
||||
|
||||
atoi (s)
|
||||
char *s;
|
||||
|
||||
{int n, c;
|
||||
n = 0;
|
||||
while (c = *s++) n = (n * 10) + (c - '0');
|
||||
return (n);
|
||||
}
|
||||
|
||||
char *itoa (n, s)
|
||||
char *s;
|
||||
|
||||
{int a;
|
||||
if (n<0) n=0;
|
||||
if (a = (n / 10)) s = itoa (a, s);
|
||||
*s++ = '0' + n%10;
|
||||
*s = 0;
|
||||
return (s);
|
||||
}
|
||||
|
||||
30
src/as/o/random.1
Normal file
30
src/as/o/random.1
Normal file
@@ -0,0 +1,30 @@
|
||||
;
|
||||
; RANDOM NUMBER GENERATOR (STOLEN FROM MUDDLE)
|
||||
;
|
||||
RELOCATABLE
|
||||
TITLE RANDOM
|
||||
.INSRT C;NC INSERT
|
||||
.INSRT C;NM INSERT
|
||||
|
||||
CENTRY SRAND,[SEED]
|
||||
MOVE A,SEED
|
||||
ROT A,-1
|
||||
MOVEM A,RLOW
|
||||
RETURN
|
||||
|
||||
CENTRY RAND
|
||||
|
||||
MOVE A,RHI
|
||||
MOVE B,RLOW
|
||||
MOVEM A,RLOW ;Update Low seed
|
||||
LSHC A,-1 ;Shift both right one bit
|
||||
XORB B,RHI ;Generate output and update High seed
|
||||
MOVE A,B
|
||||
RETURN
|
||||
|
||||
.IDATA
|
||||
RHI: 267762113337
|
||||
RLOW: 155256071112
|
||||
.PDATA
|
||||
|
||||
END
|
||||
BIN
src/as/o/random.rel
Normal file
BIN
src/as/o/random.rel
Normal file
Binary file not shown.
69
src/as/o/stdio.c
Normal file
69
src/as/o/stdio.c
Normal file
@@ -0,0 +1,69 @@
|
||||
# include "c/c.defs"
|
||||
int stdin, stdout;
|
||||
extern int cin, cout;
|
||||
|
||||
stdio ()
|
||||
|
||||
{stdin = cin; stdout = cout;
|
||||
on (ctrlg_interrupt, INT_IGNORE);
|
||||
}
|
||||
|
||||
flopen (name, mode) char *name, *mode;
|
||||
|
||||
{int f;
|
||||
f = copen (name, mode[0]);
|
||||
if (f == OPENLOSS) return (0);
|
||||
return (f);
|
||||
}
|
||||
|
||||
printf (a, b, c, d, e, f, g)
|
||||
{cprint (cout, a, b, c, d, e, f, g);}
|
||||
|
||||
fprintf (a, b, c, d, e, f, g)
|
||||
{cprint (a, b, c, d, e, f, g);}
|
||||
|
||||
strcmp (s1, s2) {return (stcmp (s2, s2));}
|
||||
|
||||
fclose (f) {cclose (f);}
|
||||
|
||||
fread (f, buf, size, number) char buf[];
|
||||
|
||||
{int n;
|
||||
n = size * number;
|
||||
while (--n >= 0) *buf++ = cgetc (f);
|
||||
}
|
||||
|
||||
freopen (name, mode, f) char *name, *mode;
|
||||
|
||||
{int i;
|
||||
cclose (f);
|
||||
i = copen (name, *mode);
|
||||
return (i);
|
||||
}
|
||||
|
||||
getuid () {return (rsuset (074));}
|
||||
|
||||
getpw (w, buf) char *buf;
|
||||
{c6tos (w, buf);}
|
||||
|
||||
nowtime (tv) int tv[];
|
||||
{cal foo;
|
||||
now (&foo);
|
||||
tv[0] = tv[1] = cal2f (&foo);
|
||||
}
|
||||
|
||||
char *ctime (tv) int tv[];
|
||||
{static char buf[100];
|
||||
cal foo;
|
||||
int f;
|
||||
f2cal (tv[0], &foo);
|
||||
f = copen (buf, 'w', "s");
|
||||
prcal (&foo, f);
|
||||
cputc ('\n', f);
|
||||
cclose (f);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
unlink (s) {delete (s);}
|
||||
exit (cc) {cexit (cc);}
|
||||
|
||||
BIN
src/as/o/stdio.rel
Normal file
BIN
src/as/o/stdio.rel
Normal file
Binary file not shown.
10
src/as/o/test.book
Normal file
10
src/as/o/test.book
Normal file
@@ -0,0 +1,10 @@
|
||||
1: 3-5 2, 4-6 v270 2, 5-3 v90 2, 6-4 r180 2g;
|
||||
2: 3-6 3g, 3-4 999, 5-6 999;
|
||||
3: 3-7 999, 4-6 4g, 5-3 999, 6-4 999;
|
||||
4: 3-4 5g, 5-6 h90 5;
|
||||
5:
|
||||
6:
|
||||
7:
|
||||
8:
|
||||
9:
|
||||
10:
|
||||
Reference in New Issue
Block a user