Path: utzoo!mnetor!uunet!husc6!bloom-beacon!mit-eddie!uw-beaver!tektronix!tekgen!tekred!games From: games@tekred.TEK.COM Newsgroups: comp.sources.games Subject: v04i008: xgo - go for curses or X-windows, Part04/04 Message-ID: <2408@tekred.TEK.COM> Date: 8 Apr 88 21:36:49 GMT Sender: billr@tekred.TEK.COM Lines: 2004 Approved: billr@saab.CNA.TEK.COM Submitted by: Greg Hale Comp.sources.games: Volume 4, Issue 8 Archive-name: xgo/Part04 #! /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 Xd.h <<'END_OF_Xd.h' X/* X * $Header: Xd.h,v 1.2 88/02/13 12:56:07 hale Exp $ X */ X X/* X X Copyright 1987 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 X#define d_width 25 X#define d_height 25 Xstatic short d_bits[] = { X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x3800, 0x0000, X 0xffff, 0x01ff, 0x3800, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000}; X/* X * $Log: Xd.h,v $ X * Revision 1.2 88/02/13 12:56:07 hale X * added logging. X * X */ X END_OF_Xd.h if test 1146 -ne `wc -c Xu.h <<'END_OF_Xu.h' X/* X * $Header: Xu.h,v 1.2 88/02/13 12:56:54 hale Exp $ X */ X X/* X X Copyright 1987 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 X#define u_width 25 X#define u_height 25 Xstatic short u_bits[] = { X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x0000, 0x0000, X 0x0000, 0x0000, 0x3800, 0x0000, X 0xffff, 0x01ff, 0x3800, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000, 0x1000, 0x0000, X 0x1000, 0x0000}; X/* X * $Log: Xu.h,v $ X * Revision 1.2 88/02/13 12:56:54 hale X * added logging. X * X */ X END_OF_Xu.h if test 1146 -ne `wc -c del.c <<'END_OF_del.c' X/* X * $Header: del.c,v 1.2 88/02/13 12:44:43 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X Xdeletes (x,y) Xint x,y; X{ X InitBoard(&marks); X killit(x,y,b(x,y)); X} X X/* X * $Log: del.c,v $ X * Revision 1.2 88/02/13 12:44:43 hale X * added logging. X * X */ X END_OF_del.c if test 730 -ne `wc -c dohand.c <<'END_OF_dohand.c' X/* X * $Header: dohand.c,v 1.4 88/02/19 13:47:54 hale Exp $ X */ X X#include "go.h" X XDoHand(x,y,c) Xint x,y,c; X{ X int p; X X if (b(x,y)!= 0) X sethand(x,y,(b(x,y)==c+1 ? 0:c+1)); X else X putpiece(x,y,c,false); X X if (c) SetBlkCur(); X else SetWhtCur(); X} X Xsethand(x,y,v) Xint x,y,v; X{ X if (b(x,y) != v) { X b(x,y)= v; X Plt(&board,x,y); X SEND(MHANDICAP); X SendCoord(x,y); X sendint(v); X } X} X/* X * $Log: dohand.c,v $ X * Revision 1.4 88/02/19 13:47:54 hale X * Added io changes for loading games. X * Load game is cleaned up. Variable board X * sizes and formats available in save game X * as well as printed comments. X * X * Revision 1.3 88/02/14 00:21:16 hale X * Added load file option during game to restore game to starting X * state. Also, clear board operation. Restoring game puts current X * player in sync. With the demo mode, this is invaluable. X * X * Revision 1.2 88/02/13 12:45:02 hale X * modified and maximized the handicap given to 9. X * X */ X END_OF_dohand.c if test 956 -ne `wc -c exit.c <<'END_OF_exit.c' X/* X * $Header: exit.c,v 1.2 88/02/13 12:47:56 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" XExit() X{ X unsetmode(); X clear(); X refresh(); X endwin(); X exit(0); X} X X/* X * $Log: exit.c,v $ X * Revision 1.2 88/02/13 12:47:56 hale X * added logging. X * X */ X END_OF_exit.c if test 731 -ne `wc -c fill.c <<'END_OF_fill.c' X/* X * $Header: fill.c,v 1.2 88/02/13 12:48:37 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X Xstatic int fillwith; X Xfill(x,y,type) Xint x,y,type; X{ X fillwith=type; X InitBoard(&marks); X fill0(x,y); X} X Xfill0(x,y) Xint 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} X X/* X * $Log: fill.c,v $ X * Revision 1.2 88/02/13 12:48:37 hale X * added logging. X * X */ X END_OF_fill.c if test 951 -ne `wc -c games/Proto <<'END_OF_games/Proto' X#!/usr/public/xgo -m -l X; first, the #!stuff to run the prog. X; must be first line X; run by typing .../file opponent@host X X; followed by board size then whos turn X19 0 X; a # delimits game data X# X; optional formats X; b/B# bottom justify for # lines of data X; r/R# right justify for # columns of data X......w.bb. X..bbw..wwb. X..b.wwwbbb. X..bww.b.... X..bw.wb.... X..bwwwb.... X..bbbbb.... X........... X; # delimits end of board info X# X; captured (black white) cursor x,y X0 0 0 0 X; comments printed to info window X% black to play and kill white END_OF_games/Proto if test 537 -ne `wc -c games/Proto.blk <<'END_OF_games/Proto.blk' X#!/usr/public/xgo -m -l X; run by typing ".../file opponent@host" X19 0 X# X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X# X0 0 0 0 X; comments printed to info window X% By: END_OF_games/Proto.blk if test 356 -ne `wc -c games/README <<'END_OF_games/README' XTo make a new file, either run the program and save a screen and edit it, Xor copy Proto.blk to a new name and edit it. In either case, proto is Xa prototypical save file you can look at. X XI suggest you use the following standard for saved games: X X name.#a.#b X Xname may be anything (could describe the problem, class of problem, or theme) X#a is the approximate rank of the problem X#b is a way of associating related problems END_OF_games/README if test 424 -ne `wc -c games/enig.1k.1 <<'END_OF_games/enig.1k.1' X#!/usr/public/xgo -m -l X19 0 X# X. . . . . @ . @ @ . . . . . @ @ @ @ @ X. . . . . . . @ . . . . . . . . O O @ X. @ . . . . O O . . . . . . . O . @ O X. . . . . . @ O . . . . . . . O @ @ O X. . . . . @ . O . . . . . . @ O O O . X. . . . . . @ O . . . . . . . @ @ O @ X. . . . . . @ O @ . . . . . . @ @ O @ X. . . . . @ . O . @ . . . . O @ . O @ X. . . . @ . O O O . . . . @ @ O O @ @ X. . . . . @ . . . . . . . . . . . . . X. . @ . @ . . . . . . . . . . . . . @ X@ . . O O O . . . . . . . O O O @ . . X. . O . . O @ . . . . . . @ @ O @ . . X@ . O . . O . . . . . . . @ O @ @ . . X. . @ O O @ . . . . . @ . O O O @ . . X@ . O . . O . . . . @ . . . . O @ . . X@ . O . . O . . . . . . . O O @ @ . . X. @ . O O . . . . . @ . @ . @ . . . . X@ . @ @ @ . @ . . . @ . @ . . . @ @ . X# X1 1 0 0 X X% white to play and make ladder X% at 13,6. Does it work? X END_OF_games/enig.1k.1 if test 841 -ne `wc -c games/enig.2k.1 <<'END_OF_games/enig.2k.1' X#!/usr/public/xgo -m -l X; run by typing .../file opponent@host X15 0 X# Xb8 X........... X.........w. X....wwww... X...wwbbb.w. X...wb...bw. X.w.wb.bwbw. X..bwbw.wbw. X...b....bw. X# X0 0 0 0 X% white to play and kill black. X% VERY HARD. END_OF_games/enig.2k.1 if test 224 -ne `wc -c games/g.10k.2 <<'END_OF_games/g.10k.2' X#!/usr/public/xgo -m -l X; first, the #!stuff to run the prog. X; must be first line X; run by typing .../file opponent@host X X; followed by board size then whos turn X19 0 X; a # delimits game data X# X; optional formats X; b/B# bottom justify for # lines of data X; r/R# right justify for # columns of data X. . . . . O . . . . . X . . X. . . X O . . . O . O X . . X. . X . X O O . . . O X . . X. . . . X . X X X . O X . . X. . . . . . . . . X X . . . X. . . . . . . . . . . . . . X; # delimits end of board info X# X; captured (black white) cursor x,y X0 0 0 0 X; comments printed to info window X% black to play and kill white END_OF_games/g.10k.2 if test 609 -ne `wc -c games/g.11k.1 <<'END_OF_games/g.11k.1' X#!/usr/public/xgo -m -l X; run by typing ".../file opponent@host" X19 0 X# X. . . . O . . . . . X . . X. . X O . . . O . O X . . X. X . X O O . . . O X . . X. . . X . X X X . O X . . X. . . . . . . . X X . . . X. . . . . . . . . . . . . X# X0 0 0 0 X; comments printed to info window X% black to play and kill white END_OF_games/g.11k.1 if test 303 -ne `wc -c games/g.12k.1 <<'END_OF_games/g.12k.1' X#!/usr/public/xgo -m -l X; ../file oppon@host X13 0 X# X......w.bb. X..bbw..wwb. X..b.wwwbbb. X..bww.b.... X..bw.wb.... X..bwwwb.... X..bbbbb.... X........... X# X0 0 0 0 X% black to play and kill white X% #203 in GGP #2 END_OF_games/g.12k.1 if test 206 -ne `wc -c games/g.15k.1 <<'END_OF_games/g.15k.1' X#!/usr/public/xgo -m -l X; run by typing ".../file opponent@host" X19 0 X# X. . x x x x x o . . . . . x o o o x . Xo x x o o o x o . . . . . x . . . x . Xo x x x x o x o . . . . . . . o . . . Xo o o x x o x o . . . . . . . . . . . Xx o . . x o x o . . . . . . o o o . . Xx o o x x o x o . . . . . . . o . . . Xx o x x x o x o . . . . . . . . . . . Xx o o o o o x o . . . . . . . . . . . Xx x x x x x x o . . . . . . . . . . . Xo o o o o o o o . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . . . . . . . . . . . X. x x x . . . . . . . . . x . . . . . X. o o x . . . . . . . . . . . . x . . X. . o x . . . . . . . . . . . . . x . X. . o x . . . . . . . . . x . o o x . Xo o x x . . . . . . . . . x x o . o . X. . o x . . . . . . . . . . . . o . . Xo o . x . . . . . . . . . . x . . . . X# X0 0 0 0 X; comments printed to info window X% Black to play X% What is the result X% in each situation? END_OF_games/g.15k.1 if test 896 -ne `wc -c games/g.15k.2 <<'END_OF_games/g.15k.2' X#!/usr/public/xgo -m -l X; run by typing ".../file opponent@host" X13 0 X# Xb7 X. . . . . . . . . X. . . . . . . . . Xo o o . . . . . . Xx x o o . . . . . X. . x o o . . . . X. x . x o . . . . X. . . x o . . . . X# X0 0 0 0 X; comments printed to info window X% By: Greg Hale X% white to play and kill black. END_OF_games/g.15k.2 if test 293 -ne `wc -c games/g.9k.1 <<'END_OF_games/g.9k.1' X#!/usr/public/xgo -m -l X9 0 X# XB5 X. . . . . . . . XO O O O . . . . X. . @ O O O . . X@ @ . @ @ O . . X. . . . . O . . X# X0 0 0 0 X% black to play and live X% 8 moves END_OF_games/g.9k.1 if test 158 -ne `wc -c games/save.10k <<'END_OF_games/save.10k' X#!/usr/public/xgo -m -l X; run by typing ".../file opponent@host" X19 0 X# X. . . . . . . . . . . . . . . . . . . X. . . . x o . . . . . . . . o x . . . X. . . x o o o . . . . . . o . x . . . X. . . x x x o . . x . . . . . x . . . X. . . . . . . . . . . . . o . . . . . X. . . x . . x . . x . . . . o . x . . X. . . . . . . . . . . . . . . . . . . X. . . . . . . . . o . . . . . . . . . X. . . x . . . . . x . . . . . . x . . X. . . . . . . . . . . . . . . . . . . X# X0 0 0 0 X; comments printed to info window X% white to play. have fun. END_OF_games/save.10k if test 534 -ne `wc -c games/save.10k.1 <<'END_OF_games/save.10k.1' X#!/usr/public/xgo -m -l X; run by typing ".../file opponent@host" X9 0 X# X. . . . . . . . . X. . . o . . . . . X. . x . o . o . . X. . . . . . . x . X. . x . x . x . . X. x . . . . . . . X. . o . o . x . . X. . . . . o . . . X. . . . . . . . . X# X0 0 0 0 X; comments printed to info window X% By: END_OF_games/save.10k.1 if test 283 -ne `wc -c go.c <<'END_OF_go.c' X/* X * $Header: go.c,v 1.2 88/02/13 12:48:46 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X Xmain (argc, argv, envp) Xint argc; Xchar **argv, **envp; X{ X /* GetStr(); X savestr(); X exit(0); */ X if (argc <= 1) helpstart(argv); X parseline(argc,argv); X X sockmask[0]= 1; X X changes(); X X main0(argc,argv,envp); X} X X/* X * $Log: go.c,v $ X * Revision 1.2 88/02/13 12:48:46 hale X * added logging. X * X */ X END_OF_go.c if test 870 -ne `wc -c handicap.c <<'END_OF_handicap.c' X/* X * $Header: handicap.c,v 1.2 88/02/13 12:49:14 hale Exp $ X */ X X#include "go.h" X X#define HC(x,y) { cx = (x); cy = (y); Handicap(!b(x,y)); } X#define MAXHANDICAPS 9 X Xsethandi() X{ X extern int handicaps,handin; X int h; X h = handicaps; X if (h>MAXHANDICAPS) h=MAXHANDICAPS; X SetStat(HANDICAP); X X if (h-- >0) HC(handin,handin); X if (h-- >0) HC(MAXX-1-handin,MAXY-1-handin); X if (h-- >0) HC(MAXX-1-handin,handin); X if (h-- >0) HC(handin,MAXY-1-handin); X if (h-- >0) HC(MAXX/2,MAXY/2); X if (h-- >0) { X HC(MAXX/2,MAXY/2); X HC(handin,MAXY/2); X HC(MAXX-1-handin,MAXY/2); X } X if (h-- >0) HC(MAXX/2,MAXY/2); X if (h-- >0) { X HC(MAXX/2,MAXY/2); X HC(MAXX/2,handin); X HC(MAXX/2,MAXY-1-handin); X } X if (h-- >0) HC(MAXX/2,MAXY/2); X if (h-- >0) HC(handin+1,handin+1); X if (h-- >0) HC(MAXX-handin-2,MAXY-handin-2); X if (h-- >0) HC(MAXX-handin-2,handin+1); X if (h-- >0) HC(handin+1,MAXY-handin-2); X} X X X/* X * $Log: handicap.c,v $ X * Revision 1.2 88/02/13 12:49:14 hale X * added logging. X * X */ X END_OF_handicap.c if test 985 -ne `wc -c initboard.c <<'END_OF_initboard.c' X/* X * $Header: initboard.c,v 1.2 88/02/13 12:49:32 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" XInitBoard(br) XBOARD *br; X{ X int x,y; X for(y=0; yd[x][y]=NONE; X} X X/* X * $Log: initboard.c,v $ X * Revision 1.2 88/02/13 12:49:32 hale X * added logging. X * X */ X END_OF_initboard.c if test 780 -ne `wc -c kill.c <<'END_OF_kill.c' X/* X * $Header: kill.c,v 1.2 88/02/13 12:49:38 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X X XKill(x,y,type) Xint x,y,type; X{ X int t; X InitBoard(&marks); X t = !(type-1)+1; X if(!IsSafe(x-1,y)) killit(x-1,y,t); X if(!IsSafe(x+1,y)) killit(x+1,y,t); X if(!IsSafe(x,y-1)) killit(x,y-1,t); X if(!IsSafe(x,y+1)) killit(x,y+1,t); X} X X/* X * $Log: kill.c,v $ X * Revision 1.2 88/02/13 12:49:38 hale X * added logging. X * X */ X END_OF_kill.c if test 892 -ne `wc -c killit.c <<'END_OF_killit.c' X/* X * $Header: killit.c,v 1.2 88/02/13 12:49:42 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X Xkillit(x,y,t) Xint x,y,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} X X/* X * $Log: killit.c,v $ X * Revision 1.2 88/02/13 12:49:42 hale X * added logging. X * X */ X END_OF_killit.c if test 859 -ne `wc -c movecur.c <<'END_OF_movecur.c' X/* X * $Header: movecur.c,v 1.2 88/02/13 12:50:35 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" Xmovecur(x,y) Xint x,y; X{ X cx+=x; X if ((cx<0)||(cx>=MAXX)) X cx-=x; X cy+=y; X if ((cy<0)||(cy>=MAXY)) X cy-=y; X} X X/* X * $Log: movecur.c,v $ X * Revision 1.2 88/02/13 12:50:35 hale X * added logging. X * X */ X END_OF_movecur.c if test 779 -ne `wc -c moveto.c <<'END_OF_moveto.c' X/* X * $Header: moveto.c,v 3.0 88/03/10 12:07:40 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" Xmoveto(x,y) X{ X move(y+1,(x*2)+1); X} X X/* X * $Log: moveto.c,v $ X * Revision 3.0 88/03/10 12:07:40 hale X * Added save games, a few changes to the I/O, X * added load and clear options. Not thouroughly tested, though, and X * I think a few bugs are in the load code. A library of sample problems X * has been started and saved with the working directory. X * X * Revision 1.2 88/02/13 12:50:38 hale X * added logging. X * X */ X END_OF_moveto.c if test 998 -ne `wc -c nomove.c <<'END_OF_nomove.c' X/* X * $Header: nomove.c,v 1.2 88/02/13 12:50:42 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X XNoMove(x,y,c,d) Xint x,y,c,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,y,c,d; X{ X return (!ir(x,y) || X (b(x,y)==c && IsSafe(x,y)) || X (b(x,y)==d && !IsSafe(x,y))); X} X/* X * $Log: nomove.c,v $ X * Revision 1.2 88/02/13 12:50:42 hale X * added logging. X * X */ X END_OF_nomove.c if test 931 -ne `wc -c plt.c <<'END_OF_plt.c' X/* X * $Header: plt.c,v 1.2 88/02/13 12:51:17 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X XPlt(br,x,y) XBOARD *br; Xint x,y; X{ X char c; X moveto(x,y); X c =(pieces[br->d[x][y]]); X if (c=='.') c = cp(x,y); X addch (c); X} X Xcp(x,y) Xint 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 ('*'); X } else { X return ('.'); X } X} X/* X * $Log: plt.c,v $ X * Revision 1.2 88/02/13 12:51:17 hale X * added logging. X * X * X */ X END_OF_plt.c if test 1000 -ne `wc -c setboard.c <<'END_OF_setboard.c' X/* X * $Header: setboard.c,v 1.2 88/02/13 12:51:53 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X Xsetboard(x,y,p) Xint 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} X X/* X * $Log: setboard.c,v $ X * Revision 1.2 88/02/13 12:51:53 hale X * added logging. X * X */ X END_OF_setboard.c if test 818 -ne `wc -c status.c <<'END_OF_status.c' X/* X * $Header: status.c,v 1.2 88/02/13 12:51:57 hale Exp $ X */ X X/* X X Copyright 1987 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 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} X X/* X * $Log: status.c,v $ X * Revision 1.2 88/02/13 12:51:57 hale X * added handling of new buttons. X * X */ X END_OF_status.c if test 818 -ne `wc -c tally.c <<'END_OF_tally.c' X/* X * $Header: tally.c,v 1.2 88/02/13 12:52:31 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X XTally() X{ X int i,j; X for (i=0; iutil.c <<'END_OF_util.c' X/* X * $Header: util.c,v 1.2 88/02/13 12:52:42 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "go.h" X#define FD_INPUT 0 X XGetAKey() X{ X addmes(HITAKEYMES); X return(GetAKey0()); X} X XGetAKey0() X{ 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} X Xflushkey() X{ X int i=0; X ioctl(FD_INPUT,TIOCFLUSH,&i); X} X XSetWhtCur() X{ X} XSetBlkCur() X{ X} X XDoRedraw() X{ X touchwin(stdscr); X clear(); X PrintBoard(&board); X} X XBeep() X{ X mvaddch(0,0,07); X} X XREFRESH() X{ X refresh(); X} X/* X * $Log: util.c,v $ X * Revision 1.2 88/02/13 12:52:42 hale X * added logging. X * X */ X END_OF_util.c if test 1081 -ne `wc -c xexit.c <<'END_OF_xexit.c' X/* X * $Header: xexit.c,v 1.2 88/02/13 12:54:07 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "xgo.h" X XExit() X{ X EndWin(); X if (dis != NULL) XCloseDisplay(dis); X exit(0); X} X X/* X * $Log: xexit.c,v $ X * Revision 1.2 88/02/13 12:54:07 hale X * added logging. X * X */ X END_OF_xexit.c if test 737 -ne `wc -c xgo.c <<'END_OF_xgo.c' X/* X * $Header: xgo.c,v 1.2 88/02/13 12:54:27 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "xgo.h" X X Xmain (argc, argv, envp) Xint argc; Xchar **argv, **envp; X{ X X char name[MAXLINE]; X X X if (argc <= 1) helpstart(argv); X parseline(argc,argv); X X X dis = XOpenDisplay(display); X if (dis == NULL) error("\nYou need to be running X to execute this program.\n"); X sockmask[0]= 1 << dpyno(); X X changes(); X X main0(argc, argv, envp); X} X X/* X * $Log: xgo.c,v $ X * Revision 1.2 88/02/13 12:54:27 hale X * added logging. X * X */ X END_OF_xgo.c if test 985 -ne `wc -c xinit.c <<'END_OF_xinit.c' X/* X * $Header: xinit.c,v 1.3 88/02/19 13:49:31 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "xgo.h" X XInit() X{ X InitW(); X InitBit(); X X fi = XOpenFont("vtsingle"); X X MAXX=dimensions; MAXY=dimensions; X hama[0]=0; X hama[1]=0; X X InitBoard(&board); X InitLoop(); X} X X/* X * $Log: xinit.c,v $ X * Revision 1.3 88/02/19 13:49:31 hale X * Added io changes for loading games. X * Load game is cleaned up. Variable board X * sizes and formats available in save game X * as well as printed comments. X * X * Revision 1.2 88/02/13 12:54:34 hale X * added logging. X * X */ X END_OF_xinit.c if test 1029 -ne `wc -c xkeyp.c <<'END_OF_xkeyp.c' X/* X * $Header: xkeyp.c,v 1.2 88/02/13 12:54:50 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "xgo.h" X#include X Xchar line[MAXLINE]=""; XKeyPress(ev) XXKeyPressedEvent *ev; X{ X char *temp; X int nb; X temp = XLookupMapping(ev, &nb); X if (nb!=0) domesg(*temp); X} X/* X * $Log: xkeyp.c,v $ X * Revision 1.2 88/02/13 12:54:50 hale X * added logging. X * X */ X END_OF_xkeyp.c if test 830 -ne `wc -c xpiecenum.h <<'END_OF_xpiecenum.h' X/* X * $Header: xpiecenum.h,v 1.2 88/02/13 12:57:42 hale Exp $ X */ X X/* X X Copyright 1987 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 X#define Smask 0 X#define Smask0 1 X#define Spiecemask 2 X#define Sintersect 3 X#define Spoint 4 X#define Sblack 6 X#define Swhite 5 X#define Sdl 7 X#define Sdr 8 X#define Sul 9 X#define Sur 10 X#define Su 11 X#define Sr 12 X#define Sd 13 X#define Sl 14 X#define Sneu 15 X#define Sfbl 16 X#define Sfwh 17 X#define Sbutton 18 X/* X * $Log: xpiecenum.h,v $ X * Revision 1.2 88/02/13 12:57:42 hale X * added logging. X * X */ X END_OF_xpiecenum.h if test 961 -ne `wc -c xplt.c <<'END_OF_xplt.c' X/* X * $Header: xplt.c,v 1.2 88/02/13 12:55:02 hale Locked $ X */ X X/* X X Copyright 1987 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 X#include "xgo.h" X XPlt(br,x,y) XBOARD *br; Xint x,y; X{ X PltPiece(x,y,br->d[x][y]); X} X X/* X * $Log: xplt.c,v $ X * Revision 1.2 88/02/13 12:55:02 hale X * added logging. X * X */ X END_OF_xplt.c if test 732 -ne `wc -c xprintboard.c <<'END_OF_xprintboard.c' X/* X * $Header: xprintboard.c,v 1.2 88/02/13 12:55:10 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include "xgo.h" X XPrintBoard(br) XBOARD *br; X{ X int x,y; X for(y=0; y MAXY-1) y2 = MAXY-1; X if (x1 < 0) x1 = 0; X if (x2 > MAXX-1) x2 = MAXX-1; X for(y=y1; y<=y2; y++) X for(x=x1; x<=x2; x++) X Plt(br,x,y); X initmesg(); X} X Xprintscore() X{ X X} X/* X * $Log: xprintboard.c,v $ X * Revision 1.2 88/02/13 12:55:10 hale X * added logging. X * X */ X END_OF_xprintboard.c if test 1067 -ne `wc -c xtraps.c <<'END_OF_xtraps.c' X/* X * $Header: xtraps.c,v 1.2 88/02/13 12:55:18 hale Exp $ X */ X X/* X X Copyright 1987 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 X#ifndef lint Xstatic char rcsid[] = "$Header: xtraps.c,v 1.2 88/02/13 12:55:18 hale Exp $"; X#endif X X#include "go.h" X#include X Xtrap_sigint () X{ X signal (SIGINT, SIG_IGN); X SEND(MEXIT); X Exit(); X} X X Xts_tp () X{ X int y, x; X char c; X X signal (SIGTSTP, SIG_IGN); X X resetty(); X X sleep (-1); X X setmode(); X X X signal (SIGINT, ts_tp); X} X X X/* X * $Log: xtraps.c,v $ X * Revision 1.2 88/02/13 12:55:18 hale X * added logging. X * X */ X END_OF_xtraps.c if test 990 -ne `wc -c xvar.c <<'END_OF_xvar.c' X/* X * $Header: xvar.c,v 1.3 88/02/19 13:49:52 hale Exp $ X */ X X/* X X Copyright 1987 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 X#include X XWindow Wboard,Wtalk,Wtalk1,Wmesg,Waccept,Wdecline, X Wscore,Wquit,Wtally,Wpass,Wcancel,Wplay, X Wexit,Wswitch,Wshow,Wresign,Wsave, Wload, X Wclear; XFontInfo *fi; XDisplay *dis; X Xint turn=0; X/* X * $Log: xvar.c,v $ X * Revision 1.3 88/02/19 13:49:52 hale X * Added io changes for loading games. X * Load game is cleaned up. Variable board X * sizes and formats available in save game X * as well as printed comments. X * X * Revision 1.2 88/02/13 12:55:27 hale X * new window variables. X * X */ X END_OF_xvar.c if test 1064 -ne `wc -c