johnc@dartvax.UUCP (John Cabell) (05/29/84)
Well, this group certainly has died recently.
In order to try to get it going again, I have 2
requests. One, will someone please send me a
blank board to use with the board decoder that
was posted some [actually, a loooong] time ago.
I can't seem to get a file with *just* zeros in
it.
Two, would someone like to comment on the
game Pente? I have tried it once and it looks
like a pretty easy game. Maybe we played it
wrong? Anyway, I though that it was easy.
Oh, one other thing. Would anyone like to
play a game of GO? I am strictly a beginner,
but I'd like to learn more and try playing with
someone that relly knows how to play.
--johnc
[ Astrovax, linus, decvax, cornell ] !dartvax!johncchuqui@nsc.UUCP (05/30/84)
here are the programs. It is in shar format (cut off the header and feed to
the shell). There will be three programs and a header file. Encode and
Decode are self explanitory. mkboard should be piped into the standard
input of decode to create a blank board.
]
chuq
#! /bin/sh
# The rest of this file is a shell script which will extract:
# decode.c encode.c mkboard.c go.h
echo x - decode.c
cat >decode.c <<'!!ChuquiCo!!Software!!'
#ifdef HEADERS
From: tbray@mprvaxa.UUCP (Tim Bray)
Subject: encode.c, decode.c, go.h
Date: Sun, 29-Jan-84 14:48:56 PST
Organization: Microtel Pacific Research, Burnaby BC
#endif HEADERS
/* decode - take a compressed representation of a go board and
* produce a picture thereof
* T. Bray, Jan. 29, 1984. This software is hereby made freely available
* to everyone, who are collectively welcomed to do anything to
* it that will not frighten horses in the street.
*/
#include <stdio.h>
#include "go.h"
main()
{
int i,row,col,value;
unsigned char mark();
if (read(0, rep, 200) != 200)
{
fprintf(stderr, "Can't read 200 bytes of representation - exiting.\n");
exit();
}
/* shuffle the compressed form into the the intermediate 'expand' array
*/
for(i=0; i<181; i++)
{
static unsigned char holder[3] = " ";
holder[0] = rep[i]; /* inefficient */
sscanf(holder, "%x", &value); /* hex-to-ascii */
expand[(i * 2) + 1] = value & 3; /* get two high bits */
expand[i * 2] = value >> 2; /* two low bits */
}
/* build the picture from 'expand'
*/
row = col = 0;
for(i=0; i<361; i++)
{
picture[row + TOP][(col++ * 2) + LEFT] = mark(i, expand[i]);
if (col == 19)
{
row++;
col = 0;
}
}
/* draw
*/
for(i = 0; i < (ROWS - 1); i++)
printf("%s\n", picture[i]);
rep[185] = rep[189] = 0;
printf(picture[ROWS - 1], BLACKCHAR, atoi(rep + 182),
WHITECHAR, atoi(rep + 186));
printf("\n");
}
/* figure out what to put in a spot. Necessary for correctly showing
* handicap points
*/
unsigned char
mark(place, value)
int place, value;
{
switch (value)
{
case BLACK: return(BLACKCHAR);
case WHITE: return(WHITECHAR);
default: /* gotta be clear */
if (place == 60 || place == 66 || place == 72 ||
place == 174 || place == 180 || place == 186 ||
place == 288 || place == 294 || place == 300)
return(CLEARHANDI);
else
return(CLEARCHAR);
}
}
!!ChuquiCo!!Software!!
echo x - encode.c
cat >encode.c <<'!!ChuquiCo!!Software!!'
#ifdef HEADERS
From: tbray@mprvaxa.UUCP (Tim Bray)
Subject: encode.c, decode.c, go.h
Date: Sun, 29-Jan-84 14:48:56 PST
Organization: Microtel Pacific Research, Burnaby BC
#endif HEADERS
/* encode - take a picture of a go board and produce a compressed
* representation.
* T. Bray, Jan. 29, 1984. This software is hereby made freely available
* to everyone, who are collectively welcomed to do anything to
* it that will not frighten horses in the street.
*/
#include <stdio.h>
#include "go.h"
main()
{
int i,row,col,value;
char *cp;
for(i=0; i<ROWS; i++)
{
if (gets(picture[i]) == NULL)
{
fprintf(stderr, "Board contains too few lines.\n");
exit();
}
}
/* shuffle the picture into the intermediate 'expand' array
*/
row = col = 0;
for(i=0; i<361; i++)
{
switch (picture[row + TOP][(col++ * 2) + LEFT])
{
case CLEARCHAR:
case CLEARHANDI:
expand[i] = CLEAR; break;
case BLACKCHAR: expand[i] = BLACK; break;
case WHITECHAR: expand[i] = WHITE; break;
case 0:
fprintf(stderr,
"Board row number %d is too short - exiting.\n",row);
exit();
default:
fprintf(stderr,
"Illegal character on board: %c - exiting.\n",
picture[row + 1][(col - 1) * 2 + 2]);
exit();
}
if (col == 19)
{
row++;
col = 0;
}
}
/* shuffle 'expand' into the 2 points/hex digit representation
*/
for(i=0; i<181; i++)
sprintf(rep + i, "%.1x", (expand[i * 2] << 2) | expand[(i * 2) + 1]);
/* grab the last line with the captured stone counts
*/
for(cp = (char *) picture[ROWS - 1]; *cp != ':'; cp++);
for(; *cp != BLACKCHAR; cp++);
cp += 2;
for(i=0; *cp != ' '; i++)
rep[182 + i] = *cp++;
for(; *cp != WHITECHAR; cp++);
cp += 2;
for(i=0; *cp != ' '; i++)
rep[186 + i] = *cp++;
write(1, rep, 200);
close(1);
}
!!ChuquiCo!!Software!!
echo x - mkboard.c
cat >mkboard.c <<'!!ChuquiCo!!Software!!'
#include <stdio.h>
main()
{
int i,j;
for (i = 0 ; i < 19 ; i++)
for (j = 0; j < 19; j++)
putchar('0');
putchar('\n');
}
!!ChuquiCo!!Software!!
echo x - go.h
cat >go.h <<'!!ChuquiCo!!Software!!'
#ifdef HEADERS
From: tbray@mprvaxa.UUCP (Tim Bray)
Subject: encode.c, decode.c, go.h
Date: Sun, 29-Jan-84 14:48:56 PST
Organization: Microtel Pacific Research, Burnaby BC
#endif HEADERS
/* magic numbers */
#define CLEAR 0 /* 2-bit encodings */
#define WHITE 1
#define BLACK 2
#define ROWS 23 /* picture dimensions */
#define COLUMNS 128
#define TOP 2 /* A1 co-ordinates */
#define LEFT 5
#define WHITECHAR 'O' /* black stone looks like this */
#define BLACKCHAR '@' /* white stone " " " */
#define CLEARCHAR '.' /* empty point " " " */
#define CLEARHANDI '+' /* handicap point " " " */
unsigned char picture[ROWS][COLUMNS] =
{
" A B C D E F G H I J K L M O P Q R S T",
" | | | | | | | | | | | | | | | | | | |",
" 1 - -",
" 2 - -",
" 3 - -",
" 4 - -",
" 5 - -",
" 6 - -",
" 7 - -",
" 8 - -",
" 9 - -",
"10 - -",
"11 - -",
"12 - -",
"13 - -",
"14 - -",
"15 - -",
"16 - -",
"17 - -",
"18 - -",
"19 - -",
" | | | | | | | | | | | | | | | | | | |",
" Captured stones: %c %d, %c %d " /*last line looks like this */
};
unsigned char rep[200],expand[362];
!!ChuquiCo!!Software!!
--
>From the closet of anxieties of: Chuq Von Rospach
{amd70,fortune,hplabs,ihnp4}!nsc!chuqui (408) 733-2600 x242
I'm sure I have my death ray in here somewhere...