v06i019: gnugo - game of GO from the GNU folks, Part01/03

313 views
Skip to first unread message

ga...@tekred.cna.tek.com

unread,
Mar 13, 1989, 2:46:36 PM3/13/89
to
Submitted-by: Man Lung Li <ma...@sun2.cs.uh.edu>
Posting-number: Volume 6, Issue 19
Archive-name: gnugo/Part01

[The original Makefile was specific for Sun's make program. I
rewrote it to be able to work with most generic Unix makes.
I compiled and ran it OK on our 4.3bsd Vax. -br]

#! /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 1 (of 3)."
# Contents: README MANIFEST COPYING Documentation make.bat matchpat.c
# patterns.c showbord.c
# Wrapped by billr@saab on Mon Mar 13 11:04:58 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(3888 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X GNU GO - the game of Go (Wei-Chi)
X Version 1.1 last revised 3-1-89
X Copyright (C) Free Software Foundation, Inc.
X written by Man L. Li
X modified by Wayne Iba
X documented by Bob Webber
X
XThis program is the updated version of Hugo (Version 1.0). It is an
Xattempt to start a free program to play Go. The idea is based on the
Xarticle "Programming the Game of Go. Byte, Vol.6 No.4" by J. K. Millen.
X
XCurrently, this program only understands basic Go rules and play skills.
XIt counts the number of liberty for each board piece. Computer move is
Xgenerated by choosing among several possible moves to attack the opponent,
Xdefense own pieces and match playing patterns. If no good move is found
Xthen random move will be generated. It doesn't have the concept of eye
Xalthough it will try to form one.
X
XThe program is written in C running on Sun and IBM PC. The only difference
Xis the function to get system time as the seed for the random number
Xgenerator. It can easily ported to other systems by changing this function.
XComputer Innovation C86 compiler is used for the PC version. To use other
XC compilers, simple change is required.
X
XYou are encouraged to send in enhencement, suggestion, bug/fix for this
Xprogram. Future release can be obtained from Free Software Foundation and
Xusenet rec.games.go newsgroup.
X
XThis package contains the following files:
X
XREADME - you are reading it.
X
XCOPYING - GNU general public license
X
XDocumentation - description of each function
X
XMakefile - file to compile gnugo program on Sun
X
Xmake.bat - file to compile gnugo program on IBM PC with C86 compiler
X
Xobjs - linking list used by make.bat
X
Xcount.c - count liberty of one piece
X
Xcountlib.c - count liberty of pieces
X
Xendgame.c - bookkeeping at end of game
X
Xeval.c - evaluate liberty
X
Xexambord.c - update game board
X
Xfindcolr.c - find connected pieces of the same color
X
Xfindnext.c - find move to defense against attack and function to evaluate move
X
Xfindopen.c - find opponent liberty and choose move to attack
X
Xfindpatn.c - match play patterns for next move
X
Xfindsavr.c - check own weakness to defense
X
Xfindwinr.c - find opponent weakness to attack
X
Xfioe.c - check if fill in its own eye
X
Xgenmove.c - main function to generate computer move
X
Xgetij.c - convert move string to board position
X
Xgetmove.c - read move or command from human player
X
Xinitmark.c - initialize marking array
X
Xmain.c - gnugo main program
X
Xmatchpat.c - match play pattern
X
Xopening.c - generate game opening moves
X
Xopenregn.c - check open region
X
Xpatterns.c - playing patterns
X
Xrandom.c - random number generator
X
Xseed.c - start random number generator seed
X
Xsethand.c - setup handicap pieces
X
Xshowbord.c - show GO board and stone positions
X
Xshowinst.c - show instruction on game playing
X
Xsuicide.c - check illegal move if suicide
X
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation - version 1.
X
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
XGNU General Public License in file COPYING for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XPlease report any bug/fix, modification, suggestion to
X
Xmail address: Man L. Li
X Dept. of Computer Science
X University of Houston
X 4800 Calhoun Road
X Houston, TX 77004
X
Xe-mail address: ma...@cs.uh.edu (Internet)
X cos...@uhvax1.bitnet (BITNET)
X 70070,404 (CompuServe)
X
END_OF_FILE
if test 3888 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1168 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X File Name Archive # Description
X-----------------------------------------------------------
X COPYING 1
X Documentation 1
X MANIFEST 1 This shipping list
X Makefile 2
X README 1
X count.c 2
X countlib.c 3
X endgame.c 2
X eval.c 3
X exambord.c 2
X findcolr.c 2
X findnext.c 2
X findopen.c 2
X findpatn.c 2
X findsavr.c 3
X findwinr.c 2
X fioe.c 2
X genmove.c 2
X getij.c 3
X getmove.c 2
X initmark.c 3
X main.c 2
X make.bat 1
X matchpat.c 1
X objs 2
X opening.c 2
X openregn.c 3
X patterns.c 1
X random.c 3
X seed.c 3
X sethand.c 2
X showbord.c 1
X showinst.c 2
X suicide.c 3
END_OF_FILE
if test 1168 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'COPYING' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'COPYING'\"
else
echo shar: Extracting \"'COPYING'\" \(9934 characters\)
sed "s/^X//" >'COPYING' <<'END_OF_FILE'
X GNU GENERAL PUBLIC LICENSE
X Version 1, February 1989
X
X Copyright (C) 1989 Free Software Foundation, Inc.
X 675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X Preamble
X
X The license agreements of most software companies try to keep users
Xat the mercy of those companies. By contrast, our General Public
XLicense is intended to guarantee your freedom to share and change free
Xsoftware--to make sure the software is free for all its users. The
XGeneral Public License applies to the Free Software Foundation's
Xsoftware and to any other program whose authors commit to using it.
XYou can use it for your programs, too.
X
X When we speak of free software, we are referring to freedom, not
Xprice. Specifically, the General Public License is designed to make
Xsure that you have the freedom to give away or sell copies of free
Xsoftware, that you receive source code or can get it if you want it,
Xthat you can change the software or use pieces of it in new free
Xprograms; and that you know you can do these things.
X
X To protect your rights, we need to make restrictions that forbid
Xanyone to deny you these rights or to ask you to surrender the rights.
XThese restrictions translate to certain responsibilities for you if you
Xdistribute copies of the software, or if you modify it.
X
X For example, if you distribute copies of a such a program, whether
Xgratis or for a fee, you must give the recipients all the rights that
Xyou have. You must make sure that they, too, receive or can get the
Xsource code. And you must tell them their rights.
X
X We protect your rights with two steps: (1) copyright the software, and
X(2) offer you this license which gives you legal permission to copy,
Xdistribute and/or modify the software.
X
X Also, for each author's protection and ours, we want to make certain
Xthat everyone understands that there is no warranty for this free
Xsoftware. If the software is modified by someone else and passed on, we
Xwant its recipients to know that what they have is not the original, so
Xthat any problems introduced by others will not reflect on the original
Xauthors' reputations.
X
X The precise terms and conditions for copying, distribution and
Xmodification follow.
X
X GNU GENERAL PUBLIC LICENSE
X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X 0. This License Agreement applies to any program or other work which
Xcontains a notice placed by the copyright holder saying it may be
Xdistributed under the terms of this General Public License. The
X"Program", below, refers to any such program or work, and a "work based
Xon the Program" means either the Program or any work containing the
XProgram or a portion of it, either verbatim or with modifications. Each
Xlicensee is addressed as "you".
X
X 1. You may copy and distribute verbatim copies of the Program's source
Xcode as you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy an appropriate copyright notice and
Xdisclaimer of warranty; keep intact all the notices that refer to this
XGeneral Public License and to the absence of any warranty; and give any
Xother recipients of the Program a copy of this General Public License
Xalong with the Program. You may charge a fee for the physical act of
Xtransferring a copy.
X
X 2. You may modify your copy or copies of the Program or any portion of
Xit, and copy and distribute such modifications under the terms of Paragraph
X1 above, provided that you also do the following:
X
X a) cause the modified files to carry prominent notices stating that
X you changed the files and the date of any change; and
X
X b) cause the whole of any work that you distribute or publish, that
X in whole or in part contains the Program or any part thereof, either
X with or without modifications, to be licensed at no charge to all
X third parties under the terms of this General Public License (except
X that you may choose to grant warranty protection to some or all
X third parties, at your option).
X
X c) If the modified program normally reads commands interactively when
X run, you must cause it, when started running for such interactive use
X in the simplest and most usual way, to print or display an
X announcement including an appropriate copyright notice and a notice
X that there is no warranty (or else, saying that you provide a
X warranty) and that users may redistribute the program under these
X conditions, and telling the user how to view a copy of this General
X Public License.
X
X d) You may charge a fee for the physical act of transferring a
X copy, and you may at your option offer warranty protection in
X exchange for a fee.
X
XMere aggregation of another independent work with the Program (or its
Xderivative) on a volume of a storage or distribution medium does not bring
Xthe other work under the scope of these terms.
X
X 3. You may copy and distribute the Program (or a portion or derivative of
Xit, under Paragraph 2) in object code or executable form under the terms of
XParagraphs 1 and 2 above provided that you also do one of the following:
X
X a) accompany it with the complete corresponding machine-readable
X source code, which must be distributed under the terms of
X Paragraphs 1 and 2 above; or,
X
X b) accompany it with a written offer, valid for at least three
X years, to give any third party free (except for a nominal charge
X for the cost of distribution) a complete machine-readable copy of the
X corresponding source code, to be distributed under the terms of
X Paragraphs 1 and 2 above; or,
X
X c) accompany it with the information you received as to where the
X corresponding source code may be obtained. (This alternative is
X allowed only for noncommercial distribution and only if you
X received the program in object code or executable form alone.)
X
XSource code for a work means the preferred form of the work for making
Xmodifications to it. For an executable file, complete source code means
Xall the source code for all modules it contains; but, as a special
Xexception, it need not include source code for modules which are standard
Xlibraries that accompany the operating system on which the executable
Xfile runs, or for standard header files or definitions files that
Xaccompany that operating system.
X
X 4. You may not copy, modify, sublicense, distribute or transfer the
XProgram except as expressly provided under this General Public License.
XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
Xthe Program is void, and will automatically terminate your rights to use
Xthe Program under this License. However, parties who have received
Xcopies, or rights to use copies, from you under this General Public
XLicense will not have their licenses terminated so long as such parties
Xremain in full compliance.
X
X 5. By copying, distributing or modifying the Program (or any work based
Xon the Program) you indicate your acceptance of this license to do so,
Xand all its terms and conditions.
X
X 6. Each time you redistribute the Program (or any work based on the
XProgram), the recipient automatically receives a license from the original
Xlicensor to copy, distribute or modify the Program subject to these
Xterms and conditions. You may not impose any further restrictions on the
Xrecipients' exercise of the rights granted herein.
X
X 7. The Free Software Foundation may publish revised and/or new versions
Xof the General Public License from time to time. Such new versions will
Xbe similar in spirit to the present version, but may differ in detail to
Xaddress new problems or concerns.
X
XEach version is given a distinguishing version number. If the Program
Xspecifies a version number of the license which applies to it and "any
Xlater version", you have the option of following the terms and conditions
Xeither of that version or of any later version published by the Free
XSoftware Foundation. If the Program does not specify a version number of
Xthe license, you may choose any version ever published by the Free Software
XFoundation.
X
X 8. If you wish to incorporate parts of the Program into other free
Xprograms whose distribution conditions are different, write to the author
Xto ask for permission. For software which is copyrighted by the Free
XSoftware Foundation, write to the Free Software Foundation; we sometimes
Xmake exceptions for this. Our decision will be guided by the two goals
Xof preserving the free status of all derivatives of our free software and
Xof promoting the sharing and reuse of software generally.
X
X NO WARRANTY
X
X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
XREPAIR OR CORRECTION.
X
X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
XPOSSIBILITY OF SUCH DAMAGES.
X
X END OF TERMS AND CONDITIONS
END_OF_FILE
if test 9934 -ne `wc -c <'COPYING'`; then
echo shar: \"'COPYING'\" unpacked with wrong size!
fi
# end of 'COPYING'
fi
if test -f 'Documentation' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Documentation'\"
else
echo shar: Extracting \"'Documentation'\" \(11360 characters\)
sed "s/^X//" >'Documentation' <<'END_OF_FILE'
X GNU GO - the game of Go (Wei-Chi)
X Version 1.1 last revised 3-1-89
X Copyright (C) Free Software Foundation, Inc.
X written by Man L. Li
X modified by Wayne Iba
X documented by Bob Webber
X
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation - version 1.
X
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
XGNU General Public License in file COPYING for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XPlease report any bug/fix, modification, suggestion to
X
Xmail address: Man L. Li
X Dept. of Computer Science
X University of Houston
X 4800 Calhoun Road
X Houston, TX 77004
X
Xe-mail address: ma...@cs.uh.edu (Internet)
X cos...@uhvax1.bitnet (BITNET)
X 70070,404 (CompuServe)
X
X
Xvalue 0 always used to mark empty square
Xvalue 1 always used to indicate white
Xvalue 2 always used to indicate black
X
Xmain()
X Shows instructions.
X
X If old game then read in information otherwise
X Initializes the board stored in the board array p to zero.
X
X Requests handicap (stored in local variable i.)
X
X Displays board.
X
X Asks which side you want to play (stored in local variable ans)
X mymove and umove indicate color played by computer and user, respectively.
X
X if user black in handicap game or white in even game, computer goes first.
X
X making a move means updating the board with the numeric value for color
X of player. genmove takes board indices i & j as reference parameters
X and returns the ones that correspond to a new move for the computer,
X it does not update the board. the routine examboard then clears
X of dead pieces (of the color passed as its parameter). after the board
X has been updated, showboard displays board.
X
X routine getmove convert the string the user types in into a valid
X move i,j pair.
X
X getmove manipulates global variable stop to indicate when game is
X done.
X
X the game stop after both pass, the user want to quit and save game
X or the user stop the game
X
X at the end of game, if the user types y to ``count score'' prompt,
X then endgame is invoked, otherwise the program exits.
X
X
Xshowboard()
X displays go board with algebraic notation on borders. special logic
X to make sure handicap markers are displayed appropriately done by
X brute force.
X
X
Xgetmove(move, i, j)
X if move = "stop" then global variable play changed to 0 exiting loop
X
X if move = "save" then write game information to file and exit by
X setting global variable to -1
X
X if move = "pass" then increment global variable pass
X otherwise, clear pass flag getij is invoked to convert move into i and j
X coordinates.
X if the board position is not empty, the last piece captured by
X computer, or suicide predicate is true, then the move is flagged as
X illegal and getmove recurses.
X
X
Xgetij(move, i, j)
X move string converted to board coordinates.
X
X
Xgenmove(i, j)
X generates computers move and returns it in pointers i & j.
X invoke eval(umove) to re-evaluate liberty of opponent pieces
X
X findwinner looks for pieces of user that only have 3 or less liberties.
X findsaver looks for pieces of computer that only have 3 or less liberties.
X findpat looks for a pattern in stored database that can be used here.
X
X STRATEGY:
X choose move with maximum value from the followings:
X
X find opponent piece to capture or attack with less than four liberties
X save any piece if threaten with less than four liberties
X try to match local play pattern for new move
X
X no urgent move then do random move
X when generating random move, bias row and column x
X by rejecting the first x that satisfies
X ((x < 2) || (x > 16) || ((x > 5) && (x < 13)))
X and on second try, reject an x that satisfies
X ((x < 2) || (x > 16))
X on third try, take what you get. done independently for
X i and j.
X invoke countlib to count liberties, if spot already taken
X or liberties (taken off global lib) 0 or 1 or fill in own eye then
X reject.
X
X if number of try equals to MAXTRY then pass
X
X after following STRATEGY to determine move, print it.
X
X
Xseed(i)
X sets up a seed. two versions depending on whether Sun (which uses
X gettimeofday to set seed) or IBM PC (which uses interrupt 21 to get system
X time).
X
X
Xrandom(i)
X simple conguence random number generator. only used for making ``random''
X moves, either in genmove() or in opening().
X
X
Xeval(color)
X evaluate liberties of pieces of a particular color using countlib.
X result stored in global array l.
X
X
Xexamboard(color)
X invokes eval(color)
X remove pieces with zero liberties, updating count of pieces captured
X in variables mk and uk for computer and user respectively.
X
X
Xsuicide(i, j)
X check to see if new move is suicide via countlib(). if it is, check to
X see if it kills computer's pieces via eval() or if Ko takes place
X returns 0 if move is good.
X
X
Xcountlib(m, n, color)
X initializes global array ml to 1's and then uses routine count() to
X count liberties at each square.
X
X
Xcount(i, j, color)
X count liberties at given square. zero out value of that square.
X if neighbor is still unmarked and its value on the board is still zero,
X then it is marked as zero and lib count is updated,
X if neighbor is same color and unmarked, then count is recursively called.
X this is done for all four neighbors, then the routine returns.
X
X essentially this does a connected component search on region connected
X to location i & j.
X
X
Xfindnextmove(m, n, i, j, val, minlib)
X used by findsaver() to find next move for defense.
X find new move i, j from group containing m, n
X uses global array ma to keep track of where it has been.
X for each neighbor, checks to see if it is empty. If so, then it
X calculate the new liberty and the relative value of the move.
X Otherwise recurses on that neighbor. After new move is found compare
X it with other move and use the one with higher value.
X returns 0 if couldn't find move.
X
X
Xfindwinner(i, j, val)
X looks for an opponents piece to capture or attack with 1 to 3 liberties.
X for each cell, check to see if its liberties are minlib and if so
X invoke initmark. evaluate move via findopen. if findopen returns
X 1, then assign value to possible move.
X select new move with highest value and return 1.
X returns 0 if findopen never succeeded.
X
X
Xinitmark()
X initialize ma array to zero.
X
X
Xfindopen(m, n, i, j, color, minlib, ct)
X called by findwinner to find all open spaces for opponent's piece.
X marks m,n entry in ma array.
X for each neighbor, if neighbor is empty spot and not last place captured,
X then count till all spaces are found and return 1 and move in i and j.
X else if spot is color and not marked, then recurse returning 1 if
X any subinvocation returns 1.
X
X
Xfindsaver(i, j, val)
X find move if any pieces of 1 to 3 liberties is threatened
X count how many pieces have minlib liberties.
X if none, return 0.
X else, for each cell, if one of computer's pieces and liberty is minlib,
X then initmark(), and look for move via findnextmove. if succeeds
X then assign value for possible move. decrement count of pieces
X threatened and select next move with maximum value and return
X 1.
X If no new move can be found then return zero and exit.
X
Xfindpatn(i, j)
X if previous invocation of findpatn marked, then invoke opening
X in that corner. if opening can find a move on a vacant square,
X then mark this invocation and return value. if not, then
X clear mark and investigate corners.
X for each marked corner (all corners initially marked), look to see if
X opening can find a move by calling opening() twice. if it can,
X mark invocation and return that move.
X for each side, look to see if a particular large empty region exists,
X if it does, make a particular move into that region.
X use mathpat on each board location looking for pattern-moves to make
X and select move with maximum value.
X if none of these find something, return 0.
X
X
Xmatchpat(m, n, i, j, val)
X for each given pattern, try all ways of placing them down with a corner
X at m,n. return recommended i,j and value if match found. pattern
X notation specifies cells that should be empty, where pieces of both sides
X should be, whether must be on edge, and recommended move. patterns
X consist of at most 16 specified locations. Try all patterns for each
X piece and select the one with highest value. Adjust value for patterns
X to expand territories in favor of move at third and fourth line. Reduce
X value for move at first and second line. Return 1 if pattern found else
X return zero.
X
X
Xopenregion(i1, j1, i2, j2)
X checks to see if rectangular region is all empty.
X
X
Xopening(i, j, cnd, type)
X type keeps track of which corner, move is reflected thru corner and
X chosen without actually looking at board.
X cnd indicates which move to make this time. a move consists of a
X location relative to a corner and a count of how many useful
X different followup moves there all. the useful followups are listed
X by index into the same structure -- the one recommended for next
X move is chosen randomly among possible moves.
X first time in, location -1,-1 is returned. this value is always ignored.
X
X
Xsethand(i)
X setup handicap stones by brute force analysis.
X
X
Xendgame()
X keeps count of captures removed by user cleaning up board, keeps track
X of dame placed by user cleaning up board, and uses findcolor to classify
X territories. final count presented with updated board showing how
X everything was classified.
X
X
Xfindcolor(i, j)
X determines what color to label empty squares when counting up score
X at end of game. algorithm is to check both north and south neighbors
X until run into occupied square or end of board. if both are vacant
X then east and west neighbors checked same way. if both are vacant
X return zero. if one neighbor zero and other nonzero, return color
X of nonzero neighbor. if both neighbors nonzero and same, then return
X that color. if both neighbors nonzero but differ, then return zero.
X
X
Xshowinst()
X shows program header and a list of instructions to user.
X
X
Xfioe(i, j)
X check if new move (i, j) will fill in own eye at center and edge. Only
X single hole eye is checked.
X
X
Xfval(newlib, minlib)
X used in findnextmove in findnext.c. Calculate relative value for new
X move having newlib liberties with old pieces having minlib liberties.
END_OF_FILE
if test 11360 -ne `wc -c <'Documentation'`; then
echo shar: \"'Documentation'\" unpacked with wrong size!
fi
# end of 'Documentation'
fi
if test -f 'make.bat' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'make.bat'\"
else
echo shar: Extracting \"'make.bat'\" \(4983 characters\)
sed "s/^X//" >'make.bat' <<'END_OF_FILE'
Xif EXIST count.obj goto l1
Xcc1 COUNT
Xif errorlevel 1 goto done
Xcc2 COUNT
Xif errorlevel 1 goto done
Xcc3 COUNT
Xif errorlevel 1 goto done
Xcc4 COUNT
Xif errorlevel 1 goto done
X:l1
Xif EXIST countlib.obj goto l2
Xcc1 COUNTLIB
Xif errorlevel 1 goto done
Xcc2 COUNTLIB
Xif errorlevel 1 goto done
Xcc3 COUNTLIB
Xif errorlevel 1 goto done
Xcc4 COUNTLIB
Xif errorlevel 1 goto done
X:l2
Xif EXIST endgame.obj goto l3
Xcc1 ENDGAME
Xif errorlevel 1 goto done
Xcc2 ENDGAME
Xif errorlevel 1 goto done
Xcc3 ENDGAME
Xif errorlevel 1 goto done
Xcc4 ENDGAME
Xif errorlevel 1 goto done
X:l3
Xif EXIST eval.obj goto l4
Xcc1 EVAL
Xif errorlevel 1 goto done
Xcc2 EVAL
Xif errorlevel 1 goto done
Xcc3 EVAL
Xif errorlevel 1 goto done
Xcc4 EVAL
Xif errorlevel 1 goto done
X:l4
Xif EXIST exambord.obj goto l5
Xcc1 EXAMBORD
Xif errorlevel 1 goto done
Xcc2 EXAMBORD
Xif errorlevel 1 goto done
Xcc3 EXAMBORD
Xif errorlevel 1 goto done
Xcc4 EXAMBORD
Xif errorlevel 1 goto done
X:l5
Xif EXIST findcolr.obj goto l6
Xcc1 FINDCOLR
Xif errorlevel 1 goto done
Xcc2 FINDCOLR
Xif errorlevel 1 goto done
Xcc3 FINDCOLR
Xif errorlevel 1 goto done
Xcc4 FINDCOLR
Xif errorlevel 1 goto done
X:l6
Xif EXIST findnext.obj goto l7
Xcc1 FINDNEXT
Xif errorlevel 1 goto done
Xcc2 FINDNEXT
Xif errorlevel 1 goto done
Xcc3 FINDNEXT
Xif errorlevel 1 goto done
Xcc4 FINDNEXT
Xif errorlevel 1 goto done
X:l7
Xif EXIST findopen.obj goto l8
Xcc1 FINDOPEN
Xif errorlevel 1 goto done
Xcc2 FINDOPEN
Xif errorlevel 1 goto done
Xcc3 FINDOPEN
Xif errorlevel 1 goto done
Xcc4 FINDOPEN
Xif errorlevel 1 goto done
X:l8
Xif EXIST findpatn.obj goto l9
Xcc1 FINDPATN
Xif errorlevel 1 goto done
Xcc2 FINDPATN
Xif errorlevel 1 goto done
Xcc3 FINDPATN
Xif errorlevel 1 goto done
Xcc4 FINDPATN
Xif errorlevel 1 goto done
X:l9
Xif EXIST findsavr.obj goto l10
Xcc1 FINDSAVR
Xif errorlevel 1 goto done
Xcc2 FINDSAVR
Xif errorlevel 1 goto done
Xcc3 FINDSAVR
Xif errorlevel 1 goto done
Xcc4 FINDSAVR
Xif errorlevel 1 goto done
X:l10
Xif EXIST findwinr.obj goto l11
Xcc1 FINDWINR
Xif errorlevel 1 goto done
Xcc2 FINDWINR
Xif errorlevel 1 goto done
Xcc3 FINDWINR
Xif errorlevel 1 goto done
Xcc4 FINDWINR
Xif errorlevel 1 goto done
X:l11
Xif EXIST fioe.obj goto l12
Xcc1 FIOE
Xif errorlevel 1 goto done
Xcc2 FIOE
Xif errorlevel 1 goto done
Xcc3 FIOE
Xif errorlevel 1 goto done
Xcc4 FIOE
Xif errorlevel 1 goto done
X:l12
Xif EXIST genmove.obj goto l13
Xcc1 GENMOVE
Xif errorlevel 1 goto done
Xcc2 GENMOVE
Xif errorlevel 1 goto done
Xcc3 GENMOVE
Xif errorlevel 1 goto done
Xcc4 GENMOVE
Xif errorlevel 1 goto done
X:l13
Xif EXIST getij.obj goto l14
Xcc1 GETIJ
Xif errorlevel 1 goto done
Xcc2 GETIJ
Xif errorlevel 1 goto done
Xcc3 GETIJ
Xif errorlevel 1 goto done
Xcc4 GETIJ
Xif errorlevel 1 goto done
X:l14
Xif EXIST getmove.obj goto l15
Xcc1 GETMOVE
Xif errorlevel 1 goto done
Xcc2 GETMOVE
Xif errorlevel 1 goto done
Xcc3 GETMOVE
Xif errorlevel 1 goto done
Xcc4 GETMOVE
Xif errorlevel 1 goto done
X:l15
Xif EXIST initmark.obj goto l16
Xcc1 INITMARK
Xif errorlevel 1 goto done
Xcc2 INITMARK
Xif errorlevel 1 goto done
Xcc3 INITMARK
Xif errorlevel 1 goto done
Xcc4 INITMARK
Xif errorlevel 1 goto done
X:l16
Xif EXIST main.obj goto l17
Xcc1 MAIN
Xif errorlevel 1 goto done
Xcc2 MAIN
Xif errorlevel 1 goto done
Xcc3 MAIN
Xif errorlevel 1 goto done
Xcc4 MAIN
Xif errorlevel 1 goto done
X:l17
Xif EXIST matchpat.obj goto l18
Xcc1 MATCHPAT
Xif errorlevel 1 goto done
Xcc2 MATCHPAT
Xif errorlevel 1 goto done
Xcc3 MATCHPAT
Xif errorlevel 1 goto done
Xcc4 MATCHPAT
Xif errorlevel 1 goto done
X:l18
Xif EXIST opening.obj goto l19
Xcc1 OPENING
Xif errorlevel 1 goto done
Xcc2 OPENING
Xif errorlevel 1 goto done
Xcc3 OPENING
Xif errorlevel 1 goto done
Xcc4 OPENING
Xif errorlevel 1 goto done
X:l19
Xif EXIST openregn.obj goto l20
Xcc1 OPENREGN
Xif errorlevel 1 goto done
Xcc2 OPENREGN
Xif errorlevel 1 goto done
Xcc3 OPENREGN
Xif errorlevel 1 goto done
Xcc4 OPENREGN
Xif errorlevel 1 goto done
X:l20
Xif EXIST random.obj goto l21
Xcc1 RANDOM
Xif errorlevel 1 goto done
Xcc2 RANDOM
Xif errorlevel 1 goto done
Xcc3 RANDOM
Xif errorlevel 1 goto done
Xcc4 RANDOM
Xif errorlevel 1 goto done
X:l21
Xif EXIST seed.obj goto l22
Xcc1 SEED
Xif errorlevel 1 goto done
Xcc2 SEED
Xif errorlevel 1 goto done
Xcc3 SEED
Xif errorlevel 1 goto done
Xcc4 SEED
Xif errorlevel 1 goto done
X:l22
Xif EXIST sethand.obj goto l23
Xcc1 SETHAND
Xif errorlevel 1 goto done
Xcc2 SETHAND
Xif errorlevel 1 goto done
Xcc3 SETHAND
Xif errorlevel 1 goto done
Xcc4 SETHAND
Xif errorlevel 1 goto done
X:l23
Xif EXIST showbord.obj goto l24
Xcc1 SHOWBORD
Xif errorlevel 1 goto done
Xcc2 SHOWBORD
Xif errorlevel 1 goto done
Xcc3 SHOWBORD
Xif errorlevel 1 goto done
Xcc4 SHOWBORD
Xif errorlevel 1 goto done
X:l24
Xif EXIST showinst.obj goto l25
Xcc1 SHOWINST
Xif errorlevel 1 goto done
Xcc2 SHOWINST
Xif errorlevel 1 goto done
Xcc3 SHOWINST
Xif errorlevel 1 goto done
Xcc4 SHOWINST
Xif errorlevel 1 goto done
X:l25
Xif EXIST suicide.obj goto l26
Xcc1 SUICIDE
Xif errorlevel 1 goto done
Xcc2 SUICIDE
Xif errorlevel 1 goto done
Xcc3 SUICIDE
Xif errorlevel 1 goto done
Xcc4 SUICIDE
Xif errorlevel 1 goto done
X:l26
Xlink @objs, gnugo,,d:\lang\c\c86\c86sas.lib
Xif errorlevel 1 goto err
Xgoto allok
X:done
Xpause error in compilation
Xgoto allok
X:err
Xpause error in linking
X:allok
END_OF_FILE
if test 4983 -ne `wc -c <'make.bat'`; then
echo shar: \"'make.bat'\" unpacked with wrong size!
fi
# end of 'make.bat'
fi
if test -f 'matchpat.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'matchpat.c'\"
else
echo shar: Extracting \"'matchpat.c'\" \(5175 characters\)
sed "s/^X//" >'matchpat.c' <<'END_OF_FILE'
X/*
X GNU GO - the game of Go (Wei-Chi)
X Version 1.1 last revised 3-1-89
X Copyright (C) Free Software Foundation, Inc.
X written by Man L. Li
X modified by Wayne Iba
X documented by Bob Webber
X*/
X/*
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation - version 1.
X
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
XGNU General Public License in file COPYING for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XPlease report any bug/fix, modification, suggestion to
X
Xmail address: Man L. Li
X Dept. of Computer Science
X University of Houston
X 4800 Calhoun Road
X Houston, TX 77004
X
Xe-mail address: ma...@cs.uh.edu (Internet)
X cos...@uhvax1.bitnet (BITNET)
X 70070,404 (CompuServe)
X*/
X
X#include <stdio.h>
X
X#define EMPTY 0
X#define MAXPC 16
X#define abs(x) ((x) < 0 ? -(x) : (x))
X#define line(x) (abs(x - 9))
X
Xextern unsigned char p[19][19];
Xextern int mymove, umove;
Xextern int lib;
X
Xmatchpat(m, n, i, j, val)
X/* match pattern and get next move */
Xint m, n, *i, *j, *val;
X{
X struct patval {int x, y, att;}; /* pattern x, y coor and attribute */
X/* att = 0 - empty, 1 - your piece, 2 - my piece, 3 - my next move */
X/* 4 - empty on edge, 5 - your piece on edge, 6 - my piece on edge */
X struct pattern {
X struct patval patn[MAXPC]; /* pattern */
X/* number of pieces in pattern, no. of transformation, pattern value */
X int patlen, trfno, patwt;
X };
X
X#include "patterns.c"
X
X/* transformation matrice */
X static int trf [8][2][2] = {
X {{1, 0}, {0, 1}}, /* linear transfomation matrix */
X {{1, 0}, {0, -1}}, /* invert */
X {{0, 1}, {-1, 0}}, /* rotate 90 */
X {{0, -1}, {-1, 0}}, /* rotate 90 and invert */
X {{-1, 0}, {0, 1}}, /* flip left */
X {{-1, 0}, {0, -1}}, /* flip left and invert */
X {{0, 1}, {1, 0}}, /* rotate 90 and flip left */
X {{0, -1}, {1, 0}} /* rotate 90, flip left and invert */
X };
X int k, my, nx, l, r, cont;
X int ti, tj, tval;
X
X *i = -1; *j = -1; *val = -1;
X for (r = 0; r < PATNO; r++)
X/* try each pattern */
X for (l = 0; l < pat[r].trfno; l++)
X/* try each orientation transformation */
X {
X k = 0; cont = 1;
X while ((k != pat[r].patlen) && cont)
X/* match each point */
X {
X/* transform pattern real coordinate */
X nx = n + trf[l][0][0] * pat[r].patn[k].x
X + trf[l][0][1] * pat[r].patn[k].y;
X my = m + trf[l][1][0] * pat[r].patn[k].x
X + trf[l][1][1] * pat[r].patn[k].y;
X
X/* outside the board */
X if ((my < 0) || ( my > 18) || (nx < 0) || (nx > 18))
X {
X cont = 0;
X break;
X }
X switch (pat[r].patn[k].att) {
X case 0 : if (p[my][nx] == EMPTY) /* open */
X break;
X else
X {
X cont = 0;
X break;
X }
X case 1 : if (p[my][nx] == umove) /* your piece */
X break;
X else
X {
X cont = 0;
X break;
X }
X case 2 : if (p[my][nx] == mymove) /* my piece */
X break;
X else
X {
X cont = 0;
X break;
X }
X case 3 : if (p[my][nx] == EMPTY) /* open for new move */
X {
X lib = 0;
X countlib(my, nx, mymove); /* check liberty */
X if (lib > 1) /* move o.k. */
X {
X ti = my;
X tj = nx;
X break;
X }
X else
X {
X cont = 0;
X break;
X }
X }
X else
X {
X cont = 0;
X break;
X }
X case 4 : if ((p[my][nx] == EMPTY) /* open on edge */
X && ((my == 0) || (my == 18) || (nx == 0) || (nx == 18)))
X break;
X else
X {
X cont = 0;
X break;
X }
X case 5 : if ((p[my][nx] == umove) /* your piece on edge */
X && ((my == 0) || (my == 18) || (nx == 0) || (nx == 18)))
X break;
X else
X {
X cont = 0;
X break;
X }
X case 6 : if ((p[my][nx] == mymove) /* my piece on edge */
X && ((my == 0) || (my == 18) || (nx == 0) || (nx == 18)))
X break;
X else
X {
X cont = 0;
X break;
X }
X }
X ++k;
X }
X if (cont) /* match pattern */
X {
X tval = pat[r].patwt;
X if ((r >= 8) && (r <= 13)) /* patterns for expand region */
X {
X if (line(ti) > 7) /* penalty on line 1, 2 */
X tval--;
X else
X if ((line(ti) == 6) || (line(ti) == 7))
X tval++; /* reward on line 3, 4 */
X
X if (line(tj) > 7) /* penalty on line 1, 2 */
X tval--;
X else
X if ((line(tj) == 6) || (line(tj) == 7))
X tval++; /* reward on line 3, 4 */
X }
X if (tval > *val)
X {
X *val = tval;
X *i = ti;
X *j = tj;
X }
X }
X }
X if (*val > 0) /* pattern matched */
X return 1;
X else /* match failed */
X return 0;
X} /* end matchpat */
END_OF_FILE
if test 5175 -ne `wc -c <'matchpat.c'`; then
echo shar: \"'matchpat.c'\" unpacked with wrong size!
fi
# end of 'matchpat.c'
fi
if test -f 'patterns.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'patterns.c'\"
else
echo shar: Extracting \"'patterns.c'\" \(7461 characters\)
sed "s/^X//" >'patterns.c' <<'END_OF_FILE'
X/*
X GNU GO - the game of Go (Wei-Chi)
X Version 1.1 last revised 3-1-89
X Copyright (C) Free Software Foundation, Inc.
X written by Man L. Li
X modified by Wayne Iba
X documented by Bob Webber
X*/
X/*
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation - version 1.
X
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
XGNU General Public License in file COPYING for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XPlease report any bug/fix, modification, suggestion to
X
Xmail address: Man L. Li
X Dept. of Computer Science
X University of Houston
X 4800 Calhoun Road
X Houston, TX 77004
X
Xe-mail address: ma...@cs.uh.edu (Internet)
X cos...@uhvax1.bitnet (BITNET)
X 70070,404 (CompuServe)
X*/
X
X#define EMPTY 0
X#define PATNO 24
X
X/* pattern x, y coor and attribute */
X/* for each pattern coordinate 0,0 must have my piece */
X/* att = 0 - empty, 1 - your piece, 2 - my piece, 3 - my next move */
X/* 4 - empty on edge, 5 - your piece on edge, 6 - my piece on edge */
X/*
X struct patval {int x, y, att;};
X*/
X
X/* patn - patern */
X/* patlen - no. of pieces in pattern */
X/* trfno - no. of transformation to match pattern */
X/* 8 for normal pattern, 4 for symmetrical pattern */
X/* patwt - pattern value */
X/*
X struct pattern {
X struct patval patn[MAXPC];
X int patlen, trfno, patwt;
X };
X*/
X static struct pattern pat[PATNO] = {
X/*
X pattern 0: 232 connect if invaded
X 010
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, 3},
X {1, 1, 1},
X {2, 0, 2},
X {2, 1, EMPTY}}, 6, 4, 82},
X/*
X pattern 1: 230 connect if invaded
X 012
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, 3},
X {1, 1, 1},
X {2, 0, EMPTY},
X {2, 1, 2}}, 6, 8, 82},
X/*
X pattern 2: 212 try to attack
X 030
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, 1},
X {1, 1, 3},
X {2, 0, 2},
X {2, 1, EMPTY}}, 6, 4, 82},
X/*
X pattern 3: 2302 connect if invaded
X 0100
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, 3},
X {1, 1, 1},
X {2, 0, EMPTY},
X {2, 1, EMPTY},
X {3, 0, 2},
X {3, 1, EMPTY}},8, 8, 83},
X/*
X pattern 4: 20302 connect if invaded
X 00100
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, EMPTY},
X {1, 1, EMPTY},
X {2, 0, 3},
X {2, 1, 1},
X {3, 0, EMPTY},
X {3, 1, EMPTY},
X {4, 0, 2},
X {4, 1, EMPTY}}, 10, 4, 84},
X/*
X pattern 5: 203 form eye to protect
X 021
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, EMPTY},
X {1, 1, 2},
X {2, 0, 3},
X {2, 1, 1}}, 6, 8, 82},
X/*
X pattern 6: 202 form eye to protect
X 031
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, EMPTY},
X {1, 1, 3},
X {2, 0, 2},
X {2, 1, 1}}, 6, 8, 82},
X/*
X pattern 7: 230 connect if invaded
X 102
X*/
X {{{0, 0, 2},
X {0, 1, 1},
X {1, 0, 3},
X {1, 1, EMPTY},
X {2, 0, EMPTY},
X {2, 1, 2}}, 6, 8, 82},
X/*
X pattern 8: 200000
X 00030 extend
X 00000
X*/
X {{{0, 0, 2},
X {1, 0, EMPTY},
X {2, 0, EMPTY},
X {3, 0, EMPTY},
X {4, 0, EMPTY},
X {5, 0, EMPTY},
X {1, 1, EMPTY},
X {2, 1, EMPTY},
X {3, 1, EMPTY},
X {4, 1, 3},
X {5, 1, EMPTY},
X {1, 2, EMPTY},
X {2, 2, EMPTY},
X {3, 2, EMPTY},
X {4, 2, EMPTY},
X {5, 2, EMPTY}}, 16, 8, 80},
X/*
X pattern 9: 2
X 000
X 000 extend
X 000
X 030
X 000
X*/
X {{{ 0, 0, 2},
X {-1, 1, EMPTY},
X { 0, 1, EMPTY},
X { 1, 1, EMPTY},
X {-1, 2, EMPTY},
X { 0, 2, EMPTY},
X { 1, 2, EMPTY},
X {-1, 3, EMPTY},
X { 0, 3, EMPTY},
X { 1, 3, EMPTY},
X {-1, 4, EMPTY},
X { 0, 4, 3},
X { 1, 4, EMPTY},
X {-1, 5, EMPTY},
X { 0, 5, EMPTY},
X { 1, 5, EMPTY}}, 16, 4, 80},
X/*
X pattern 10: 20000
X 0030 extend
X 0000
X*/
X {{{0, 0, 2},
X {1, 0, EMPTY},
X {2, 0, EMPTY},
X {3, 0, EMPTY},
X {4, 0, EMPTY},
X {1, 1, EMPTY},
X {2, 1, EMPTY},
X {3, 1, 3},
X {4, 1, EMPTY},
X {1, 2, EMPTY},
X {2, 2, EMPTY},
X {3, 2, EMPTY},
X {4, 2, EMPTY}}, 13, 8, 79},
X/*
X pattern 11: 2
X 000
X 000 extend
X 030
X 000
X*/
X {{{ 0, 0, 2},
X {-1, 1, EMPTY},
X { 0, 1, EMPTY},
X { 1, 1, EMPTY},
X {-1, 2, EMPTY},
X { 0, 2, EMPTY},
X { 1, 2, EMPTY},
X {-1, 3, EMPTY},
X { 0, 3, 3},
X { 1, 3, EMPTY},
X {-1, 4, EMPTY},
X { 0, 4, EMPTY},
X { 1, 4, EMPTY}}, 13, 4, 79},
X/*
X pattern 12: 2000
X 030 extend
X 000
X*/
X {{{0, 0, 2},
X {1, 0, EMPTY},
X {2, 0, EMPTY},
X {3, 0, EMPTY},
X {1, 1, EMPTY},
X {2, 1, 3},
X {3, 1, EMPTY},
X {1, 2, EMPTY},
X {2, 2, EMPTY},
X {3, 2, EMPTY}}, 10, 8, 76},
X/*
X pattern 13: 2
X 000 extend
X 030
X 000
X*/
X {{{ 0, 0, 2},
X {-1, 1, EMPTY},
X { 0, 1, EMPTY},
X { 1, 1, EMPTY},
X {-1, 2, EMPTY},
X { 0, 2, 3},
X { 1, 2, EMPTY},
X {-1, 3, EMPTY},
X { 0, 3, EMPTY},
X { 1, 3, EMPTY}}, 10, 4, 76},
X/*
X pattern 14: 643 form eye on the edge
X 20
X*/
X {{{0, 0, 6},
X {1, 0, 4},
X {1, 1, 2},
X {2, 0, 3},
X {2, 1, EMPTY}}, 5, 8, 80},
X/*
X pattern 15: 646 solidify eye on the edge
X 231
X*/
X {{{0, 0, 6},
X {1, 0, 4},
X {1, 1, 2},
X {2, 0, 6},
X {2, 1, 3},
X {3, 1, 1}}, 6, 8, 75},
X/*
X pattern 16: 646 solidify eye on the edge
X 230
X 1
X*/
X {{{0, 0, 6},
X {1, 0, 4},
X {1, 1, 2},
X {2, 0, 6},
X {2, 1, 3},
X {2, 2, 1},
X {3, 1, EMPTY}}, 7, 8, 75},
X/*
X pattern 17: 646 solidify eye on the edge
X 230
X 0
X*/
X {{{0, 0, 6},
X {1, 0, 4},
X {1, 1, 2},
X {2, 0, 6},
X {2, 1, 3},
X {2, 2, EMPTY},
X {3, 1, EMPTY}}, 7, 8, 75},
X/*
X pattern 18: 2 form eye on center
X 202
X 3
X*/
X {{{0, 0, 2},
X {-1, 1, 2},
X {0, 1, EMPTY},
X {1, 1, 2},
X {0, 2, 3}}, 5, 4, 80},
X/*
X pattern 19: 2 solidify eye on center
X 202
X 231
X*/
X {{{0, 0, 2},
X {-1, 1, 2},
X {0, 1, EMPTY},
X {1, 1, 2},
X {0, 2, 2},
X {1, 2, 3},
X {2, 2, 1}}, 7, 8, 75},
X/*
X pattern 20: 2 solidify eye on center
X 202
X 230
X 0
X*/
X {{{0, 0, 2},
X {-1, 1, 2},
X {0, 1, EMPTY},
X {1, 1, 2},
X {0, 2, 2},
X {1, 2, 3},
X {2, 2, EMPTY},
X {1, 3, EMPTY}}, 8, 8, 75},
X/*
X pattern 21: 2 solidify eye on center
X 202
X 230
X 1
X*/
X {{{0, 0, 2},
X {-1, 1, 2},
X {0, 1, EMPTY},
X {1, 1, 2},
X {0, 2, 2},
X {1, 2, 3},
X {2, 2, EMPTY},
X {1, 3, 1}}, 8, 8, 75},
X/*
X pattern 23: 20100 connect if invaded
X 00302
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, EMPTY},
X {1, 1, EMPTY},
X {2, 0, 1},
X {2, 1, 3},
X {3, 0, EMPTY},
X {3, 1, EMPTY},
X {4, 0, EMPTY},
X {4, 1, 2}}, 10, 8, 84},
X/*
X pattern 24: 2100 connect if invaded
X 0302
X*/
X {{{0, 0, 2},
X {0, 1, EMPTY},
X {1, 0, 1},
X {1, 1, 3},
X {2, 0, EMPTY},
X {2, 1, EMPTY},
X {3, 0, EMPTY},
X {3, 1, 2}}, 10, 8, 83}
X };
X/* end patterns */
END_OF_FILE
if test 7461 -ne `wc -c <'patterns.c'`; then
echo shar: \"'patterns.c'\" unpacked with wrong size!
fi
# end of 'patterns.c'
fi
if test -f 'showbord.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'showbord.c'\"
else
echo shar: Extracting \"'showbord.c'\" \(6315 characters\)
sed "s/^X//" >'showbord.c' <<'END_OF_FILE'
X/*
X GNU GO - the game of Go (Wei-Chi)
X Version 1.1 last revised 3-1-89
X Copyright (C) Free Software Foundation, Inc.
X written by Man L. Li
X modified by Wayne Iba
X documented by Bob Webber
X*/
X/*
XThis program is free software; you can redistribute it and/or modify
Xit under the terms of the GNU General Public License as published by
Xthe Free Software Foundation - version 1.
X
XThis program is distributed in the hope that it will be useful,
Xbut WITHOUT ANY WARRANTY; without even the implied warranty of
XMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
XGNU General Public License in file COPYING for more details.
X
XYou should have received a copy of the GNU General Public License
Xalong with this program; if not, write to the Free Software
XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XPlease report any bug/fix, modification, suggestion to
X
Xmail address: Man L. Li
X Dept. of Computer Science
X University of Houston
X 4800 Calhoun Road
X Houston, TX 77004
X
Xe-mail address: ma...@cs.uh.edu (Internet)
X cos...@uhvax1.bitnet (BITNET)
X 70070,404 (CompuServe)
X*/
X
X#include <stdio.h>
X
X#define EMPTY 0
X#define WHITE 1
X
Xextern unsigned char p[19][19];
Xextern int mymove, umove;
Xextern int mk, uk; /* piece captured */
X
Xshowboard()
X/* show go board */
X {
X int i, j, ii;
X
X/* p = 0 for empty ,p = 1 for white piece, p = 2 for black piece */
X printf(" A B C D E F G H J K L M N O P Q R S T\n");
X/* row 19 to 17 */
X for (i = 0; i < 3; i++)
X {
X ii = 19 - i;
X printf("%2d",ii);
X
X for (j = 0; j < 19; j++)
X if (p[i][j] == EMPTY)
X printf(" -");
X else if (p[i][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf("%2d",ii);
X printf("\n");
X }
X/* row 16 */
X printf("16");
X
X for (j = 0; j < 3; j++)
X if (p[3][j] == EMPTY)
X printf(" -");
X else if (p[3][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[3][3] == 0)
X printf(" +");
X else if (p[3][3] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 4; j < 9; j++)
X if (p[3][j] == EMPTY)
X printf(" -");
X else if (p[3][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[3][9] == EMPTY)
X printf(" +");
X else if (p[3][9] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 10; j < 15; j++)
X if (p[3][j] == EMPTY)
X printf(" -");
X else if (p[3][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[3][15] == EMPTY)
X printf(" +");
X else if (p[3][15] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 16; j < 19; j++)
X if (p[3][j] == EMPTY)
X printf(" -");
X else if (p[3][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf("16");
X if (umove == 1)
X printf(" Your color: White O\n");
X else
X if (umove == 2)
X printf(" Your color: Black X\n");
X else
X printf("\n");
X/* row 15 to 11 */
X for (i = 4; i < 9; i++)
X {
X ii = 19 - i;
X printf("%2d",ii);
X
X for (j = 0; j < 19; j++)
X if (p[i][j] == EMPTY)
X printf(" -");
X else if (p[i][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf("%2d",ii);
X if (i == 4)
X {
X if (mymove == 1)
X printf(" My color: White O\n");
X else
X if (mymove == 2)
X printf(" My color: Black X\n");
X else
X printf("\n");
X }
X else
X if (i != 8)
X printf("\n");
X else
X printf(" You have captured %d pieces\n", mk);
X }
X/* row 10 */
X printf("10");
X
X for (j = 0; j < 3; j++)
X if (p[9][j] == EMPTY)
X printf(" -");
X else if (p[9][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[9][3] == EMPTY)
X printf(" +");
X else if (p[9][3] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 4; j < 9; j++)
X if (p[9][j] == EMPTY)
X printf(" -");
X else if (p[9][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[9][9] == EMPTY)
X printf(" +");
X else if (p[9][9] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 10; j < 15; j++)
X if (p[9][j] == EMPTY)
X printf(" -");
X else if (p[9][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[9][15] == EMPTY)
X printf(" +");
X else if (p[9][15] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 16; j < 19; j++)
X if (p[9][j] == EMPTY)
X printf(" -");
X else if (p[9][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf("10");
X printf(" I have captured %d pieces\n", uk);
X/* row 9 to 5 */
X for (i = 10; i < 15; i++)
X {
X ii = 19 - i;
X printf("%2d",ii);
X
X for (j = 0; j < 19; j++)
X if (p[i][j] == EMPTY)
X printf(" -");
X else if (p[i][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf("%2d",ii);
X printf("\n");
X }
X/* row 4 */
X printf(" 4");
X
X for (j = 0; j < 3; j++)
X if (p[15][j] == EMPTY)
X printf(" -");
X else if (p[15][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[15][3] == EMPTY)
X printf(" +");
X else if (p[15][3] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 4; j < 9; j++)
X if (p[15][j] == EMPTY)
X printf(" -");
X else if (p[15][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[15][9] == EMPTY)
X printf(" +");
X else if (p[15][9] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 10; j < 15; j++)
X if (p[15][j] == EMPTY)
X printf(" -");
X else if (p[15][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X if (p[15][15] == EMPTY)
X printf(" +");
X else if (p[15][15] == WHITE)
X printf(" O");
X else printf(" X");
X
X for (j = 16; j < 19; j++)
X if (p[15][j] == EMPTY)
X printf(" -");
X else if (p[15][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf(" 4");
X printf("\n");
X/* row 3 to 1 */
X for (i = 16; i < 19; i++)
X {
X ii = 19 - i;
X printf("%2d",ii);
X
X for (j = 0; j < 19; j++)
X if (p[i][j] == EMPTY)
X printf(" -");
X else if (p[i][j] == WHITE)
X printf(" O");
X else printf(" X");
X
X printf("%2d",ii);
X printf("\n");
X }
X printf(" A B C D E F G H J K L M N O P Q R S T\n\n");
X } /* end showboard */
END_OF_FILE
if test 6315 -ne `wc -c <'showbord.c'`; then
echo shar: \"'showbord.c'\" unpacked with wrong size!
fi
# end of 'showbord.c'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 3 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

Reply all
Reply to author
Forward
0 new messages