Home » CEEFAX disks » telesoftware7.adl » 20-05-88/4_SITE/C
20-05-88/4_SITE/C
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware7.adl |
Filename: | 20-05-88/4_SITE/C |
Read OK: | ✔ |
File size: | 1865 bytes |
Load address: | 0000 |
Exec address: | FFFFFFFF |
File contents
/****************************************** * * * 4-SITE * * * * By Robin Nixon * * * * (c) Personal Computing with the Amstrad * * * ******************************************/ #include "rlib.h" /* Functions */ void startscreen(),updatescreen(),playerselect(); void computerselect(),evaluate(),won(); int new(); /* Macros */ #define ON 1 #define OFF 0 #define PLAYER 1 #define COMP 2 /* Global variables */ uchar board[8][8],weightings[8][8],coords[64][2]; int over,dummy=1,xx=0,yy=0,pscore=0,cscore=0,go=0; /* Program */ main() { int j,k; srand((int) time(0)); startscreen(); go=rnd(2); while(dummy) { for (j=0 ; j<8 ; ++j) for (k=0 ; k<8 ; ++k) { board[j][k]=0; updatescreen(j,k); } over=FALSE; locate (5,4); printf("%2d",cscore); locate (72,4); printf("%2d",pscore); if(go) { go=FALSE; while (!over) { playerselect(); evaluate(); if (!over) { computerselect(); evaluate(); } } won(over); } else { go=TRUE; evaluate(); while (!over) { computerselect(); evaluate(); if (!over) { playerselect(); evaluate(); } } won(over); } } } void startscreen() { int j,k; cls(); cursoroff(); print("4-Site By Robin Nixon"); locate(41,0); print("(c) Personal Computing with the Amstrad"); locate (2,2); print("My Score"); locate (68,2); print("Your Score"); locate (0,1); for (j=0 ; j<8 ; ++j) { indent(12); for (k=0 ; k<8 ; ++k) print("����Ŀ "); crlf(); indent(12); for (k=0 ; k<8 ; ++k) print("� � "); crlf(); indent(12); for (k=0 ; k<8 ; ++k) print("������ "); if (j<7) crlf(); } } void updatescreen(x,y) int x,y; { locate (14+x*7,2+y*3); switch (board[x][y]) { case 1 : print("��"); break; case 2 : print("��"); break; default: print(" "); break; } } void cursor(x,y,onoff) int x,y,onoff; { locate (13+x*7,2+y*3); switch (onoff) { case 0: putch(sp); locate (16+x*7,2+y*3); putch(sp); break; case 1: putch('['); locate (16+x*7,2+y*3); putch(']'); break; } } void playerselect() { int c=0,flag=FALSE; cursor(xx,yy,ON); while (!flag) { while ((c=inkey()) != 0x0d) { if (c == 27) { cursize(6,7); exit(0); } if (c != 0) { cursor(xx,yy,OFF); switch(c) { case 0x4b: --xx; break; case 0x4d: ++xx; break; case 0x48: --yy; break; case 0x50: ++yy; break; } if (xx<0) xx=7; if (xx>7) xx=0; if (yy<0) yy=7; if (yy>7) yy=0; cursor(xx,yy,ON); } } if (board[xx][yy] == 0) { board[xx][yy]=PLAYER; cursor(xx,yy,OFF); updatescreen(xx,yy); flag=TRUE; } } } void evaluate() { int j,k,l,p,c,x,y; for (j=0 ; j<8 ; ++j) for (k=0 ; k<8 ; ++k) weightings[j][k]=0; for (j=0 ; j<8 ; ++j) { for (k=0 ; k<5 ; ++k) { p=0; c=0; for (l=0 ; l<4 ; ++l) { switch (board[j][k+l]) { case 1: ++p; break; case 2: ++c; break; } } p=new(p,PLAYER); c=new(c,COMP); if (p == 9999) over=PLAYER; if (c == 9999) over=COMP; if (p == 0 && c>0) for (l=0 ; l<4 ; ++l) weightings[j][k+l]+=c; if (c == 0 && p>0) for (l=0 ; l<4 ; ++l) weightings[j][k+l]+=p; } } for (k=0 ; k<8 ; ++k) { for (j=0 ; j<5 ; ++j) { p=0; c=0; for (l=0 ; l<4 ; ++l) { switch (board[j+l][k]) { case 1: ++p; break; case 2: ++c; break; } } p=new(p,PLAYER); c=new(c,COMP); if (p == 9999) over=PLAYER; if (c == 9999) over=COMP; if (p == 0 && c>0) for (l=0 ; l<4 ; ++l) weightings[j+l][k]+=c; if (c == 0 && p>0) for (l=0 ; l<4 ; ++l) weightings[j+l][k]+=p; } } for (j=0 ; j<5 ; ++j) { for (k=0 ; k<5 ; ++k) { p=0; c=0; for (l=0 ; l<4 ; ++l) { switch(board[j+l][k+l]) { case 1: ++p; break; case 2: ++c; break; } } p=new(p,PLAYER); c=new(c,COMP); if (p == 9999) over=PLAYER; if (c == 9999) over=COMP; if (p == 0 && c>0) for (l=0 ; l<4 ; ++l) weightings[j+l][k+l]+=c; if (c == 0 && p>0) for (l=0 ; l<4 ; ++l) weightings[j+l][k+l]+=p; } } for (j=3 ; j<8 ; ++j) { for (k=0 ; k<5 ; ++k) { p=0; c=0; for (l=0 ; l<4 ; ++l) { switch(board[j-l][k+l]) { case 1: ++p; break; case 2: ++c; break; } } p=new(p,PLAYER); c=new(c,COMP); if (p == 9999) over=PLAYER; if (c == 9999) over=COMP; if (p == 0 && c>0) for (l=0 ; l<4 ; ++l) weightings[j-l][k+l]+=c; if (c == 0 && p>0) for (l=0 ; l<4 ; ++l) weightings[j-l][k+l]+=p; } } } void computerselect() { int t,top,x,y,j,k,l; top=0; for (j=0 ; j<8 ; ++j) for (k=0 ; k<8 ; ++k) if (board[j][k] == 0) if ((l=weightings[j][k]) > top) top=l; l=0; for (j=0 ; j<8 ; ++j) for (k=0 ; k<8 ; ++k) if (weightings[j][k] == top && board[j][k] == 0) { coords[l][0]=j; coords[l][1]=k; ++l; } t=rnd(l); x=coords[t][0]; y=coords[t][1]; board[x][y]=COMP; updatescreen(x,y); } int new(num,player) int num; { switch(num) { case (0): return(0); case (1): return(player*2); case (2): return(player*10); case (3): return(player*75); case (4): return(9999); } return(0); } void won(player) int player; { if (player == PLAYER) { ++pscore; locate(70,22); print("YOU WIN"); locate(68,24); print("Press a key"); while (inkey() == 0); locate(70,22); print(" "); locate(68,24); print(" "); } else { ++cscore; locate(3,22); print("I WIN"); locate(0,24); print("Press a key"); while (inkey() == 0); locate(2,22); print(" "); locate(0,24); print(" "); } }
00000000 2f 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |/***************| 00000010 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| 00000020 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 0d 0a 2a 20 20 |***********..* | 00000030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000050 20 20 20 20 20 20 20 2a 0d 0a 2a 20 20 20 20 20 | *..* | 00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 34 2d 53 | 4-S| 00000070 49 54 45 20 20 20 20 20 20 20 20 20 20 20 20 20 |ITE | 00000080 20 20 20 20 2a 0d 0a 2a 20 20 20 20 20 20 20 20 | *..* | 00000090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000000b0 20 2a 0d 0a 2a 20 20 20 20 20 20 20 20 20 20 20 | *..* | 000000c0 20 20 20 42 79 20 52 6f 62 69 6e 20 4e 69 78 6f | By Robin Nixo| 000000d0 6e 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 0d |n *.| 000000e0 0a 2a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |.* | 000000f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000100 20 20 20 20 20 20 20 20 20 20 20 2a 0d 0a 2a 20 | *..* | 00000110 28 63 29 20 50 65 72 73 6f 6e 61 6c 20 43 6f 6d |(c) Personal Com| 00000120 70 75 74 69 6e 67 20 77 69 74 68 20 74 68 65 20 |puting with the | 00000130 41 6d 73 74 72 61 64 20 2a 0d 0a 2a 20 20 20 20 |Amstrad *..* | 00000140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000160 20 20 20 20 20 2a 0d 0a 2a 2a 2a 2a 2a 2a 2a 2a | *..********| 00000170 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a |****************| * 00000190 2a 2a 2f 0d 0a 0d 0a 23 69 6e 63 6c 75 64 65 20 |**/....#include | 000001a0 22 72 6c 69 62 2e 68 22 0d 0a 0d 0a 2f 2a 20 46 |"rlib.h"..../* F| 000001b0 75 6e 63 74 69 6f 6e 73 20 2a 2f 0d 0a 0d 0a 76 |unctions */....v| 000001c0 6f 69 64 20 73 74 61 72 74 73 63 72 65 65 6e 28 |oid startscreen(| 000001d0 29 2c 75 70 64 61 74 65 73 63 72 65 65 6e 28 29 |),updatescreen()| 000001e0 2c 70 6c 61 79 65 72 73 65 6c 65 63 74 28 29 3b |,playerselect();| 000001f0 0d 0a 76 6f 69 64 20 63 6f 6d 70 75 74 65 72 73 |..void computers| 00000200 65 6c 65 63 74 28 29 2c 65 76 61 6c 75 61 74 65 |elect(),evaluate| 00000210 28 29 2c 77 6f 6e 28 29 3b 0d 0a 69 6e 74 20 6e |(),won();..int n| 00000220 65 77 28 29 3b 0d 0a 0d 0a 2f 2a 20 4d 61 63 72 |ew();..../* Macr| 00000230 6f 73 20 2a 2f 0d 0a 0d 0a 23 64 65 66 69 6e 65 |os */....#define| 00000240 20 4f 4e 20 31 0d 0a 23 64 65 66 69 6e 65 20 4f | ON 1..#define O| 00000250 46 46 20 30 0d 0a 23 64 65 66 69 6e 65 20 50 4c |FF 0..#define PL| 00000260 41 59 45 52 20 31 0d 0a 23 64 65 66 69 6e 65 20 |AYER 1..#define | 00000270 43 4f 4d 50 20 32 0d 0a 0d 0a 2f 2a 20 47 6c 6f |COMP 2..../* Glo| 00000280 62 61 6c 20 76 61 72 69 61 62 6c 65 73 20 2a 2f |bal variables */| 00000290 0d 0a 0d 0a 75 63 68 61 72 20 62 6f 61 72 64 5b |....uchar board[| 000002a0 38 5d 5b 38 5d 2c 77 65 69 67 68 74 69 6e 67 73 |8][8],weightings| 000002b0 5b 38 5d 5b 38 5d 2c 63 6f 6f 72 64 73 5b 36 34 |[8][8],coords[64| 000002c0 5d 5b 32 5d 3b 0d 0a 69 6e 74 20 6f 76 65 72 2c |][2];..int over,| 000002d0 64 75 6d 6d 79 3d 31 2c 78 78 3d 30 2c 79 79 3d |dummy=1,xx=0,yy=| 000002e0 30 2c 70 73 63 6f 72 65 3d 30 2c 63 73 63 6f 72 |0,pscore=0,cscor| 000002f0 65 3d 30 2c 67 6f 3d 30 3b 0d 0a 0d 0a 2f 2a 20 |e=0,go=0;..../* | 00000300 50 72 6f 67 72 61 6d 20 2a 2f 0d 0a 0d 0a 6d 61 |Program */....ma| 00000310 69 6e 28 29 0d 0a 7b 0d 0a 09 69 6e 74 20 6a 2c |in()..{...int j,| 00000320 6b 3b 0d 0a 0d 0a 09 73 72 61 6e 64 28 28 69 6e |k;.....srand((in| 00000330 74 29 20 74 69 6d 65 28 30 29 29 3b 0d 0a 09 73 |t) time(0));...s| 00000340 74 61 72 74 73 63 72 65 65 6e 28 29 3b 0d 0a 09 |tartscreen();...| 00000350 67 6f 3d 72 6e 64 28 32 29 3b 0d 0a 09 77 68 69 |go=rnd(2);...whi| 00000360 6c 65 28 64 75 6d 6d 79 29 0d 0a 09 7b 0d 0a 09 |le(dummy)...{...| 00000370 09 66 6f 72 20 28 6a 3d 30 20 3b 20 6a 3c 38 20 |.for (j=0 ; j<8 | 00000380 3b 20 2b 2b 6a 29 0d 0a 09 09 09 66 6f 72 20 28 |; ++j).....for (| 00000390 6b 3d 30 20 3b 20 6b 3c 38 20 3b 20 2b 2b 6b 29 |k=0 ; k<8 ; ++k)| 000003a0 0d 0a 09 09 09 7b 0d 0a 09 09 09 09 62 6f 61 72 |.....{......boar| 000003b0 64 5b 6a 5d 5b 6b 5d 3d 30 3b 09 0d 0a 09 09 09 |d[j][k]=0;......| 000003c0 09 75 70 64 61 74 65 73 63 72 65 65 6e 28 6a 2c |.updatescreen(j,| 000003d0 6b 29 3b 0d 0a 09 09 09 7d 0d 0a 09 09 6f 76 65 |k);.....}....ove| 000003e0 72 3d 46 41 4c 53 45 3b 0d 0a 09 09 6c 6f 63 61 |r=FALSE;....loca| 000003f0 74 65 20 28 35 2c 34 29 3b 20 70 72 69 6e 74 66 |te (5,4); printf| 00000400 28 22 25 32 64 22 2c 63 73 63 6f 72 65 29 3b 0d |("%2d",cscore);.| 00000410 0a 09 09 6c 6f 63 61 74 65 20 28 37 32 2c 34 29 |...locate (72,4)| 00000420 3b 20 70 72 69 6e 74 66 28 22 25 32 64 22 2c 70 |; printf("%2d",p| 00000430 73 63 6f 72 65 29 3b 0d 0a 09 09 69 66 28 67 6f |score);....if(go| 00000440 29 0d 0a 09 09 7b 0d 0a 09 09 09 67 6f 3d 46 41 |)....{.....go=FA| 00000450 4c 53 45 3b 0d 0a 09 09 09 77 68 69 6c 65 20 28 |LSE;.....while (| 00000460 21 6f 76 65 72 29 0d 0a 09 09 09 7b 0d 0a 09 09 |!over).....{....| 00000470 09 09 70 6c 61 79 65 72 73 65 6c 65 63 74 28 29 |..playerselect()| 00000480 3b 0d 0a 09 09 09 09 65 76 61 6c 75 61 74 65 28 |;......evaluate(| 00000490 29 3b 0d 0a 09 09 09 09 69 66 20 28 21 6f 76 65 |);......if (!ove| 000004a0 72 29 0d 0a 09 09 09 09 7b 0d 0a 09 09 09 09 09 |r)......{.......| 000004b0 63 6f 6d 70 75 74 65 72 73 65 6c 65 63 74 28 29 |computerselect()| 000004c0 3b 0d 0a 09 09 09 09 09 65 76 61 6c 75 61 74 65 |;.......evaluate| 000004d0 28 29 3b 0d 0a 09 09 09 09 7d 0d 0a 09 09 09 7d |();......}.....}| 000004e0 0d 0a 09 09 09 77 6f 6e 28 6f 76 65 72 29 3b 0d |.....won(over);.| 000004f0 0a 09 09 7d 0d 0a 09 09 65 6c 73 65 0d 0a 09 09 |...}....else....| 00000500 7b 0d 0a 09 09 09 67 6f 3d 54 52 55 45 3b 0d 0a |{.....go=TRUE;..| 00000510 09 09 09 65 76 61 6c 75 61 74 65 28 29 3b 0d 0a |...evaluate();..| 00000520 09 09 09 77 68 69 6c 65 20 28 21 6f 76 65 72 29 |...while (!over)| 00000530 0d 0a 09 09 09 7b 0d 0a 09 09 09 09 63 6f 6d 70 |.....{......comp| 00000540 75 74 65 72 73 65 6c 65 63 74 28 29 3b 0d 0a 09 |uterselect();...| 00000550 09 09 09 65 76 61 6c 75 61 74 65 28 29 3b 0d 0a |...evaluate();..| 00000560 09 09 09 09 69 66 20 28 21 6f 76 65 72 29 0d 0a |....if (!over)..| 00000570 09 09 09 09 7b 0d 0a 09 09 09 09 09 70 6c 61 79 |....{.......play| 00000580 65 72 73 65 6c 65 63 74 28 29 3b 0d 0a 09 09 09 |erselect();.....| 00000590 09 09 65 76 61 6c 75 61 74 65 28 29 3b 0d 0a 09 |..evaluate();...| 000005a0 09 09 09 7d 0d 0a 09 09 09 7d 0d 0a 09 09 09 77 |...}.....}.....w| 000005b0 6f 6e 28 6f 76 65 72 29 3b 0d 0a 09 09 7d 0d 0a |on(over);....}..| 000005c0 09 7d 0d 0a 7d 09 0d 0a 0d 0a 76 6f 69 64 20 73 |.}..}.....void s| 000005d0 74 61 72 74 73 63 72 65 65 6e 28 29 0d 0a 7b 0d |tartscreen()..{.| 000005e0 0a 09 69 6e 74 20 6a 2c 6b 3b 0d 0a 0d 0a 09 63 |..int j,k;.....c| 000005f0 6c 73 28 29 3b 20 63 75 72 73 6f 72 6f 66 66 28 |ls(); cursoroff(| 00000600 29 3b 0d 0a 09 70 72 69 6e 74 28 22 34 2d 53 69 |);...print("4-Si| 00000610 74 65 20 42 79 20 52 6f 62 69 6e 20 4e 69 78 6f |te By Robin Nixo| 00000620 6e 22 29 3b 0d 0a 09 6c 6f 63 61 74 65 28 34 31 |n");...locate(41| 00000630 2c 30 29 3b 0d 0a 09 70 72 69 6e 74 28 22 28 63 |,0);...print("(c| 00000640 29 20 50 65 72 73 6f 6e 61 6c 20 43 6f 6d 70 75 |) Personal Compu| 00000650 74 69 6e 67 20 77 69 74 68 20 74 68 65 20 41 6d |ting with the Am| 00000660 73 74 72 61 64 22 29 3b 0d 0a 09 6c 6f 63 61 74 |strad");...locat| 00000670 65 20 28 32 2c 32 29 3b 20 70 72 69 6e 74 28 22 |e (2,2); print("| 00000680 4d 79 20 53 63 6f 72 65 22 29 3b 0d 0a 09 6c 6f |My Score");...lo| 00000690 63 61 74 65 20 28 36 38 2c 32 29 3b 20 70 72 69 |cate (68,2); pri| 000006a0 6e 74 28 22 59 6f 75 72 20 20 53 63 6f 72 65 22 |nt("Your Score"| 000006b0 29 3b 0d 0a 09 6c 6f 63 61 74 65 20 28 30 2c 31 |);...locate (0,1| 000006c0 29 3b 0d 0a 09 66 6f 72 20 28 6a 3d 30 20 3b 20 |);...for (j=0 ; | 000006d0 6a 3c 38 20 3b 20 2b 2b 6a 29 0d 0a 09 7b 0d 0a |j<8 ; ++j)...{..| 000006e0 09 09 69 6e 64 65 6e 74 28 31 32 29 3b 0d 0a 09 |..indent(12);...| 000006f0 09 66 6f 72 20 28 6b 3d 30 20 3b 20 6b 3c 38 20 |.for (k=0 ; k<8 | 00000700 3b 20 2b 2b 6b 29 0d 0a 09 09 09 70 72 69 6e 74 |; ++k).....print| 00000710 28 22 da c4 c4 c4 c4 bf 20 22 29 3b 0d 0a 09 09 |("...... ");....| 00000720 63 72 6c 66 28 29 3b 20 69 6e 64 65 6e 74 28 31 |crlf(); indent(1| 00000730 32 29 3b 0d 0a 09 09 66 6f 72 20 28 6b 3d 30 20 |2);....for (k=0 | 00000740 3b 20 6b 3c 38 20 3b 20 2b 2b 6b 29 0d 0a 09 09 |; k<8 ; ++k)....| 00000750 09 70 72 69 6e 74 28 22 b3 20 20 20 20 b3 20 22 |.print(". . "| 00000760 29 3b 0d 0a 09 09 63 72 6c 66 28 29 3b 20 69 6e |);....crlf(); in| 00000770 64 65 6e 74 28 31 32 29 3b 0d 0a 09 09 66 6f 72 |dent(12);....for| 00000780 20 28 6b 3d 30 20 3b 20 6b 3c 38 20 3b 20 2b 2b | (k=0 ; k<8 ; ++| 00000790 6b 29 0d 0a 09 09 09 70 72 69 6e 74 28 22 c0 c4 |k).....print("..| 000007a0 c4 c4 c4 d9 20 22 29 3b 0d 0a 09 09 69 66 20 28 |.... ");....if (| 000007b0 6a 3c 37 29 0d 0a 09 09 09 63 72 6c 66 28 29 3b |j<7).....crlf();| 000007c0 0d 0a 09 7d 0d 0a 7d 0d 0a 0d 0a 76 6f 69 64 20 |...}..}....void | 000007d0 75 70 64 61 74 65 73 63 72 65 65 6e 28 78 2c 79 |updatescreen(x,y| 000007e0 29 0d 0a 69 6e 74 20 78 2c 79 3b 0d 0a 7b 0d 0a |)..int x,y;..{..| 000007f0 09 6c 6f 63 61 74 65 20 28 31 34 2b 78 2a 37 2c |.locate (14+x*7,| 00000800 32 2b 79 2a 33 29 3b 0d 0a 09 73 77 69 74 63 68 |2+y*3);...switch| 00000810 20 28 62 6f 61 72 64 5b 78 5d 5b 79 5d 29 0d 0a | (board[x][y])..| 00000820 09 7b 0d 0a 09 09 63 61 73 65 20 31 20 3a 20 70 |.{....case 1 : p| 00000830 72 69 6e 74 28 22 b1 b1 22 29 3b 20 62 72 65 61 |rint(".."); brea| 00000840 6b 3b 0d 0a 09 09 63 61 73 65 20 32 20 3a 20 70 |k;....case 2 : p| 00000850 72 69 6e 74 28 22 db db 22 29 3b 20 62 72 65 61 |rint(".."); brea| 00000860 6b 3b 0d 0a 09 09 64 65 66 61 75 6c 74 3a 20 70 |k;....default: p| 00000870 72 69 6e 74 28 22 20 20 22 29 3b 20 62 72 65 61 |rint(" "); brea| 00000880 6b 3b 0d 0a 09 7d 0d 0a 7d 0d 0a 0d 0a 76 6f 69 |k;...}..}....voi| 00000890 64 20 63 75 72 73 6f 72 28 78 2c 79 2c 6f 6e 6f |d cursor(x,y,ono| 000008a0 66 66 29 0d 0a 69 6e 74 20 78 2c 79 2c 6f 6e 6f |ff)..int x,y,ono| 000008b0 66 66 3b 0d 0a 7b 0d 0a 09 6c 6f 63 61 74 65 20 |ff;..{...locate | 000008c0 28 31 33 2b 78 2a 37 2c 32 2b 79 2a 33 29 3b 0d |(13+x*7,2+y*3);.| 000008d0 0a 09 73 77 69 74 63 68 20 28 6f 6e 6f 66 66 29 |..switch (onoff)| 000008e0 0d 0a 09 7b 0d 0a 09 09 63 61 73 65 20 30 3a 09 |...{....case 0:.| 000008f0 70 75 74 63 68 28 73 70 29 3b 20 6c 6f 63 61 74 |putch(sp); locat| 00000900 65 20 28 31 36 2b 78 2a 37 2c 32 2b 79 2a 33 29 |e (16+x*7,2+y*3)| 00000910 3b 0d 0a 09 09 09 09 70 75 74 63 68 28 73 70 29 |;......putch(sp)| 00000920 3b 20 62 72 65 61 6b 3b 0d 0a 09 09 63 61 73 65 |; break;....case| 00000930 20 31 3a 09 70 75 74 63 68 28 27 5b 27 29 3b 20 | 1:.putch('['); | 00000940 6c 6f 63 61 74 65 20 28 31 36 2b 78 2a 37 2c 32 |locate (16+x*7,2| 00000950 2b 79 2a 33 29 3b 0d 0a 09 09 09 09 70 75 74 63 |+y*3);......putc| 00000960 68 28 27 5d 27 29 3b 09 62 72 65 61 6b 3b 0d 0a |h(']');.break;..| 00000970 09 7d 0d 0a 7d 0d 0a 0d 0a 76 6f 69 64 20 70 6c |.}..}....void pl| 00000980 61 79 65 72 73 65 6c 65 63 74 28 29 0d 0a 7b 0d |ayerselect()..{.| 00000990 0a 09 69 6e 74 20 63 3d 30 2c 66 6c 61 67 3d 46 |..int c=0,flag=F| 000009a0 41 4c 53 45 3b 0d 0a 0d 0a 09 63 75 72 73 6f 72 |ALSE;.....cursor| 000009b0 28 78 78 2c 79 79 2c 4f 4e 29 3b 0d 0a 09 77 68 |(xx,yy,ON);...wh| 000009c0 69 6c 65 20 28 21 66 6c 61 67 29 0d 0a 09 7b 0d |ile (!flag)...{.| 000009d0 0a 09 09 77 68 69 6c 65 20 28 28 63 3d 69 6e 6b |...while ((c=ink| 000009e0 65 79 28 29 29 20 21 3d 20 30 78 30 64 29 0d 0a |ey()) != 0x0d)..| 000009f0 09 09 7b 0d 0a 09 09 09 69 66 20 28 63 20 3d 3d |..{.....if (c ==| 00000a00 20 32 37 29 0d 0a 09 09 09 7b 0d 0a 09 09 09 09 | 27).....{......| 00000a10 63 75 72 73 69 7a 65 28 36 2c 37 29 3b 0d 0a 09 |cursize(6,7);...| 00000a20 09 09 09 65 78 69 74 28 30 29 3b 0d 0a 09 09 09 |...exit(0);.....| 00000a30 7d 0d 0a 09 09 09 69 66 20 28 63 20 21 3d 20 30 |}.....if (c != 0| 00000a40 29 0d 0a 09 09 09 7b 0d 0a 09 09 09 09 63 75 72 |).....{......cur| 00000a50 73 6f 72 28 78 78 2c 79 79 2c 4f 46 46 29 3b 0d |sor(xx,yy,OFF);.| 00000a60 0a 09 09 09 09 73 77 69 74 63 68 28 63 29 0d 0a |.....switch(c)..| 00000a70 09 09 09 09 7b 0d 0a 09 09 09 09 09 63 61 73 65 |....{.......case| 00000a80 20 30 78 34 62 3a 20 2d 2d 78 78 3b 20 62 72 65 | 0x4b: --xx; bre| 00000a90 61 6b 3b 0d 0a 09 09 09 09 09 63 61 73 65 20 30 |ak;.......case 0| 00000aa0 78 34 64 3a 20 2b 2b 78 78 3b 20 62 72 65 61 6b |x4d: ++xx; break| 00000ab0 3b 0d 0a 09 09 09 09 09 63 61 73 65 20 30 78 34 |;.......case 0x4| 00000ac0 38 3a 20 2d 2d 79 79 3b 20 62 72 65 61 6b 3b 0d |8: --yy; break;.| 00000ad0 0a 09 09 09 09 09 63 61 73 65 20 30 78 35 30 3a |......case 0x50:| 00000ae0 20 2b 2b 79 79 3b 20 62 72 65 61 6b 3b 0d 0a 09 | ++yy; break;...| 00000af0 09 09 09 7d 0d 0a 09 09 09 09 69 66 20 28 78 78 |...}......if (xx| 00000b00 3c 30 29 20 78 78 3d 37 3b 0d 0a 09 09 09 09 69 |<0) xx=7;......i| 00000b10 66 20 28 78 78 3e 37 29 20 78 78 3d 30 3b 0d 0a |f (xx>7) xx=0;..| 00000b20 09 09 09 09 69 66 20 28 79 79 3c 30 29 20 79 79 |....if (yy<0) yy| 00000b30 3d 37 3b 0d 0a 09 09 09 09 69 66 20 28 79 79 3e |=7;......if (yy>| 00000b40 37 29 20 79 79 3d 30 3b 0d 0a 09 09 09 09 63 75 |7) yy=0;......cu| 00000b50 72 73 6f 72 28 78 78 2c 79 79 2c 4f 4e 29 3b 0d |rsor(xx,yy,ON);.| 00000b60 0a 09 09 09 7d 0d 0a 09 09 7d 0d 0a 09 09 69 66 |....}....}....if| 00000b70 20 28 62 6f 61 72 64 5b 78 78 5d 5b 79 79 5d 20 | (board[xx][yy] | 00000b80 3d 3d 20 30 29 0d 0a 09 09 7b 0d 0a 09 09 09 62 |== 0)....{.....b| 00000b90 6f 61 72 64 5b 78 78 5d 5b 79 79 5d 3d 50 4c 41 |oard[xx][yy]=PLA| 00000ba0 59 45 52 3b 0d 0a 09 09 09 63 75 72 73 6f 72 28 |YER;.....cursor(| 00000bb0 78 78 2c 79 79 2c 4f 46 46 29 3b 0d 0a 09 09 09 |xx,yy,OFF);.....| 00000bc0 75 70 64 61 74 65 73 63 72 65 65 6e 28 78 78 2c |updatescreen(xx,| 00000bd0 79 79 29 3b 0d 0a 09 09 09 66 6c 61 67 3d 54 52 |yy);.....flag=TR| 00000be0 55 45 3b 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 7d 0d |UE;....}...}..}.| 00000bf0 0a 0d 0a 76 6f 69 64 20 65 76 61 6c 75 61 74 65 |...void evaluate| 00000c00 28 29 0d 0a 7b 0d 0a 09 69 6e 74 20 6a 2c 6b 2c |()..{...int j,k,| 00000c10 6c 2c 70 2c 63 2c 78 2c 79 3b 0d 0a 0d 0a 09 66 |l,p,c,x,y;.....f| 00000c20 6f 72 20 28 6a 3d 30 20 3b 20 6a 3c 38 20 3b 20 |or (j=0 ; j<8 ; | 00000c30 2b 2b 6a 29 0d 0a 09 09 66 6f 72 20 28 6b 3d 30 |++j)....for (k=0| 00000c40 20 3b 20 6b 3c 38 20 3b 20 2b 2b 6b 29 0d 0a 09 | ; k<8 ; ++k)...| 00000c50 09 09 77 65 69 67 68 74 69 6e 67 73 5b 6a 5d 5b |..weightings[j][| 00000c60 6b 5d 3d 30 3b 0d 0a 0d 0a 09 66 6f 72 20 28 6a |k]=0;.....for (j| 00000c70 3d 30 20 3b 20 6a 3c 38 20 3b 20 2b 2b 6a 29 0d |=0 ; j<8 ; ++j).| 00000c80 0a 09 7b 0d 0a 20 09 09 66 6f 72 20 28 6b 3d 30 |..{.. ..for (k=0| 00000c90 20 3b 20 6b 3c 35 20 3b 20 2b 2b 6b 29 0d 0a 09 | ; k<5 ; ++k)...| 00000ca0 09 7b 0d 0a 20 09 09 09 70 3d 30 3b 20 63 3d 30 |.{.. ...p=0; c=0| 00000cb0 3b 0d 0a 20 09 09 09 66 6f 72 20 28 6c 3d 30 20 |;.. ...for (l=0 | 00000cc0 3b 20 6c 3c 34 20 3b 20 2b 2b 6c 29 0d 0a 09 09 |; l<4 ; ++l)....| 00000cd0 09 7b 0d 0a 09 09 09 09 73 77 69 74 63 68 20 28 |.{......switch (| 00000ce0 62 6f 61 72 64 5b 6a 5d 5b 6b 2b 6c 5d 29 0d 0a |board[j][k+l])..| 00000cf0 09 09 09 09 7b 0d 0a 09 09 09 09 09 63 61 73 65 |....{.......case| 00000d00 20 31 3a 20 2b 2b 70 3b 20 62 72 65 61 6b 3b 0d | 1: ++p; break;.| 00000d10 0a 09 09 09 09 09 63 61 73 65 20 32 3a 20 2b 2b |......case 2: ++| 00000d20 63 3b 20 62 72 65 61 6b 3b 0d 0a 09 09 09 09 7d |c; break;......}| 00000d30 0d 0a 09 09 09 7d 0d 0a 09 09 09 70 3d 6e 65 77 |.....}.....p=new| 00000d40 28 70 2c 50 4c 41 59 45 52 29 3b 20 63 3d 6e 65 |(p,PLAYER); c=ne| 00000d50 77 28 63 2c 43 4f 4d 50 29 3b 0d 0a 0d 0a 09 09 |w(c,COMP);......| 00000d60 09 69 66 20 28 70 20 3d 3d 20 39 39 39 39 29 20 |.if (p == 9999) | 00000d70 6f 76 65 72 3d 50 4c 41 59 45 52 3b 0d 0a 09 09 |over=PLAYER;....| 00000d80 09 69 66 20 28 63 20 3d 3d 20 39 39 39 39 29 20 |.if (c == 9999) | 00000d90 6f 76 65 72 3d 43 4f 4d 50 3b 0d 0a 0d 0a 09 09 |over=COMP;......| 00000da0 09 69 66 20 28 70 20 3d 3d 20 30 20 26 26 20 63 |.if (p == 0 && c| 00000db0 3e 30 29 0d 0a 09 09 09 09 66 6f 72 20 28 6c 3d |>0)......for (l=| 00000dc0 30 20 3b 20 6c 3c 34 20 3b 20 2b 2b 6c 29 0d 0a |0 ; l<4 ; ++l)..| 00000dd0 09 09 09 09 09 77 65 69 67 68 74 69 6e 67 73 5b |.....weightings[| 00000de0 6a 5d 5b 6b 2b 6c 5d 2b 3d 63 3b 0d 0a 09 09 09 |j][k+l]+=c;.....| 00000df0 69 66 20 28 63 20 3d 3d 20 30 20 26 26 20 70 3e |if (c == 0 && p>| 00000e00 30 29 0d 0a 09 09 09 09 66 6f 72 20 28 6c 3d 30 |0)......for (l=0| 00000e10 20 3b 20 6c 3c 34 20 3b 20 2b 2b 6c 29 0d 0a 09 | ; l<4 ; ++l)...| 00000e20 09 09 09 09 77 65 69 67 68 74 69 6e 67 73 5b 6a |....weightings[j| 00000e30 5d 5b 6b 2b 6c 5d 2b 3d 70 3b 0d 0a 09 09 7d 0d |][k+l]+=p;....}.| 00000e40 0a 09 7d 0d 0a 09 66 6f 72 20 28 6b 3d 30 20 3b |..}...for (k=0 ;| 00000e50 20 6b 3c 38 20 3b 20 2b 2b 6b 29 0d 0a 09 7b 0d | k<8 ; ++k)...{.| 00000e60 0a 09 09 66 6f 72 20 28 6a 3d 30 20 3b 20 6a 3c |...for (j=0 ; j<| 00000e70 35 20 3b 20 2b 2b 6a 29 0d 0a 09 09 7b 0d 0a 09 |5 ; ++j)....{...| 00000e80 09 09 70 3d 30 3b 20 63 3d 30 3b 0d 0a 09 09 09 |..p=0; c=0;.....| 00000e90 66 6f 72 20 28 6c 3d 30 20 3b 20 6c 3c 34 20 3b |for (l=0 ; l<4 ;| 00000ea0 20 2b 2b 6c 29 0d 0a 09 09 09 7b 0d 0a 09 09 09 | ++l).....{.....| 00000eb0 09 73 77 69 74 63 68 20 28 62 6f 61 72 64 5b 6a |.switch (board[j| 00000ec0 2b 6c 5d 5b 6b 5d 29 0d 0a 09 09 09 09 7b 0d 0a |+l][k])......{..| 00000ed0 09 09 09 09 09 63 61 73 65 20 31 3a 20 2b 2b 70 |.....case 1: ++p| 00000ee0 3b 20 62 72 65 61 6b 3b 0d 0a 09 09 09 09 09 63 |; break;.......c| 00000ef0 61 73 65 20 32 3a 20 2b 2b 63 3b 20 62 72 65 61 |ase 2: ++c; brea| 00000f00 6b 3b 0d 0a 09 09 09 09 7d 0d 0a 09 09 09 7d 0d |k;......}.....}.| 00000f10 0a 09 09 09 70 3d 6e 65 77 28 70 2c 50 4c 41 59 |....p=new(p,PLAY| 00000f20 45 52 29 3b 20 63 3d 6e 65 77 28 63 2c 43 4f 4d |ER); c=new(c,COM| 00000f30 50 29 3b 0d 0a 0d 0a 09 09 09 69 66 20 28 70 20 |P);.......if (p | 00000f40 3d 3d 20 39 39 39 39 29 20 6f 76 65 72 3d 50 4c |== 9999) over=PL| 00000f50 41 59 45 52 3b 0d 0a 09 09 09 69 66 20 28 63 20 |AYER;.....if (c | 00000f60 3d 3d 20 39 39 39 39 29 20 6f 76 65 72 3d 43 4f |== 9999) over=CO| 00000f70 4d 50 3b 0d 0a 0d 0a 09 09 09 69 66 20 28 70 20 |MP;.......if (p | 00000f80 3d 3d 20 30 20 26 26 20 63 3e 30 29 0d 0a 09 09 |== 0 && c>0)....| 00000f90 09 09 66 6f 72 20 28 6c 3d 30 20 3b 20 6c 3c 34 |..for (l=0 ; l<4| 00000fa0 20 3b 20 2b 2b 6c 29 0d 0a 09 09 09 09 09 77 65 | ; ++l).......we| 00000fb0 69 67 68 74 69 6e 67 73 5b 6a 2b 6c 5d 5b 6b 5d |ightings[j+l][k]| 00000fc0 2b 3d 63 3b 0d 0a 09 09 09 69 66 20 28 63 20 3d |+=c;.....if (c =| 00000fd0 3d 20 30 20 26 26 20 70 3e 30 29 0d 0a 09 09 09 |= 0 && p>0).....| 00000fe0 09 66 6f 72 20 28 6c 3d 30 20 3b 20 6c 3c 34 20 |.for (l=0 ; l<4 | 00000ff0 3b 20 2b 2b 6c 29 0d 0a 09 09 09 09 09 77 65 69 |; ++l).......wei| 00001000 67 68 74 69 6e 67 73 5b 6a 2b 6c 5d 5b 6b 5d 2b |ghtings[j+l][k]+| 00001010 3d 70 3b 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 09 66 |=p;....}...}...f| 00001020 6f 72 20 28 6a 3d 30 20 3b 20 6a 3c 35 20 3b 20 |or (j=0 ; j<5 ; | 00001030 2b 2b 6a 29 0d 0a 09 7b 0d 0a 09 09 66 6f 72 20 |++j)...{....for | 00001040 28 6b 3d 30 20 3b 20 6b 3c 35 20 3b 20 2b 2b 6b |(k=0 ; k<5 ; ++k| 00001050 29 0d 0a 09 09 7b 0d 0a 20 09 09 09 70 3d 30 3b |)....{.. ...p=0;| 00001060 20 63 3d 30 3b 0d 0a 09 09 09 66 6f 72 20 28 6c | c=0;.....for (l| 00001070 3d 30 20 3b 20 6c 3c 34 20 3b 20 2b 2b 6c 29 0d |=0 ; l<4 ; ++l).| 00001080 0a 09 09 09 7b 0d 0a 09 09 09 09 73 77 69 74 63 |....{......switc| 00001090 68 28 62 6f 61 72 64 5b 6a 2b 6c 5d 5b 6b 2b 6c |h(board[j+l][k+l| 000010a0 5d 29 0d 0a 09 09 09 09 7b 0d 0a 09 09 09 09 09 |])......{.......| 000010b0 63 61 73 65 20 31 3a 20 2b 2b 70 3b 20 62 72 65 |case 1: ++p; bre| 000010c0 61 6b 3b 0d 0a 09 09 09 09 09 63 61 73 65 20 32 |ak;.......case 2| 000010d0 3a 20 2b 2b 63 3b 20 62 72 65 61 6b 3b 0d 0a 09 |: ++c; break;...| 000010e0 09 09 09 7d 0d 0a 09 09 09 7d 0d 0a 09 09 09 70 |...}.....}.....p| 000010f0 3d 6e 65 77 28 70 2c 50 4c 41 59 45 52 29 3b 20 |=new(p,PLAYER); | 00001100 63 3d 6e 65 77 28 63 2c 43 4f 4d 50 29 3b 0d 0a |c=new(c,COMP);..| 00001110 0d 0a 09 09 09 69 66 20 28 70 20 3d 3d 20 39 39 |.....if (p == 99| 00001120 39 39 29 20 6f 76 65 72 3d 50 4c 41 59 45 52 3b |99) over=PLAYER;| 00001130 0d 0a 09 09 09 69 66 20 28 63 20 3d 3d 20 39 39 |.....if (c == 99| 00001140 39 39 29 20 6f 76 65 72 3d 43 4f 4d 50 3b 0d 0a |99) over=COMP;..| 00001150 0d 0a 09 09 09 69 66 20 28 70 20 3d 3d 20 30 20 |.....if (p == 0 | 00001160 26 26 20 63 3e 30 29 0d 0a 09 09 09 09 66 6f 72 |&& c>0)......for| 00001170 20 28 6c 3d 30 20 3b 20 6c 3c 34 20 3b 20 2b 2b | (l=0 ; l<4 ; ++| 00001180 6c 29 0d 0a 09 09 09 09 09 77 65 69 67 68 74 69 |l).......weighti| 00001190 6e 67 73 5b 6a 2b 6c 5d 5b 6b 2b 6c 5d 2b 3d 63 |ngs[j+l][k+l]+=c| 000011a0 3b 0d 0a 09 09 09 69 66 20 28 63 20 3d 3d 20 30 |;.....if (c == 0| 000011b0 20 26 26 20 70 3e 30 29 0d 0a 09 09 09 09 66 6f | && p>0)......fo| 000011c0 72 20 28 6c 3d 30 20 3b 20 6c 3c 34 20 3b 20 2b |r (l=0 ; l<4 ; +| 000011d0 2b 6c 29 0d 0a 09 09 09 09 09 77 65 69 67 68 74 |+l).......weight| 000011e0 69 6e 67 73 5b 6a 2b 6c 5d 5b 6b 2b 6c 5d 2b 3d |ings[j+l][k+l]+=| 000011f0 70 3b 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 09 66 6f |p;....}...}...fo| 00001200 72 20 28 6a 3d 33 20 3b 20 6a 3c 38 20 3b 20 2b |r (j=3 ; j<8 ; +| 00001210 2b 6a 29 0d 0a 09 7b 0d 0a 09 09 66 6f 72 20 28 |+j)...{....for (| 00001220 6b 3d 30 20 3b 20 6b 3c 35 20 3b 20 2b 2b 6b 29 |k=0 ; k<5 ; ++k)| 00001230 0d 0a 09 09 7b 0d 0a 20 09 09 09 70 3d 30 3b 20 |....{.. ...p=0; | 00001240 63 3d 30 3b 0d 0a 09 09 09 66 6f 72 20 28 6c 3d |c=0;.....for (l=| 00001250 30 20 3b 20 6c 3c 34 20 3b 20 2b 2b 6c 29 0d 0a |0 ; l<4 ; ++l)..| 00001260 09 09 09 7b 0d 0a 09 09 09 09 73 77 69 74 63 68 |...{......switch| 00001270 28 62 6f 61 72 64 5b 6a 2d 6c 5d 5b 6b 2b 6c 5d |(board[j-l][k+l]| 00001280 29 0d 0a 09 09 09 09 7b 0d 0a 09 09 09 09 09 63 |)......{.......c| 00001290 61 73 65 20 31 3a 20 2b 2b 70 3b 20 62 72 65 61 |ase 1: ++p; brea| 000012a0 6b 3b 0d 0a 09 09 09 09 09 63 61 73 65 20 32 3a |k;.......case 2:| 000012b0 20 2b 2b 63 3b 20 62 72 65 61 6b 3b 0d 0a 09 09 | ++c; break;....| 000012c0 09 09 7d 0d 0a 09 09 09 7d 0d 0a 09 09 09 70 3d |..}.....}.....p=| 000012d0 6e 65 77 28 70 2c 50 4c 41 59 45 52 29 3b 20 63 |new(p,PLAYER); c| 000012e0 3d 6e 65 77 28 63 2c 43 4f 4d 50 29 3b 0d 0a 0d |=new(c,COMP);...| 000012f0 0a 09 09 09 69 66 20 28 70 20 3d 3d 20 39 39 39 |....if (p == 999| 00001300 39 29 20 6f 76 65 72 3d 50 4c 41 59 45 52 3b 0d |9) over=PLAYER;.| 00001310 0a 09 09 09 69 66 20 28 63 20 3d 3d 20 39 39 39 |....if (c == 999| 00001320 39 29 20 6f 76 65 72 3d 43 4f 4d 50 3b 0d 0a 0d |9) over=COMP;...| 00001330 0a 09 09 09 69 66 20 28 70 20 3d 3d 20 30 20 26 |....if (p == 0 &| 00001340 26 20 63 3e 30 29 0d 0a 09 09 09 09 66 6f 72 20 |& c>0)......for | 00001350 28 6c 3d 30 20 3b 20 6c 3c 34 20 3b 20 2b 2b 6c |(l=0 ; l<4 ; ++l| 00001360 29 0d 0a 09 09 09 09 09 77 65 69 67 68 74 69 6e |).......weightin| 00001370 67 73 5b 6a 2d 6c 5d 5b 6b 2b 6c 5d 2b 3d 63 3b |gs[j-l][k+l]+=c;| 00001380 0d 0a 09 09 09 69 66 20 28 63 20 3d 3d 20 30 20 |.....if (c == 0 | 00001390 26 26 20 70 3e 30 29 0d 0a 09 09 09 09 66 6f 72 |&& p>0)......for| 000013a0 20 28 6c 3d 30 20 3b 20 6c 3c 34 20 3b 20 2b 2b | (l=0 ; l<4 ; ++| 000013b0 6c 29 0d 0a 09 09 09 09 09 77 65 69 67 68 74 69 |l).......weighti| 000013c0 6e 67 73 5b 6a 2d 6c 5d 5b 6b 2b 6c 5d 2b 3d 70 |ngs[j-l][k+l]+=p| 000013d0 3b 0d 0a 09 09 7d 0d 0a 09 7d 0d 0a 7d 0d 0a 0d |;....}...}..}...| 000013e0 0a 76 6f 69 64 20 63 6f 6d 70 75 74 65 72 73 65 |.void computerse| 000013f0 6c 65 63 74 28 29 0d 0a 7b 0d 0a 09 69 6e 74 20 |lect()..{...int | 00001400 74 2c 74 6f 70 2c 78 2c 79 2c 6a 2c 6b 2c 6c 3b |t,top,x,y,j,k,l;| 00001410 0d 0a 09 74 6f 70 3d 30 3b 0d 0a 09 66 6f 72 20 |...top=0;...for | 00001420 28 6a 3d 30 20 3b 20 6a 3c 38 20 3b 20 2b 2b 6a |(j=0 ; j<8 ; ++j| 00001430 29 0d 0a 09 09 66 6f 72 20 28 6b 3d 30 20 3b 20 |)....for (k=0 ; | 00001440 6b 3c 38 20 3b 20 2b 2b 6b 29 0d 0a 09 09 09 69 |k<8 ; ++k).....i| 00001450 66 20 28 62 6f 61 72 64 5b 6a 5d 5b 6b 5d 20 3d |f (board[j][k] =| 00001460 3d 20 30 29 0d 0a 09 09 09 09 69 66 20 28 28 6c |= 0)......if ((l| 00001470 3d 77 65 69 67 68 74 69 6e 67 73 5b 6a 5d 5b 6b |=weightings[j][k| 00001480 5d 29 20 3e 20 74 6f 70 29 0d 0a 09 09 09 09 09 |]) > top).......| 00001490 74 6f 70 3d 6c 3b 0d 0a 09 6c 3d 30 3b 0d 0a 09 |top=l;...l=0;...| 000014a0 66 6f 72 20 28 6a 3d 30 20 3b 20 6a 3c 38 20 3b |for (j=0 ; j<8 ;| 000014b0 20 2b 2b 6a 29 0d 0a 09 09 66 6f 72 20 28 6b 3d | ++j)....for (k=| 000014c0 30 20 3b 20 6b 3c 38 20 3b 20 2b 2b 6b 29 0d 0a |0 ; k<8 ; ++k)..| 000014d0 09 09 09 69 66 20 28 77 65 69 67 68 74 69 6e 67 |...if (weighting| 000014e0 73 5b 6a 5d 5b 6b 5d 20 3d 3d 20 74 6f 70 20 26 |s[j][k] == top &| 000014f0 26 20 62 6f 61 72 64 5b 6a 5d 5b 6b 5d 20 3d 3d |& board[j][k] ==| 00001500 20 30 29 0d 0a 09 09 09 7b 0d 0a 09 09 09 09 63 | 0).....{......c| 00001510 6f 6f 72 64 73 5b 6c 5d 5b 30 5d 3d 6a 3b 0d 0a |oords[l][0]=j;..| 00001520 09 09 09 09 63 6f 6f 72 64 73 5b 6c 5d 5b 31 5d |....coords[l][1]| 00001530 3d 6b 3b 0d 0a 09 09 09 09 2b 2b 6c 3b 0d 0a 09 |=k;......++l;...| 00001540 09 09 7d 0d 0a 09 74 3d 72 6e 64 28 6c 29 3b 0d |..}...t=rnd(l);.| 00001550 0a 0d 0a 09 78 3d 63 6f 6f 72 64 73 5b 74 5d 5b |....x=coords[t][| 00001560 30 5d 3b 0d 0a 09 79 3d 63 6f 6f 72 64 73 5b 74 |0];...y=coords[t| 00001570 5d 5b 31 5d 3b 0d 0a 0d 0a 09 62 6f 61 72 64 5b |][1];.....board[| 00001580 78 5d 5b 79 5d 3d 43 4f 4d 50 3b 0d 0a 09 75 70 |x][y]=COMP;...up| 00001590 64 61 74 65 73 63 72 65 65 6e 28 78 2c 79 29 3b |datescreen(x,y);| 000015a0 0d 0a 7d 0d 0a 0d 0a 69 6e 74 20 6e 65 77 28 6e |..}....int new(n| 000015b0 75 6d 2c 70 6c 61 79 65 72 29 0d 0a 69 6e 74 20 |um,player)..int | 000015c0 6e 75 6d 3b 0d 0a 7b 0d 0a 09 73 77 69 74 63 68 |num;..{...switch| 000015d0 28 6e 75 6d 29 0d 0a 09 7b 0d 0a 09 09 63 61 73 |(num)...{....cas| 000015e0 65 20 28 30 29 3a 20 72 65 74 75 72 6e 28 30 29 |e (0): return(0)| 000015f0 3b 0d 0a 09 09 63 61 73 65 20 28 31 29 3a 20 72 |;....case (1): r| 00001600 65 74 75 72 6e 28 70 6c 61 79 65 72 2a 32 29 3b |eturn(player*2);| 00001610 0d 0a 09 09 63 61 73 65 20 28 32 29 3a 20 72 65 |....case (2): re| 00001620 74 75 72 6e 28 70 6c 61 79 65 72 2a 31 30 29 3b |turn(player*10);| 00001630 0d 0a 09 09 63 61 73 65 20 28 33 29 3a 20 72 65 |....case (3): re| 00001640 74 75 72 6e 28 70 6c 61 79 65 72 2a 37 35 29 3b |turn(player*75);| 00001650 0d 0a 09 09 63 61 73 65 20 28 34 29 3a 20 72 65 |....case (4): re| 00001660 74 75 72 6e 28 39 39 39 39 29 3b 0d 0a 09 7d 0d |turn(9999);...}.| 00001670 0a 09 72 65 74 75 72 6e 28 30 29 3b 0d 0a 7d 0d |..return(0);..}.| 00001680 0a 0d 0a 76 6f 69 64 20 77 6f 6e 28 70 6c 61 79 |...void won(play| 00001690 65 72 29 0d 0a 69 6e 74 20 70 6c 61 79 65 72 3b |er)..int player;| 000016a0 0d 0a 7b 0d 0a 09 69 66 20 28 70 6c 61 79 65 72 |..{...if (player| 000016b0 20 3d 3d 20 50 4c 41 59 45 52 29 0d 0a 09 7b 0d | == PLAYER)...{.| 000016c0 0a 09 09 2b 2b 70 73 63 6f 72 65 3b 0d 0a 09 09 |...++pscore;....| 000016d0 6c 6f 63 61 74 65 28 37 30 2c 32 32 29 3b 0d 0a |locate(70,22);..| 000016e0 09 09 70 72 69 6e 74 28 22 59 4f 55 20 57 49 4e |..print("YOU WIN| 000016f0 22 29 3b 0d 0a 09 09 6c 6f 63 61 74 65 28 36 38 |");....locate(68| 00001700 2c 32 34 29 3b 0d 0a 09 09 70 72 69 6e 74 28 22 |,24);....print("| 00001710 50 72 65 73 73 20 61 20 6b 65 79 22 29 3b 0d 0a |Press a key");..| 00001720 09 09 77 68 69 6c 65 20 28 69 6e 6b 65 79 28 29 |..while (inkey()| 00001730 20 3d 3d 20 30 29 3b 0d 0a 09 09 6c 6f 63 61 74 | == 0);....locat| 00001740 65 28 37 30 2c 32 32 29 3b 0d 0a 09 09 70 72 69 |e(70,22);....pri| 00001750 6e 74 28 22 20 20 20 20 20 20 20 22 29 3b 0d 0a |nt(" ");..| 00001760 09 09 6c 6f 63 61 74 65 28 36 38 2c 32 34 29 3b |..locate(68,24);| 00001770 0d 0a 09 09 70 72 69 6e 74 28 22 20 20 20 20 20 |....print(" | 00001780 20 20 20 20 20 20 22 29 3b 0d 0a 09 7d 0d 0a 09 | ");...}...| 00001790 65 6c 73 65 0d 0a 09 7b 0d 0a 09 09 2b 2b 63 73 |else...{....++cs| 000017a0 63 6f 72 65 3b 0d 0a 09 09 6c 6f 63 61 74 65 28 |core;....locate(| 000017b0 33 2c 32 32 29 3b 0d 0a 09 09 70 72 69 6e 74 28 |3,22);....print(| 000017c0 22 49 20 57 49 4e 22 29 3b 0d 0a 09 09 6c 6f 63 |"I WIN");....loc| 000017d0 61 74 65 28 30 2c 32 34 29 3b 0d 0a 09 09 70 72 |ate(0,24);....pr| 000017e0 69 6e 74 28 22 50 72 65 73 73 20 61 20 6b 65 79 |int("Press a key| 000017f0 22 29 3b 0d 0a 09 09 77 68 69 6c 65 20 28 69 6e |");....while (in| 00001800 6b 65 79 28 29 20 3d 3d 20 30 29 3b 0d 0a 09 09 |key() == 0);....| 00001810 6c 6f 63 61 74 65 28 32 2c 32 32 29 3b 0d 0a 09 |locate(2,22);...| 00001820 09 70 72 69 6e 74 28 22 20 20 20 20 20 20 20 22 |.print(" "| 00001830 29 3b 0d 0a 09 09 6c 6f 63 61 74 65 28 30 2c 32 |);....locate(0,2| 00001840 34 29 3b 0d 0a 09 09 70 72 69 6e 74 28 22 20 20 |4);....print(" | 00001850 20 20 20 20 20 20 20 20 20 22 29 3b 0d 0a 09 7d | ");...}| 00001860 0d 0a 7d 0d 0a |..}..| 00001865