billr@saab.CNA.TEK.COM (Bill Randle) (11/20/90)
Submitted-by: Adrian Mariano <theorem@blake.u.washington.edu>
Posting-number: Volume 11, Issue 67
Archive-name: igo/Part02
Environment: BSD Unix, INET sockets
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 2 (of 2)."
# Contents: backup.c changes.c chkmve.c curse.c del.c dohand.c
# doloop.c exit.c fill.c go.c handicap.c help.c init.c initboard.c
# kill.c life.c loop.c looputil.c mesg.c movecur.c moveto.c nomove.c
# plt.c printboard.c putpiece.c score.c setboard.c status.c
# std.disclaimer strength.c tally.c traps.c util.c var.c
# Wrapped by billr@saab on Fri Nov 16 10:44:33 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'backup.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'backup.c'\"
else
echo shar: Extracting \"'backup.c'\" \(1386 characters\)
sed "s/^X//" >'backup.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xint ohama[2] = {
X 0, 0
X};
Xstatic int ocur;
Xstatic BOARD lastboard;
Xint lhama[2] = {
X 0, 0
X};
X
X
Xsaveboard () {
X int i,
X j;
X ocur = curplr;
X ohama[0] = hama[0];
X ohama[1] = hama[1];
X
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++)
X backup.d[i][j] = board.d[i][j];
X}
X
Xsaveboard0 () {
X int i,
X j;
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++)
X backup.d[i][j] = lastboard.d[i][j];
X}
X
Xsavelast () {
X int i,
X j;
X lhama[0] = hama[0];
X lhama[1] = hama[1];
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++)
X lastboard.d[i][j] = board.d[i][j];
X}
X
Xrestlast () {
X int i,
X j;
X hama[0] = lhama[0];
X hama[1] = lhama[1];
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++) {
X if (board.d[i][j] != lastboard.d[i][j]) {
X Plt (&lastboard, i, j);
X }
X board.d[i][j] = lastboard.d[i][j];
X }
X}
X
Xrestboard () {
X int i,
X j;
X hama[0] = ohama[0];
X hama[1] = ohama[1];
X curplr = ocur;
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++)
X board.d[i][j] = backup.d[i][j];
X}
X
Xint compboard () {
X int i,
X j;
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++)
X if (board.d[i][j] != backup.d[i][j])
X return (-1);
X return (0);
X}
END_OF_FILE
if test 1386 -ne `wc -c <'backup.c'`; then
echo shar: \"'backup.c'\" unpacked with wrong size!
fi
# end of 'backup.c'
fi
if test -f 'changes.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'changes.c'\"
else
echo shar: Extracting \"'changes.c'\" \(819 characters\)
sed "s/^X//" >'changes.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X
Xchanges () {
X printf ("\
X----------------------------------------------------------------------\n\
X\n\
X %s\n\
X By Greg Hale\n\
X Enhancements by Adrian Mariano\n\
X\n\
XWelcome to the oriental game of Go. If you do not know how to play,\n\
XI recommend that you read the documentation or find someone who knows\n\
Xhow to play.\n\
X\n\
XThis program was developed at the Experimental Computing Facility at the\n\
XUniversity of California, Berkeley, by Greg Hale and enhanced by Adrian\n\
XMariano at the University of Washington. Thanks to all the\n\
Xother members for their input, support, and test playing.\n\
X\n\
X----------------------------------------------------------------------\n \
X[Hit return to continue]\n\n",VERSION);
X getchar ();
X}
END_OF_FILE
if test 819 -ne `wc -c <'changes.c'`; then
echo shar: \"'changes.c'\" unpacked with wrong size!
fi
# end of 'changes.c'
fi
if test -f 'chkmve.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'chkmve.c'\"
else
echo shar: Extracting \"'chkmve.c'\" \(1165 characters\)
sed "s/^X//" >'chkmve.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xchkmve (c)
Xchar c;
X{
X switch (c) {
X WHEN '4':
X case 'h':
X movecur (-1, 0);
X return (1);
X WHEN '2':
X case 'j':
X movecur (0, 1);
X return (1);
X WHEN '8':
X case 'k':
X movecur (0, -1);
X return (1);
X WHEN '6':
X case 'l':
X movecur (1, 0);
X return (1);
X WHEN '7':
X case 'y':
X movecur (-1, -1);
X return (1);
X WHEN '9':
X case 'u':
X movecur (1, -1);
X return (1);
X WHEN '1':
X case 'b':
X movecur (-1, 1);
X return (1);
X WHEN '3':
X case 'n':
X movecur (1, 1);
X return (1);
X WHEN 'H':
X movecur (-FASTMOVE, 0);
X return (1);
X WHEN 'J':
X movecur (0, FASTMOVE);
X return (1);
X WHEN 'K':
X movecur (0, -FASTMOVE);
X return (1);
X WHEN 'L':
X movecur (FASTMOVE, 0);
X return (1);
X WHEN 'Y':
X movecur (-FASTMOVE, -FASTMOVE);
X return (1);
X WHEN 'U':
X movecur (FASTMOVE, -FASTMOVE);
X return (1);
X WHEN 'B':
X movecur (-FASTMOVE, FASTMOVE);
X return (1);
X WHEN 'N':
X movecur (FASTMOVE, FASTMOVE);
X return (1);
X OTHERWISE:
X return (0);
X }
X}
END_OF_FILE
if test 1165 -ne `wc -c <'chkmve.c'`; then
echo shar: \"'chkmve.c'\" unpacked with wrong size!
fi
# end of 'chkmve.c'
fi
if test -f 'curse.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'curse.c'\"
else
echo shar: Extracting \"'curse.c'\" \(1210 characters\)
sed "s/^X//" >'curse.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
X
Xint curpos = 0;
X#define OFFX (2*MAXX+2)
X#define MAXL 23
X
Xconnectmes () {
X extern char *myname,
X myhostname[];
X mvaddstr (0, 0, "Waiting for other player to type 'go user@host.net' ");
X refresh ();
X}
X
Xdoneconnectmes () {
X clear ();
X refresh ();
X}
X
XCLEAR () {
X clear ();
X refresh ();
X}
X
XDoQuit () {
X char c;
X homemes ();
X addmes ("- Opponent wants to score and quit. Do you accept? (y/n)");
X Beep ();
X do
X c = GetAKey0 ();
X while (c != 'y' && c != 'n');
X if (c == 'y') {
X SEND (MACCEPT);
X Score ();
X }
X else {
X dodecline ();
X SEND (MDECLINE);
X }
X move (0, 0);
X clrtoeol ();
X refresh ();
X}
X
X
X#define mesgy 1
X#define mesgy2 5
X#define mesgx 42
X
Xhomemes () {
X int y;
X for (y = mesgy; y < mesgy2; y++) {
X move (y, mesgx);
X clrtoeol ();
X }
X}
X
Xaddmes (mes)
Xchar *mes;
X{
X do {
X move (curpos + mesgy, mesgx);
X printw ("%.35s", mes);
X curpos = (curpos + 1) % (mesgy2 - mesgy + 1);
X move (curpos + mesgy, mesgx);
X clrtoeol ();
X if (strlen (mes) <= 35)
X break;
X else
X mes += 35;
X }
X while (1);
X refresh ();
X}
X
Xbeginline () {
X move (curpos + mesgy, OFFX);
X}
END_OF_FILE
if test 1210 -ne `wc -c <'curse.c'`; then
echo shar: \"'curse.c'\" unpacked with wrong size!
fi
# end of 'curse.c'
fi
if test -f 'del.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'del.c'\"
else
echo shar: Extracting \"'del.c'\" \(137 characters\)
sed "s/^X//" >'del.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xdeletes (x, y)
Xint x,
X y;
X{
X InitBoard (&marks);
X killit (x, y, b (x, y));
X}
END_OF_FILE
if test 137 -ne `wc -c <'del.c'`; then
echo shar: \"'del.c'\" unpacked with wrong size!
fi
# end of 'del.c'
fi
if test -f 'dohand.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dohand.c'\"
else
echo shar: Extracting \"'dohand.c'\" \(460 characters\)
sed "s/^X//" >'dohand.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XDoHand (x, y, c)
Xint x,
X y,
X c;
X{
X
X sethand (x, y, (b (x, y) == c + 1 ? 0 : c + 1));
X printscore ();
X}
X
Xsethand (x, y, v)
Xint x,
X y,
X v;
X{
Xextern int handicaps;
X if (b (x, y) != v) {
Xif (AreWe(HANDICAP)) {
X if (v) handicaps++;
X else handicaps--;
X }
X b (x, y) = v;
X dolog (x, y, v);
X Plt (&board, x, y);
X SEND (MHANDICAP);
X SendCoord (x, y);
X sendint (v);
X }
X}
END_OF_FILE
if test 460 -ne `wc -c <'dohand.c'`; then
echo shar: \"'dohand.c'\" unpacked with wrong size!
fi
# end of 'dohand.c'
fi
if test -f 'doloop.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'doloop.c'\"
else
echo shar: Extracting \"'doloop.c'\" \(2071 characters\)
sed "s/^X//" >'doloop.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xextern int mesflg,
X loadflg,
X inverse;
X
X
XDoLoop () {
X char c;
X c = GetAKey0 ();
X if (mesflg)
X domesg (c);
X else
X if ((c == 'e') || (!chkmve (c) && !disable)) {
X switch (c) {
X WHEN REDRAW:
X DoRedraw ();
X#ifdef EVILCODE
X WHEN 'e':
X SetStat (EXIT);
X SEND (MEXIT);
X#endif
X
X WHEN 'V':
X if (inverse) {
X for (c = 0; c < 6; c++)
X pieces[c] -= 128;
X inverse = 0;
X }
X else {
X for (c = 0; c < 6; c++)
X pieces[c] += 128;
X inverse = 128;
X }
X DoRedraw ();
X WHEN 'S':
X dosave ();
X WHEN '#':
X doload ();
X WHEN 'q':
X if (AreWe (SCORE)) {
X SEND (MQUIT);
X disable = 1;
X }
X WHEN 't':
X if (AreWe (SCORE))
X dotally ();
X
X WHEN 'c':
X if (AreWe (SCORE)) {
X docancel ();
X SEND (MCANCEL);
X }
X
X WHEN 'C':
X if (verify ("Clear the board (y/n)?")) {
X SEND (MCLEAR);
X doclear ();
X }
X
X WHEN 'm':
X mesflg++;
X
X WHEN 'R':
X if (verify ("Resign (y/n)?")) {
X SEND (MRESIGN);
X doresign (true);
X }
X
X WHEN 's':
X if (AreWe (HANDICAP)) {
X SEND (MSWITCH);
X doswitch ();
X }
X else
X if (AreWe (PLAY)) {
X SEND (MSCORE);
X doscore ();
X }
X
X WHEN '/':
X if (AreWe (PLAY)) {
X ShowLast ();
X }
X else
X Beep ();
X WHEN 'p':
X if (AreWe (PLAY) && myturn) {
X curplr = !curplr;
X SEND (MPASS);
X }
X else
X if (AreWe (HANDICAP)) {
X SEND (MPLAY);
X doplay ();
X printscore ();
X }
X WHEN '?':
X help ();
X PrintBoard (&board);
X
X WHEN 'z':
X if (AreWe(PLAY)) DoHand (cx, cy, 0);
X WHEN 'x':
X if (AreWe(PLAY)) DoHand (cx, cy, 1);
X
X WHEN ' ':
X case '0':
X if (AreWe (HANDICAP))
X sethand (cx, cy, !b (cx, cy));
X else
X if (AreWe (SCORE))
X doscorehit (cx, cy);
X else
X if (AreWe (PLAY) && myturn)
X putpiece (cx, cy, curplr, true, true);
X printscore ();
X OTHERWISE:
X ;
X }
X }
X}
END_OF_FILE
if test 2071 -ne `wc -c <'doloop.c'`; then
echo shar: \"'doloop.c'\" unpacked with wrong size!
fi
# end of 'doloop.c'
fi
if test -f 'exit.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'exit.c'\"
else
echo shar: Extracting \"'exit.c'\" \(118 characters\)
sed "s/^X//" >'exit.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
XExit () {
X unsetmode ();
X endwin ();
X closelog ();
X exit (0);
X}
END_OF_FILE
if test 118 -ne `wc -c <'exit.c'`; then
echo shar: \"'exit.c'\" unpacked with wrong size!
fi
# end of 'exit.c'
fi
if test -f 'fill.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'fill.c'\"
else
echo shar: Extracting \"'fill.c'\" \(412 characters\)
sed "s/^X//" >'fill.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xstatic int fillwith;
X
Xfill (x, y, type)
Xint x,
X y,
X type;
X{
X fillwith = type;
X InitBoard (&marks);
X fill0 (x, y);
X}
X
Xfill0 (x, y)
Xint x,
X y;
X{
X if (ir (x, y) and b (x, y) == NONE and m (x, y) == NONE) {
X m (x, y) = MARK;
X b (x, y) = fillwith;
X fill0 (x - 1, y);
X fill0 (x + 1, y);
X fill0 (x, y - 1);
X fill0 (x, y + 1);
X }
X}
END_OF_FILE
if test 412 -ne `wc -c <'fill.c'`; then
echo shar: \"'fill.c'\" unpacked with wrong size!
fi
# end of 'fill.c'
fi
if test -f 'go.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'go.c'\"
else
echo shar: Extracting \"'go.c'\" \(233 characters\)
sed "s/^X//" >'go.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xmain (argc, argv, envp)
Xint argc;
Xchar **argv,
X **envp;
X{
X if (argc <= 1)
X helpstart (argv);
X parseline (argc, argv);
X
X sockmask[0] = 1;
X
X
X main0 (argc, argv, envp);
X}
END_OF_FILE
if test 233 -ne `wc -c <'go.c'`; then
echo shar: \"'go.c'\" unpacked with wrong size!
fi
# end of 'go.c'
fi
if test -f 'handicap.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'handicap.c'\"
else
echo shar: Extracting \"'handicap.c'\" \(1445 characters\)
sed "s/^X//" >'handicap.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
X#define MAXHANDICAPS 9
X
Xhcap(x,y,log)
Xint x,y,log;
X{
X extern FILE *logfile;
X cx = x;
X cy = y;
X Handicap(!b(x,y));
X if (log) fprintf(logfile,"[%c%c]",x+'a',y+'a');
X}
X
Xsethandi()
X{
X extern int handicaps,handin;
X int savelog;
X extern int logflg;
X extern FILE *logfile;
X
X int h;
X h = handicaps;
X if (h>MAXHANDICAPS) h=MAXHANDICAPS;
X SetStat(HANDICAP);
X if (h<2) return;
X if (savelog=logflg) {
X logflg=0;
X fprintf(logfile,"AddBlack");
X }
X switch (h) {
X case 5:
X hcap(MAXX/2,MAXY/2,savelog);
X case 4:
X hcap(handin,MAXY-1-handin,savelog);
X case 3:
X hcap(MAXX-1-handin,handin,savelog);
X case 2:
X hcap(MAXX-1-handin,MAXY-1-handin,savelog);
X hcap(handin,handin,savelog);
X break;
X case 7:
X hcap(MAXX/2,MAXY/2,savelog);
X case 6:
X hcap(handin,handin,savelog);
X hcap(MAXX-1-handin,MAXY-1-handin,savelog);
X hcap(MAXX-1-handin,handin,savelog);
X hcap(handin,MAXY-1-handin,savelog);
X hcap(handin,MAXY/2,savelog);
X hcap(MAXX-1-handin,MAXY/2,savelog);
X break;
X case 9:
X hcap(MAXX/2,MAXY/2,savelog);
X case 8:
X hcap(handin,handin,savelog);
X hcap(MAXX-1-handin,MAXY-1-handin,savelog);
X hcap(MAXX-1-handin,handin,savelog);
X hcap(handin,MAXY-1-handin,savelog);
X hcap(handin,MAXY/2,savelog);
X hcap(MAXX-1-handin,MAXY/2,savelog);
X hcap(MAXX/2,handin,savelog);
X hcap(MAXX/2,MAXY-1-handin,savelog);
X break;
X }
X if (logflg=savelog) fprintf(logfile,"\n");
X
X}
X
X
X
X
X
END_OF_FILE
if test 1445 -ne `wc -c <'handicap.c'`; then
echo shar: \"'handicap.c'\" unpacked with wrong size!
fi
# end of 'handicap.c'
fi
if test -f 'help.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'help.c'\"
else
echo shar: Extracting \"'help.c'\" \(1253 characters\)
sed "s/^X//" >'help.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
X#define FD_INPUT 0
X
Xstatic char c;
X
Xhelp()
X{
X clear();
X refresh();
X printf("\n\
X-- %s: by Greg Hale --\n\
X[12346789hjklyubnHJKLYUBN]: cursor movement.\n\
X<space>,[0]:select current point. (put/remove a stone or structure)\n\
X[p]: start play/pass your turn.\n\
X[q]: quit and print score. (CHOOSE AFTER SCORING)\n\
X[R]: resign and give the win to the other player.\n\
X[m]: send a message to the other player.\n\
X press control-D exit.\n\
X[s]: switch which player you are (black/white) in handicap mode,\n\
X or turn on scoring mode when playing.\n\
X[t]: tally (show how territory is defined in scoring mode)\n\
X[c]: cancel scoring mode and restore game.\n\
X[C]: clear the board.\n\
X[^c]: leave the game.\n\
X[^l]: redraw the screen.\n\
X[/]: show the last move.\n\
X[?]: help.\n\
X[V]: toggle inverse <-> normal video.\n\
X[#]: load a saved game.\n\
X[S]: save the current board, turn, and score.\n\
X[z][x]: set and unset moves for demonstrations.\n\
X\n\
X<hit any key to continue>",VERSION);
X
X refresh();
X GetAKey0();
X clear();
X }
X
X
X longhelp()
X {
X system(HELP_CMD);
X exit(0);
X }
X
END_OF_FILE
if test 1253 -ne `wc -c <'help.c'`; then
echo shar: \"'help.c'\" unpacked with wrong size!
fi
# end of 'help.c'
fi
if test -f 'init.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'init.c'\"
else
echo shar: Extracting \"'init.c'\" \(517 characters\)
sed "s/^X//" >'init.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include <signal.h>
X#include "go.h"
XInit () {
X extern int tstp ();
X int max,
X myts_tp (), myts_cont ();
X
X MAXX = dimensions;
X MAXY = dimensions;
X
X initscr ();
X/* signal (SIGTSTP, myts_tp);
X signal (SIGCONT, myts_cont);*/
X setmode ();
X
X clear ();
X refresh ();
X InitBoard (&board);
X SetStat (HANDICAP);
X}
X
Xsetmode () {
X /* cbreak(); */
X noecho ();
X crmode ();
X}
X
Xunsetmode () {
X /* nocbreak(); */
X echo ();
X nocrmode ();
X}
END_OF_FILE
if test 517 -ne `wc -c <'init.c'`; then
echo shar: \"'init.c'\" unpacked with wrong size!
fi
# end of 'init.c'
fi
if test -f 'initboard.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'initboard.c'\"
else
echo shar: Extracting \"'initboard.c'\" \(189 characters\)
sed "s/^X//" >'initboard.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
XInitBoard (br)
XBOARD * br;
X{
X int x,
X y;
X for (y = 0; y < MAXY; y++)
X for (x = 0; x < MAXX; x++)
X br -> d[x][y] = NONE;
X}
END_OF_FILE
if test 189 -ne `wc -c <'initboard.c'`; then
echo shar: \"'initboard.c'\" unpacked with wrong size!
fi
# end of 'initboard.c'
fi
if test -f 'kill.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'kill.c'\"
else
echo shar: Extracting \"'kill.c'\" \(620 characters\)
sed "s/^X//" >'kill.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
X
XKill (x, y, type)
Xint x,
X y,
X type;
X{
X int t;
X InitBoard (&marks);
X t = !(type - 1) + 1;
X if (!IsSafe (x - 1, y))
X killit (x - 1, y, t);
X if (!IsSafe (x + 1, y))
X killit (x + 1, y, t);
X if (!IsSafe (x, y - 1))
X killit (x, y - 1, t);
X if (!IsSafe (x, y + 1))
X killit (x, y + 1, t);
X}
X
X
Xkillit (x, y, t)
Xint x,
X y,
X t;
X{
X if (ir (x, y) && b (x, y) == t && t != NONE) {
X setboard (x, y, NONE);
X Plt (&board, x, y);
X killit (x - 1, y, t);
X killit (x + 1, y, t);
X killit (x, y - 1, t);
X killit (x, y + 1, t);
X }
X}
END_OF_FILE
if test 620 -ne `wc -c <'kill.c'`; then
echo shar: \"'kill.c'\" unpacked with wrong size!
fi
# end of 'kill.c'
fi
if test -f 'life.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'life.c'\"
else
echo shar: Extracting \"'life.c'\" \(1298 characters\)
sed "s/^X//" >'life.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XIsSafe (x, y)
Xint x,
X y;
X{
X int t;
X if (!ir (x, y) || (t = b (x, y)) == NONE)
X return (false);
X InitBoard (&marks);
X return (esc (x, y, t));
X}
X
Xesc (x, y, t)
Xint x,
X y,
X t;
X{
X if (!ir (x, y))
X return (false);
X if (b (x, y) == NONE)
X return (true);
X if (!m (x, y) && b (x, y) == t) {
X m (x, y) = MARK;
X return (esc (x - 1, y, t) ||
X esc (x + 1, y, t) ||
X esc (x, y - 1, t) ||
X esc (x, y + 1, t));
X }
X return (false);
X}
X
X
XOwner (x, y)
Xint x,
X y;
X{
X int o;
X InitBoard (&marks);
X o = Owner0 (x, y);
X return (o == -1 ? 3 : o);
X}
X
XOwner0 (x, y)
Xint x,
X y;
X{
X int c,
X n;
X if (m (x, y) || !ir (x, y))
X return 3;
X m (x, y) = 1;
X if (b (x, y) != NONE)
X return (b (x, y) + 3);
X return (New (New (New (New (3, x - 1, y), x + 1, y), x, y - 1), x, y + 1));
X
X}
X
XNew (o, x2, y2) /* 3= undetermined, 4=p1, 5=p2, -1=shared */
Xreg int o;
Xint x2,
X y2;
X{
X reg int n; /* old, new */
X n = Owner0 (x2, y2);
X if (o == 3)
X return n;
X if (n == 3)
X return o;
X if (o < 0)
X return o;
X return (n == o ? o : -1);
X}
X
Xint ir (x, y)
Xint x,
X y;
X{
X return ((x >= 0) && (x < MAXX) && (y >= 0) && (y < MAXY));
X}
END_OF_FILE
if test 1298 -ne `wc -c <'life.c'`; then
echo shar: \"'life.c'\" unpacked with wrong size!
fi
# end of 'life.c'
fi
if test -f 'loop.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'loop.c'\"
else
echo shar: Extracting \"'loop.c'\" \(1236 characters\)
sed "s/^X//" >'loop.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X#include <strings.h>
X
X
Xextern int errno;
Xextern int mesflg,
X curx,
X cury;
X
X
XLoop () {
X int mask,
X res;
X char message[20];
X homemes ();
X /* strcpy(message,"- "); strcat(message,VERSION); strcat(message," By Greg Hale"); addmes(message); */ addmes ("- Set up handicap.");
X addmes ("- Press 'p' to play");
X
X do {
X myturn = (!player && curplr) || (player && !curplr);
X
X if (AreWe (PLAY)) {
X if (myturn) {
X notify (" Your turn");
X }
X else
X notify (" Waiting for opponent");
X }
X else
X if (AreWe (HANDICAP)) {
X notify (" Set Handicap");
X }
X else
X if (AreWe (SCORE)) {
X notify (" Scoring");
X }
X else {
X notify (" What are we doing??");
X }
X
X if (mesflg)
X move (cury, curx);
X else
X moveto (cx, cy);
X
X refresh ();
X
X mask = sockmask[0] | sockmask[1];
X if (select (32, &mask, 0, 0, 0) == -1) {
X if (errno == EINTR) {
X continue;
X }
X else
X error (" Error- Select failed\n");
X }
X if (mask & sockmask[0]) {
X DoLoop ();
X }
X else
X if (mask == sockmask[1]) {
X myturn = !myturn;
X DoOther ();
X }
X else
X error (" Error - bad select\n");
X
X }
X while (!AreWe (EXIT));
X}
END_OF_FILE
if test 1236 -ne `wc -c <'loop.c'`; then
echo shar: \"'loop.c'\" unpacked with wrong size!
fi
# end of 'loop.c'
fi
if test -f 'looputil.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'looputil.c'\"
else
echo shar: Extracting \"'looputil.c'\" \(808 characters\)
sed "s/^X//" >'looputil.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
X#define WAITTIME 2
X#define MVSCORE move(4,45);
X#define MVMESG move(20,1);
X
Xchar *msg0,
X *msg1,
X *sc0,
X *sc1,
X *sc2,
X *m0,
X *m1,
X *s1,
X *s2,
X *message;
X
Xint koflg;
Xint mes0time;
Xint mes1time;
Xint turn;
Xint tally;
Xchar c;
Xbool done;
Xbool sflg;
X
X
XNextPlr () {
X curplr = !curplr;
X turn++;
X if (done)
X done--;
X}
X
X
XFillit (i, x, y)
Xint i,
X x,
X y;
X{
X fill (x, y, i);
X PrintBoard (&board);
X}
X
X
XHandicap (i)
Xint i;
X{
Xint savehand;
Xextern int handicaps;
X savehand=handicaps;
X if (AreWe (HANDICAP))
X sethand (cx, cy, i);
X handicaps=savehand;
X}
X
X
Xdotally () {
X savelast ();
X Tally ();
X PrintBoard (&board);
X GetAKey ();
X restlast ();
X}
END_OF_FILE
if test 808 -ne `wc -c <'looputil.c'`; then
echo shar: \"'looputil.c'\" unpacked with wrong size!
fi
# end of 'looputil.c'
fi
if test -f 'mesg.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'mesg.c'\"
else
echo shar: Extracting \"'mesg.c'\" \(1825 characters\)
sed "s/^X//" >'mesg.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xextern char *opponent;
X
Xint mesgx = 42;
Xint mesgy = 7;
Xint mesgx2 = 78;
Xint mesgy2 = 14;
X
X
Xint talkx = 42;
Xint talky = 16;
Xint talkx2 = 78;
Xint talky2 = 23;
X
Xstatic char mesgbuf[1000];
Xint cur;
Xint curx;
Xint cury;
Xint mesflg;
X
X#define FD_INPUT 0
X
Xint tcury;
X
Xnotify (s)
Xchar *s;
X{
X mvaddstr (0, 0, "123456 ");
X mvaddstr (0, 0, s);
X}
X
Xinitmesg () {
X mesflg = 0;
X cur = -1;
X curx = mesgx;
X cury = mesgy;
X
X tcury = talky;
X
X
X mvaddstr (0, mesgx, " -- ");
X mvaddstr (0, mesgx + 6, VERSION);
X mvaddstr (0, mesgx + 12, ": By Greg Hale --");
X mvaddstr (mesgy - 1, mesgx, " -- your messages ^D end --");
X mvaddstr (talky - 1, talkx, " -- opponent ^D end --");
X}
X
Xaddtalk (s)
Xchar *s;
X{
X logcomment (s, 2);
X mvaddstr (tcury, talkx, s);
X if (tcury++ == talky2)
X tcury = talky;
X move (tcury, talkx);
X clrtoeol ();
X}
X
Xdomesg (c)
Xchar c;
X{
X if (c == '\b' || c == '\177') {
X delchar ();
X }
X else
X if (c == '\n') {
X sendbuf ();
X curx = mesgx;
X if (cury++ == mesgy2)
X cury = mesgy;
X move (cury, curx);
X clrtoeol ();
X }
X else
X if (c == 004) { /* ^D returns to board now */
X mesflg = 0;
X return (0);
X }
X else {
X addchar (c);
X }
X move (cury, curx);
X}
X
Xaddchar (c)
Xchar c;
X{
X mesgbuf[++cur] = c;
X mvaddch (cury, curx, c);
X if (curx++ == mesgx2) {
X curx = mesgx;
X if (cury++ == mesgy2)
X cury = mesgy;
X sendbuf ();
X move (cury, curx);
X clrtoeol ();
X }
X}
X
Xdelchar () {
X if (cur >= 0 && curx > mesgx) {
X curx--;
X cur--;
X mvaddch (cury, curx, ' ');
X }
X}
X
Xsendbuf () {
X mesgbuf[++cur] = '\0';
X SEND (MMESSAGE);
X SEND (mesgbuf);
X cur = -1;
X logcomment (mesgbuf, 1);
X}
END_OF_FILE
if test 1825 -ne `wc -c <'mesg.c'`; then
echo shar: \"'mesg.c'\" unpacked with wrong size!
fi
# end of 'mesg.c'
fi
if test -f 'movecur.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'movecur.c'\"
else
echo shar: Extracting \"'movecur.c'\" \(149 characters\)
sed "s/^X//" >'movecur.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
Xmovecur (x, y)
Xint x,
X y;
X{
X cx = (cx + x + MAXX) % MAXX;
X cy = (cy + y + MAXX) % MAXY;
X}
END_OF_FILE
if test 149 -ne `wc -c <'movecur.c'`; then
echo shar: \"'movecur.c'\" unpacked with wrong size!
fi
# end of 'movecur.c'
fi
if test -f 'moveto.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'moveto.c'\"
else
echo shar: Extracting \"'moveto.c'\" \(91 characters\)
sed "s/^X//" >'moveto.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
Xmoveto (x, y) {
X move (y + 1, (x * 2) + 1);
X}
END_OF_FILE
if test 91 -ne `wc -c <'moveto.c'`; then
echo shar: \"'moveto.c'\" unpacked with wrong size!
fi
# end of 'moveto.c'
fi
if test -f 'nomove.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'nomove.c'\"
else
echo shar: Extracting \"'nomove.c'\" \(435 characters\)
sed "s/^X//" >'nomove.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XNoMove (x, y, c, d)
Xint x,
X y,
X c,
X d;
X{
X return (!IsSafe (x, y) &&
X nmv0 (x - 1, y, c, d) &&
X nmv0 (x + 1, y, c, d) &&
X nmv0 (x, y - 1, c, d) &&
X nmv0 (x, y + 1, c, d));
X}
X
Xnmv0 (x, y, c, d)
Xint x,
X y,
X c,
X d;
X{
X return (!ir (x, y) ||
X (b (x, y) == c && IsSafe (x, y)) ||
X (b (x, y) == d && !IsSafe (x, y)));
X}
END_OF_FILE
if test 435 -ne `wc -c <'nomove.c'`; then
echo shar: \"'nomove.c'\" unpacked with wrong size!
fi
# end of 'nomove.c'
fi
if test -f 'plt.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'plt.c'\"
else
echo shar: Extracting \"'plt.c'\" \(504 characters\)
sed "s/^X//" >'plt.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XPlt (br, x, y)
XBOARD * br;
Xint x,
X y;
X{
X char c;
X moveto (x, y);
X c = (pieces[br -> d[x][y]]);
X if (c == pieces[0])
X c = cp (x, y);
X addch (c);
X}
X
Xcp (x, y)
Xint x,
X y;
X{
X extern int handin;
X int r;
X if ((x == handin || x == MAXX - 1 - handin || x == (MAXX - 1) / 2) &&
X (y == handin || y == MAXY - 1 - handin || y == (MAXY - 1) / 2)) {
X return (pieces[4]);
X }
X else {
X return (pieces[0]);
X }
X}
END_OF_FILE
if test 504 -ne `wc -c <'plt.c'`; then
echo shar: \"'plt.c'\" unpacked with wrong size!
fi
# end of 'plt.c'
fi
if test -f 'printboard.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'printboard.c'\"
else
echo shar: Extracting \"'printboard.c'\" \(947 characters\)
sed "s/^X//" >'printboard.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XPrintBoard (br)
XBOARD * br;
X{
X extern int handin,
X dimensions,
X inverse;
X int x,
X y;
X touchwin (stdscr);
X handin = (dimensions > 12) ? 3 : 2;
X for (y = 1; y < MAXY + 1; y++)
X for (x = 0; x < MAXX * 2; x++)
X mvaddch (y, x, 32 + inverse);
X for (y = 0; y < MAXY; y++) {
X for (x = 0; x < MAXX; x++) {
X Plt (br, x, y);
X }
X mvprintw (y + 1, MAXX * 2, "|%d", MAXY - y);
X }
X for (x = MAXX; x--;) {
X char c;
X c = 'A' + x;
X c = (c >= 'I') ? c + 1 : c;
X mvaddch (MAXY + 1, x * 2 + 1, c);
X }
X initmesg ();
X printscore ();
X refresh ();
X}
X
Xprintscore () {
X /* mvaddstr(MAXY+1,0,"Go - By Greg Hale"); */
X move (21, 0);
X addch (player ? '>' : ' ');
X printw ("Player one [*] (captured O): %4d", hama[0]);
X move (22, 0);
X addch (!player ? '>' : ' ');
X printw ("Player two [O] (captured *): %4d", hama[1]);
X}
END_OF_FILE
if test 947 -ne `wc -c <'printboard.c'`; then
echo shar: \"'printboard.c'\" unpacked with wrong size!
fi
# end of 'printboard.c'
fi
if test -f 'putpiece.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'putpiece.c'\"
else
echo shar: Extracting \"'putpiece.c'\" \(1871 characters\)
sed "s/^X//" >'putpiece.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "sys/time.h"
X#include "go.h"
X#define DELAY 30000
X
Xint lastx,
X lasty;
X
Xextern int logflg;
X
Xputpiece (cx, cy, cur, blinkflg, switchB)
Xint cx,
X cy;
Xint cur;
Xint blinkflg;
Xint switchB;
X{
X if (blinkflg)
X Beep ();
X if (b (cx, cy) == NONE) {
X int c,
X d;
X savelast ();
X c = !cur + 1;
X d = cur + 1;
X setboard (cx, cy, d);
X if (NoMove (cx, cy, c, d)) {
X b (cx, cy) = 0;
X Plt (&board, cx, cy);
X }
X else {
X Kill (cx, cy, d);
X
X if (!compboard ()) {
X homemes ();
X addmes ("- That's a KO. You can't");
X addmes (" go there.");
X restlast ();
X }
X else {
X lastx = cx;
X lasty = cy;
X if (switchB) {
X SEND (MMOVE);
X SendCoord (cx, cy);
X sprintf (buf, "%d", cur);
X SEND (buf);
X }
X Plt (&board, cx, cy);
X refresh ();
X if (blinkflg)
X blink (cx, cy, d);
X if (logflg)
X dolog (cx, cy, d);
X if (switchB)
X NextPlr ();
X saveboard0 ();
X }
X }
X }
X}
X
XShowLast () {
X blink (lastx, lasty, b (lastx, lasty));
X}
X
Xblink (x, y, d)
Xint x,
X y,
X d;
X{
X extern int numberblink;
X int blinks;
X int mask;
X struct timeval tv;
X if (!AreWe (HANDICAP)) {
X for (blinks = numberblink; blinks--;) {
X mask = sockmask[0];
X tv.tv_sec = 0;
X tv.tv_usec = 200000;
X if (select (sizeof (mask), &mask, 0, 0, &tv))
X break;
X b (x, y) = b (x, y) ? 0 : d;
X Plt (&board, x, y);
X refresh ();
X }
X b (x, y) = d;
X Plt (&board, x, y);
X refresh ();
X }
X}
X
X
XGetCoord (x, y)
Xint *x,
X *y;
X{
X RECV (buf);
X *x = atoi (buf);
X RECV (buf);
X *y = atoi (buf);
X}
X
XSendCoord (x, y)
Xint x,
X y;
X{
X sprintf (buf, "%d", x);
X DEBUG (printf ("SENDCOORD X:%s\n", buf);
X )
X SEND (buf);
X sprintf (buf, "%d", y);
X DEBUG (printf ("SENDCOORD Y:%s\n", buf);
X )
X SEND (buf);
X}
END_OF_FILE
if test 1871 -ne `wc -c <'putpiece.c'`; then
echo shar: \"'putpiece.c'\" unpacked with wrong size!
fi
# end of 'putpiece.c'
fi
if test -f 'score.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'score.c'\"
else
echo shar: Extracting \"'score.c'\" \(1397 characters\)
sed "s/^X//" >'score.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XScore()
X{
X extern int handicaps;
X char temp[100];
X float komi,s1,s2,s1space,s2space;
X int i,j;
X
X s1=s2=0.0;
X Tally();
X for (i=0; i<MAXX; i++) {
X for (j=0; j<MAXY; j++) {
X if (b(i,j)==4) {
X s1++;
X }
X else if(b(i,j)==5) {
X s2++;
X }
X
X }
X }
X komi = (handicaps>0 || dimensions != 19) ? 0.0 : KOMI;
X s1space=s1;
X s2space=s2;
X s2+=hama[1];
X s1+=hama[0];
X s2 = s2 + komi;
X if (s1>s2)
X sprintf(temp,"Black has won by %g points!",s1-s2);
X else if (s2>s1)
X sprintf(temp,"White has won by %g points!",s2-s1);
X else sprintf(temp,"It was a tie game!");
X
X homemes();
X addmes("Final Results:");
X addmes(temp);
X
X if (s1 != s2) {
X iwon = (player && (s1>s2)) || (!player && (s1<s2));
X savestr();
X }
X
X GetAKey();
X clear();
X move(1,0);
X printw("------------------------------------------------\n");
X printw("- Final Results (Japanese counting) -\n");
X printw("------------------------------------------------\n");
X printw("- Territory + Captured + Komi = Final Score\n");
X printw("-Black: %3.1f %3.1f 0 %3.1f\n",
X s1space, (float)hama[0], s1);
X printw("-White: %3.1f %3.1f %1.1f %3.1f\n",
X s2space, (float)hama[1], komi, s2);
X printw("-------------------------------------------------\n");
X printw("\n%s\n",temp);
X refresh();
X testsave();
X move(20,0);
X refresh();
X Exit();
X}
X
X
END_OF_FILE
if test 1397 -ne `wc -c <'score.c'`; then
echo shar: \"'score.c'\" unpacked with wrong size!
fi
# end of 'score.c'
fi
if test -f 'setboard.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'setboard.c'\"
else
echo shar: Extracting \"'setboard.c'\" \(240 characters\)
sed "s/^X//" >'setboard.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
Xsetboard (x, y, p)
Xint x,
X y;
Xchar p;
X{
X if ((p < 1 || p > 2) && b (x, y) == 1 || b (x, y) == 2) {
X hama[!(b (x, y) - 1)]++;
X }
X board.d[x][y] = p;
X Plt (&board, x, y);
X}
END_OF_FILE
if test 240 -ne `wc -c <'setboard.c'`; then
echo shar: \"'setboard.c'\" unpacked with wrong size!
fi
# end of 'setboard.c'
fi
if test -f 'status.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'status.c'\"
else
echo shar: Extracting \"'status.c'\" \(201 characters\)
sed "s/^X//" >'status.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
X
XAreWe (s)
Xint s;
X{
X return (status & s);
X}
X
XSetStat (s)
Xint s;
X{
X status = status | s;
X}
X
XClrStat (s)
Xint s;
X{
X status = status & ~s;
X}
END_OF_FILE
if test 201 -ne `wc -c <'status.c'`; then
echo shar: \"'status.c'\" unpacked with wrong size!
fi
# end of 'status.c'
fi
if test -f 'std.disclaimer' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'std.disclaimer'\"
else
echo shar: Extracting \"'std.disclaimer'\" \(490 characters\)
sed "s/^X//" >'std.disclaimer' <<'END_OF_FILE'
X/*
X Copyright 1990 Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation. No representations are made about the
Xsuitability of this software for any purpose. It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
END_OF_FILE
if test 490 -ne `wc -c <'std.disclaimer'`; then
echo shar: \"'std.disclaimer'\" unpacked with wrong size!
fi
# end of 'std.disclaimer'
fi
if test -f 'strength.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'strength.c'\"
else
echo shar: Extracting \"'strength.c'\" \(2082 characters\)
sed "s/^X//" >'strength.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X#include <pwd.h>
X
XFILE * strfile;
Xchar filename[500];
Xextern int strength,
X opponstr;
Xextern float wins;
X
XGetStr () {
X int id;
X struct passwd *pw;
X char *dir;
X id = geteuid ();
X pw = getpwuid (id);
X dir = pw -> pw_dir;
X strcpy (filename, dir);
X strcat (filename, GOFILE);
X /* fprintf(stderr,"FILENAME:%s\n",filename); */
X if ((strfile = fopen (filename, "r")) != NULL) {
X fscanf (strfile, "%d", &strength);
X fscanf (strfile, "%f", &wins);
X fclose (strfile);
X }
X else {
X strength = 0;
X wins = 0.0;
X }
X
X}
X
X
X
X
Xsavestr () {
X float getdelta (), newwins;
X newwins = getdelta ();
X if (newwins * wins < 0.0)
X wins = newwins;
X else
X wins += newwins;
X savestr0 ();
X}
X
Xsavestr0 () {
X if ((strfile = fopen (filename, "w")) != NULL) {
X if ((wins >= WINSUP && strength < MAXSTR)) {
X fprintf (strfile, "%d 0.0\n", strength + 1);
X }
X else
X if ((wins <= -WINSUP && strength > 1)) {
X fprintf (strfile, "%d 0.0\n", strength - 1);
X }
X else {
X fprintf (strfile, "%d %f\n", strength, wins);
X }
X fclose (strfile);
X }
X}
X
X
Xfloat getdelta () {
X if (iwon) { /* i won */
X if (strength < opponstr)/* i'm weaker */
X return ((opponstr - strength) / 10.0 + 1.0);
X else
X return (((strength - opponstr) > 20) ? 2.0 : 1.0);
X }
X else {
X if (strength < opponstr)
X return (-1.0);
X else
X return (-((strength - opponstr) / 20.0 + 1.0));
X }
X}
X
Xshowstr () {
X GetStr ();
X if (strength < 31) {
X printf ("Your strength is about: %d kyu.\n", 31 - strength);
X }
X else
X if (strength < 40) {
X printf ("Your strength is about: %d dan.\n", strength - 30);
X }
X else
X if (strength < MAXSTR + 1) {
X printf ("Your strength is about: %d professional dan.\n", strength - 39);
X }
X else {
X printf ("Your are at maximum strength.\n");
X }
X if (wins >= 0)
X printf ("You have also won %d games in a row.\n", (int) (wins / 2.0));
X else
X printf ("You have also lost %d games in a row.\n", -(int) (wins));
X}
END_OF_FILE
if test 2082 -ne `wc -c <'strength.c'`; then
echo shar: \"'strength.c'\" unpacked with wrong size!
fi
# end of 'strength.c'
fi
if test -f 'tally.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'tally.c'\"
else
echo shar: Extracting \"'tally.c'\" \(201 characters\)
sed "s/^X//" >'tally.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X
XTally () {
X int i,
X j;
X for (i = 0; i < MAXX; i++)
X for (j = 0; j < MAXY; j++)
X if (b (i, j) == NONE)
X fill (i, j, Owner (i, j));
X}
END_OF_FILE
if test 201 -ne `wc -c <'tally.c'`; then
echo shar: \"'tally.c'\" unpacked with wrong size!
fi
# end of 'tally.c'
fi
if test -f 'traps.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'traps.c'\"
else
echo shar: Extracting \"'traps.c'\" \(1727 characters\)
sed "s/^X//" >'traps.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X#include <signal.h>
X
X#define FD_INPUT 0
Xtrap_sigint () {
X int y,
X x;
X char c;
X
X signal (SIGINT, SIG_IGN);
X clear ();
X mvaddstr (22, 1, "Quit (y/n)?");
X refresh ();
X c = GetAKey0 ();
X while (c != 'n' && c != 'N' && c != 'y' && c != 'Y') {
X if (c == '\f')
X refresh ();
X c = GetAKey ();
X }
X if (c == 'y') {
X SEND (MEXIT);
X clear ();
X refresh ();
X Exit ();
X }
X
X touchwin (stdscr);
X PrintBoard (&board);
X
X signal (SIGINT, trap_sigint);
X}
X
X/* These signal handlers cause bad bugs
Xmyts_tp () {
X clear ();
X refresh ();
X resetty ();
X kill (getpid (), SIGSTOP);
X}
X
Xmyts_cont () {
X setmode ();
X touchwin (stdscr);
X clear ();
X PrintBoard (&board);
X}
X*/
X
X/*
X * set up all the core dump signal vectors to the signal handler given
X */
X
Xsetcore (f)
Xint (*f) ();
X{
X signal (SIGQUIT, f);
X signal (SIGILL, f);
X signal (SIGTRAP, f);
X signal (SIGIOT, f);
X signal (SIGEMT, f);
X signal (SIGFPE, f);
X signal (SIGBUS, f);
X signal (SIGSEGV, f);
X signal (SIGSYS, f);
X}
X
X/*
X * very fatal error occured twice. Time to die.
X * We have been surrounded :)
X */
X
Xtrap_cdumpII () {
X int i;
X setcore (SIG_IGN);
X fprintf (stderr, "Save failed! Fatal error! Committing processide...\n");
X exit (666);
X}
X
X/*
X * The first core dump signal goes here, then to cdumpII
X * The first signal attempts to save the game and leave cleanly.
X * the second version just dies :(
X */
X
Xtrap_cdump () {
X int trap_cdumpII ();
X setcore (trap_cdumpII);
X fprintf (stderr, "core dump attempted- attempting save...\n");
X savegame ();
X fprintf (stderr, "save successful.\n\n");
X Exit ();
X}
END_OF_FILE
if test 1727 -ne `wc -c <'traps.c'`; then
echo shar: \"'traps.c'\" unpacked with wrong size!
fi
# end of 'traps.c'
fi
if test -f 'util.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'util.c'\"
else
echo shar: Extracting \"'util.c'\" \(1323 characters\)
sed "s/^X//" >'util.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include "go.h"
X#include <ctype.h>
X
X#define FD_INPUT 0
X
XGetAKey () {
X addmes (HITAKEYMES);
X return (GetAKey0 ());
X}
X
XGetAKey0 () {
X char c;
X if (read (FD_INPUT, &c, 1) <= 0) {
X SEND (MEXIT);
X error ("Aborting- End of File read.\n");
X }
X return (c);
X}
XDoRedraw () {
X touchwin (stdscr);
X clear ();
X PrintBoard (&board);
X}
X
XBeep () {
X extern int beepflg;
X if (beepflg)
X putchar (07);
X}
X
Xint verify (s)
Xchar *s;
X{
X char buf[2];
X do {
X getLine (s, buf, 1);
X }
X while (buf[0] != 'y' && buf[0] != 'n');
X
X return buf[0] == 'y';
X}
X
Xint getLine (query, dst, maxLen)/* char *, char *, int */
Xchar *query,
X *dst;
Xint maxLen;
X{
X int qLen,
X dLen;
X char c;
X mvaddstr (0, 1, query);
X printw (" ");
X mvaddstr (0, 1, query);
X dLen = 0;
X qLen = strlen (query);
X do {
X move (0, qLen + 1 + dLen);
X refresh ();
X c = getchar ();
X if (isprint (c) && dLen < maxLen) {
X mvaddch (0, qLen + dLen + 1, c);
X dst[dLen++] = c;
X }
X else
X if (dLen && (c == '\b' || c == '\177')) {
X dLen--;
X mvaddch (0, qLen + dLen + 1, ' ');
X }
X }
X while (c != '\n' && c != '\r');
X dst[dLen] = 0;
X move (0, 1);
X printw (" ");
X return dLen;
X}
END_OF_FILE
if test 1323 -ne `wc -c <'util.c'`; then
echo shar: \"'util.c'\" unpacked with wrong size!
fi
# end of 'util.c'
fi
if test -f 'var.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'var.c'\"
else
echo shar: Extracting \"'var.c'\" \(882 characters\)
sed "s/^X//" >'var.c' <<'END_OF_FILE'
X#include "std.disclaimer"
X#include <sys/file.h>
X#include "go.h"
X
XBOARD backup, board, marks;
X
Xint handin;
Xint handicaps = 0; /* handicap indentation */
Xint dimensions,
X myport;
Xint cx = 0,
X cy = 0;
Xchar pieces[] = {
X '.' + INVERSE, BLACK + INVERSE, 'O' + INVERSE, '=' + INVERSE,
X '+' + INVERSE, '-' + INVERSE
X};
Xint curplr = 0;
Xint hama[2] = {
X 0, 0
X};
Xint MAXX,
X MAXY;
Xchar buf[MAXBUF];
Xint beepflg;
Xint disable = 0;
Xint status,
X sock,
X sockmask[2],
X myturn;
Xint player,
X iwon,
X opponstr,
X strength;
Xint loadflg;
Xint logflg;
Xint usemess;
Xchar loadname[128],
X logname[128];
Xfloat wins;
Xchar *blanks = " ";
Xchar *myname,
X *hisname;
XFILE * logfile;
Xint inverse;
END_OF_FILE
if test 882 -ne `wc -c <'var.c'`; then
echo shar: \"'var.c'\" unpacked with wrong size!
fi
# end of 'var.c'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked both archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0