home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-20 | 76.9 KB | 2,723 lines |
-
- # This is a shell archive. Remove anything before this line,
- # then unpack it by saving it in a file and typing "sh file".
- #
- # Wrapped by Achim Flammenkamp <achim@dozy> on Tue Mar 16 17:41:45 1993
- #
- # This archive contains:
- # layout
- #
-
- LANG=""; export LANG
- PATH=/bin:/usr/bin:$PATH; export PATH
-
- echo mkdir - layout
- mkdir layout
-
- echo x - layout/dia.doc
- cat >layout/dia.doc <<'@EOF'
- A D O C U M E N T I O N
-
- of the User Functions in
-
- d i a g r a m . p s
-
- Version 3.8
-
-
- General:
- For PS novices: PostScript is a programming language from Adobe Inc.
- for high quality graphic output. It is stack orientated. Therefore
- arguments must prelead a function call. The symbol % ever starts a
- comment until the actual line ends. All tokens need only separated by
- at least one white space character (blank, tab, CRLF).
- The Fonts are extended that you can use accented letters in strings.
- Look up their octal coding in /accentvec ; e. g. (pla\356t \314 homme).
- You can not only print a single game record, but also form your own
- layout of go diagrams. The default papersize is assumed to be DIN A4.
-
- User Layout Functions:
-
- Pagelength
- val Pagelength --- set the pagelength to val inches
- Pagewidth
- val Pagewidth --- set the pagewidth to val inches
- Scale
- val Scale --- set the global scale factor of the graphic to val
- Yoff
- val Yoff --- increase the global top margin by val pts (1/72 inch)
- the real margin depends on scale factor
- Xoff
- val Xoff --- increase the global left margin by val pts (1/72 inch)
- the real margin depends on scale factor
- TopMargin
- val TopMargin --- set the global top margin to val inches
- the real top margin is independent of the scale factor
- BottomMargin
- val BottomMargin --- set the global bottom margin to val inches. the
- real bottom margin is independent of the scale factor
- Size
- n1 Size --- set the size of the board to n1 (1 <= n1 <= 25)
- (default: 19). Also usefull to change the columnwidth,
- which is as large as the boardsize times 1/4 inch.
- SetColumn
- n1 SetColumn --- set the number of columns per page to n1 (>= 1), but
- do not check whether the pagewidth is large enough
- or the actual scale factor and the colwidth are ok
- SetColumns
- n1 lm rm ic SetColumns --- set the number of columns per page to n1.
- Computes a new scale factor depending of the
- pagewidth, the inter columns space, ic, the
- left margin, lm, the right margin, rm, and
- the size of the board. Therefore this command
- should be given after that is correct set. The
- values of lm, rm and ic are interpretated as
- inches. Also Xoff is fitted to ensure a left
- margin of lm inches. The value ic will be
- ignored if n1 equals 1 but must be given.
-
- Initialize
- Initialize --- must ALWAYS prelude the sequence of PS commands,
- EXECPT the x-y-sizing macros must be in front of it.
- These are: Pagelength, Pagewidth, Xoff, Yoff, Scale,
- TopMargin, BottomMargin, Size, SetColumn,
- SetColumns
-
- User Game Functions:
-
- Heading
- n1 val flag --- centers the heading above the next n1 ( > 0 ) columns
- set the scaling factor of the head to val ( >= 0 )
- flag indicates whether the space of the headmargin
- should be reserved on the next pages. ATTENTION:
- multiple game records must be separated by this command
- Title
- (string) Title --- print title (string) in the heading
- BPlayer
- (string) BPlayer --- print name (string) of black player in heading
- WPlayer
- (string) WPlayer --- print name (string) of white player in heading
- Info
- (string) Info --- print information (string) in heading
- SetCaption
- SetCaption --- toggles the caption of the board (default: off)
- Movelines
- n1 Movelines --- set the number of reserved lines to n1 (n1 >= 0)
- These will automatic generated with DrawBoard and
- DrawPart below the board to show moves on occupied
- positions (default: 1)
-
- DrawBoard
- (string) DrawBoard --- draw a size times size goboard with subscrip-
- tion (string) . Attention will overlap the caption
-
- StartGame
- StartGame --- begin to input game data. Must be given exact onetime
- for each game record (clears internal move counter)
- Given in front of DrawBoard will garanty an empty board
- (useful trick to show different games on a page)
- Com
- (string) Com --- print comment (string) below the board
- Newline
- Newline --- break line (maybe page) in comment text
- W
- n1 n2 (n3) W --- put a white stone at coordinate n1 n2,
- and set mark with (n3). () gives no mark.
- 1 <= n1 <= boardsize, 1<= n2 <= boardsize,
- n3 can be any character or string.
- B
- n1 n2 (n3) B --- same as W, but for black stone
- E
- n1 n2 (n3) E --- set a black marker at coordinate n1 n2.
- 1 <= n1 <= boardsize, 1<= n2 <= boardsize,
- selects white background.
- EB
- n1 n2 (n3) EB --- same as E, but select no background.
- EW
- n1 n2 (n3) EW --- same as EB, but set white marker
- SetC
- n1 SetC --- set move counter to n1 (n1 must be an integer)
- WC
- n1 n2 WC --- put a white stone at coordinate n1 n2, and increase
- counter. if counter > 0 then set mark 'counter'.
- 1 <= n1 <= boardsize, 1<= n2 <= boardsize,
- BC
- n1 n2 BC --- put a black stone at coordinate n1 n2, and increase
- counter. if counter > 0 then set mark 'counter'.
- 1 <= n1 <= boardsize, 1<= n2 <= boardsize,
- WCMP
- n1 n2 (n3) WCMP --- put a white stone at coordinates n1 n2, but draw
- it with mark 'counter' below the board and draw
- the (n3) string beside this move in the reserved
- lines. Equivalent to n1 n2 Ko WC At (n3) E
- BCMP
- n1 n2 (n3) BCMP --- put a black stone at coordinates n1 n2, but draw
- it with mark 'counter' below the board and draw
- the (n3) string beside this move in the reserved
- lines. Equivalent to n1 n2 Ko BC At (n3) E
- Ko
- n1 n2 Ko --- there is a move at coordinates n1 n2 , but it
- will be drawn below the board in the reserved lines
- n1 n2 Ko (n3) W --- draws W stone with mark n3 below the board
- n1 n2 Ko (n3) B --- draws B stone with mark n3 below the board
- n1 n2 Ko WC --- draws W stone with mark 'counter' below the board
- n1 n2 Ko BC --- draws B stone with mark 'counter' below the board
- At
- At (n3) E --- draws mark (n3) below the ko stone in the reserved lines
- only sensible after a Ko command. Two examples:
- n1 n2 Ko WC At (pass) E , n1 n2 Ko (n3) B At (A) E
- WM
- WM --- white move in comment with referrence to last move
- BM
- BM --- black move in comment with referrence to last move
- WS
- WS --- white stone symbol in comment. Should be replaced by the
- special character \374 in comment
- BS
- BS --- black stone symbol in comment. Should be replaced by the
- special chararcter \375 in comment
- CBS
- CBS --- shortened form of Com BS
- CWS
- CWS --- shortened form of Com WS
- PageBreak
- PageBreak --- starts a new page and can redraw the board
- R
- n1 n2 R --- remove stone at coordinates n1 n2
- 1 <= n1 <= boardsize, 1<= n2 <= boardsize
- the result will be visulable on the next page only
- ColBreak
- ColBreak --- explicit column break
- SetView
- SetView --- set the singlemove view mode
- SetCharC
- n1 SetCharC --- set the max. number of characters per marker to n1
- will be used in calculating the size of StoneFont
- ToggleRedraw
- ToggleRedraw --- toggles the automatic redrawing of the board at
- PageBreak (default is redrawing on)
- Togglehead
- ToggleHead --- toggles the common headmargin (default is head margin
- of first heading in opposite to no head margin)
- DrawPart
- n1 n2 m (cap) DrawPart --- draws a n1 times n2 part of a go board
- with margins indicated in m and caption (cap)
- m (< 16) is interpreted as 4digit binary number;
- each binary digit, if it is 1, indicates a margin
- to draw. the digits are numbered from lower- to
- highervalued ones:
- the 1. digit represents the left margin
- the 2. digit represents the right margin
- the 3. digit represents the lower margin
- the 4. digit represents the upper margin
- SetCoord
- n1 n2 SetCoord --- set the xshift n1 and yshift n2 to be subtracted
- from all move coordinates. this defines virtually
- the offset of the lower left corner of the board
- showpage
- showpage --- prints the (last) page. Should be the final PS command
-
-
- Please, send any bug reprorts, comments or suggestions for improvements to
-
- achim@unibi.hrz.uni-bielefeld.de
-
- Bielefeld, August 11 1992
- @EOF
-
- chmod 644 layout/dia.doc
-
- echo x - layout/README
- sed 's/^@//' >layout/README <<'@EOF'
- To compile this program, type
- cc -o smart2ps smart2ps.c
-
- Use smart2ps to generate the postscript for a SGF file like
- cp diagram.ps file.ps ; smart2ps <file.mgt >>file.ps
-
-
- @From: Achim Flammenkamp <achim@unibi.hrz.uni-bielefeld.de>
-
-
- A D O C U M E N T A T I O N summary to s m a r t 2 p s (version 3.6)
-
-
- SGF means smart go format and PS means PostScript in the following context.
-
- 'smart2ps' converts many SGF files into PS format. It's not a perfect converter
- but I hope it is practical. You can easly extend or change it if you under-
- stand C programming.
- With some commandline options you can variate the layout of its PS-output.
-
- They are:
-
- # any natural number # sets the default pagebreak of the PS code every #
- moves at least. E.g. to get (al least) every 50 moves a new sheet you must
- append 50 somewhere after your command 'smart2ps'. If there are enough
- comments to fill the page then there will be a pagebreak, too.
- -c this option toggles the suppression of comments during playing. Its
- default value doesn't suppress these comments to be printed in PS.
- -r tell the converter whether there are seperate ranking entries for the
- players to aspect. They will be collected and put together with the
- corresponding players' names into PS.
- -p without this option the converter doesn't check liberties of groups in go
- and generate no implicit R(EMOVE) PS-command. This means captured stones
- are visible on new sheets of the printing. With this option the converter
- checks the liberties of each move and generate corresponding R(EMOVE) PS-
- commands, if neccessary. An extension to SGF is the ChangeStone[xy][xy].
- entry with can occure and changes the positions [xy] where a stone is
- located (in Go it can only be changed to empty by capturing). If you
- convert e.g. ishi-std-format to SGF you will like this facility.
- -x mirrors all stones at the x-centerline of the board in comparision to
- their original positions (maybe wishful for some purpose).
- -y mirrors all stones at the y-centerline of the board in comparision to
- their original positions (maybe useful to convert IGS recorded go-games).
- -i ignores all Comment entries in SGF before the start of the match (would be
- placed above the board in PS format and would shift down the board repre-
- sentation.)
- -m toggles the prelude of comments by black and white stone symbols while
- playing. (If not set you will have difficulties probably to map the
- comments to played moves.)
- -s toggles the default caption of the board by numbers(y-axes) and letters
- (x-axes) to no caption.
- -v generates a PS-code easy to view with ghostscript or other PS-viewers.
- (Not recommended for printing because it will generate each move on a
- new page.)
- -dLIST generates after each move of the LIST a new diagram. LIST is a non
- empty, strict increasing list of natural numbers separated by commas.
- -l@ sets the language of key words to english (@=0), german (@=1), french
- (@=2), dutch (@=3). Further codes maybe defined in future releases.
- -k@ sets the number of 'Movelines' to @. These reserved lines below the
- diagram services to the ko moves and other multiple occupied points.
- -z toggles the move counter to zero for each new diagramm. Move numbers will
- start with 1 in each diagramm if this option is set. Defaultly it is off.
- -? will show you all legal options of this program and the actual version
- number and exits.
- -L# sets the pagelength to # inches (default 11.5)
- -W# sets the pagewidth to # inches (default 8.25)
- -S# sets the global scaling factor to # (default 1.0)
- -T# sets the topmargin to # inches
- -M# sets the leftmargin to # inches
- -R# sets the rightmargin to # inches
- -I# sets the inter column space to # inches (default is 0.5)
- -C@ sets the the number of columns (default 1) you want to have to @
- -B# sets the bottommargin to # inches
- -H# sets the scaling factor of the head to # (default 1.0)
- -h toggles the reservation of space of the headmargin on next pages
- -J@ sets the head width to @ columns (default 1) including inter column space
-
-
-
- An unix-borne-shell script look is included to show the use of smart2ps
- and the PS-code in diagram.ps for easy interactive use. Probably you have
- to change the printer name inside look and perhaps the viewer 'gs'. Maybe
- you want to have different default options of smart2ps.
-
- Bielefeld, Germany, March 16th 1993
-
- @EOF
-
- chmod 644 layout/README
-
- echo x - layout/diagram.ps
- cat >layout/diagram.ps <<'@EOF'
- %!PS-Adobe-2.0
- % ******* WeiQi.PS ******* 3.8 ***
- % A PostScript Program for Drawing Go game.
- %
- % Achim Flammenkamp, Wed Dec 19 18:30 MET 1992
- % Youyi Chen, Wed Aug 8 15:41:30 EDT 1990
- %
- % Achim Flammenkamp achim@hrz.uni-bielefeld.de
- % Department of Mathematics
- % University of Bielefeld
- % 4800 Bielefeld 1
- % Germany
- %
- % Youyi Chen yychen@watdragon.uwaterloo.ca
- % Department of Statistics and Actuarial Science
- % University of Waterloo
- % Waterloo, Ontario
- % Canada, N2L 3G1
- %
- %
- % General:
- % Two sample problems are supplied with this program. Append one
- % of the examples and send all directly to a Postscript printer,
- % you will get a very interesting ancient Chinese WeiQi life and
- % death problem drawn by PostScript.
- %
- % At the bottom of this file different layouts are presented.
- % Select one of them or creat one of your own if you like.
- % If you want to print your own games, you only need to edit
- % the example data, title, comments using the same format.
- %
- %
- % CopyLeft:
- % You are free to use and distribute it non commercial.
- % Please send me your suggestions, comments and bug reports.
- %
- % PostScript is a trademark of Adobe Systems, Incorporated.
-
- % -------- global variables and procedures --------
- /boardsize 19 1 sub def % default size of board - 1
- /unitlength 18 def % unit length = 1/4 inch = 18/72 inch
- /unit { unitlength mul } bind def
- /inch { unitlength mul 4 mul } bind def
- /pagelength 11.7 inch def % DIN A4 format % 2^(-1.75) m
- /pagewidth 8.25 inch def % DIN A4 format % 2^(-2.25) m
- %remember: 1'' = 25.4mm = 0.0254 meter 1 meter ~ 39.37 inch
- % area of a DIN An sheet = 1/2^n m^2 , n ranges from 0, 1, 2, 3, ...
- % ratio of length to width of a DIN An sheey = sqrt(2) : 1
- % => divide a DIN An sheet in 2 DIN A(n+1) sheets by a horizontal central cut
- /xoff 6 unit def % default x_offset
- /yoff 14 unit def % default y_offset
- /factor 1.0 def % default scale
- /ystart 24 unit def % historical set to 24 units artifically :-)
- /bottommargin 1 unit def % fine adjust to stay on the page
- /colwidth boardsize unit def % default colwidth
- /linewidth 0.5 def % board grid linewidth
- /lineheight 1.0 def % default linefeed
- /digits 3 def % maximum number of character of marks
- /counter 0 def % user move counter
- /caption 0 def % default no board caption
- /kolines 1 def % default one reserved line
- /autoredraw 1 def % default board redrawing on
- /markmode 0 def % default marker is black on white background
- /singlemove 0 def % default viewing off
- /pagec 1 def % pagecounter
- /MoveC -1 def % internal move counter
- /columns 1 def % default only one column per page
- /intercolumns 2 unit def % space between columns
- /heading -1.0 def % default heading space must be negativ
- /headwidth boardsize unit def % default headwidth
- /headmargin 1 def % default one main heading of multiple columns or pages
- /xshift 0 def % default no x shift of move coordinates
- /yshift 0 def % default no y shift of move coordinates
- /kostr1 (Move) def % (Zug) () (Zet) % caption is language dependend
- /kostr2 ( at) def % (auf) () ( op) % englisch, german, french, dutch, ...
- /koxstart 1.9 def % x start position of reserved lines
- /koxincr 1.2 def
- /koystart -0.8 def % y start position of reserved lines
- /comyincr 0.9 def
-
- /ErrorMsg { % stack: (msg)
- showpage
- /Times-Roman findfont 20 scalefont setfont
- 0 100 moveto 0 setgray show
- showpage
- stop
- } bind def
-
- /Pagewidth { % stack: n1
- dup 0 le
- { pop (pagewidth must be positiv) ErrorMsg } if
- inch /pagewidth exch def } bind def
- /Pagelength { % stack: n1
- dup 0 le
- { pop (pagelength must be positiv) ErrorMsg } if
- inch /pagelength exch def } bind def
- /Xoff { % stack: n1
- xoff add /xoff exch def } bind def
- /Yoff { % stack: n1
- neg yoff add /yoff exch def } bind def
- /Scale { % stack: n1
- dup 0.0 gt
- { /factor exch def }
- { pop (scale factor must be positiv) ErrorMsg } ifelse
- } bind def
-
- /TopMargin { % stack: n1
- inch /topmargin exch def
- % /yoff pagelength bottommargin sub topmargin sub factor ystart mul sub def
- } bind def
-
- /BottomMargin { % stack: n1
- inch /bottommargin exch def
- } bind def
-
- /Size { % stack: n1
- dup dup floor ne { pop (size must be an integer) ErrorMsg } if
- dup 1 gt
- { 1 sub dup /boardsize exch def % new board size
- unit dup /headwidth exch def % new head width
- dup colwidth div /relf exch def % relative factor
- /colwidth exch def % new column width
- userdict /rightmargin known % if SetColumns used :
- { 1.0 relf div
- userdict /LM known { dup dup scale } if
- userdict /RM known { /RM LM colwidth add def } if
- factor mul /factor exch def
- intercolumns relf mul /intercolumns exch def
- } if
- userdict /topmargin known % if TopMargin used :
- { /yoff pagelength bottommargin sub topmargin sub
- factor ystart mul sub def
- } if
- userdict /Bottom known % if Bottom used :
- { Bottom relf mul /Bottom exch def } if
- heading relf mul /heading exch def
- userdict /headcol known % if Heading used :
- { headcol dup colwidth mul exch 1 sub intercolumns mul add
- /headwidth exch def
- } if
- }
- { pop (size must be greater 1) ErrorMsg } ifelse
- } bind def
-
- /SetColumn { % stack: n1
- dup 1 ge
- { /columns exch def }
- { pop (columns must be greater 0) ErrorMsg } ifelse
- } bind def
-
- /SetColumns { % stack: n1 n2 n3 n4
- inch /intercolumns exch def
- inch /rightmargin exch def
- inch /leftmargin exch def
- dup 1 ge
- { /columns exch def
- /factor pagewidth leftmargin sub rightmargin sub
- columns 1 sub intercolumns mul sub columns colwidth mul
- div def
- factor 0 le { (page to small for margins) ErrorMsg } if
- /xoff leftmargin def
- /intercolumns intercolumns factor div def
- } { pop (columns must be greater 0) ErrorMsg } ifelse
- } bind def
-
- /Initialize {
- 0 bottommargin translate % bottom margin
- userdict /topmargin known
- { /yoff pagelength bottommargin sub topmargin sub
- factor ystart mul sub def
- } if % calculate yoff if topmargin is given
- xoff yoff translate % move the origin
- factor factor scale % set global scale
- yoff factor div /Bottom exch neg def
- /LM 0 def % left margin for board and comments
- /RM LM colwidth add def % right margin for comments
- /ypos ystart def % y start
- } bind def
-
- /TitleFont {
- /Times-Bold-Accent findfont
- 25 lineheight mul scalefont setfont
- } def
-
- /PlayerFont {
- /Times-Bold-Accent findfont
- 18 lineheight mul scalefont setfont
- } def
-
- /DescriFont {
- /Times-Roman-Symbol findfont
- 15 lineheight mul scalefont setfont
- } def
-
- /sfs % stone font size
- 1.8 digits 1 add div 0.1 add unit ceiling def
-
- /StoneFont {
- /Helvetica-Bold-Accent findfont
- sfs scalefont
- setfont
- } def
-
- /CommentFont {
- /Times-Italic-Symbol findfont
- sfs scalefont setfont
- } def
-
- /Title { % stack: (title)
- TitleFont
- dup stringwidth pop
- headwidth sub -0.5 mul LM add
- ypos moveto show
- /ypos ypos lineheight unit 1.2 mul sub def
- } def
-
- /BPlayer { % stack: (bplayer)
- PlayerFont
- /Radius lineheight 0.4 mul def
- dup stringwidth pop
- headwidth sub -0.5 mul Radius unit add LM add
- /xpos exch def xpos
- ypos moveto show
- 1 setgray stroke
- xpos Radius unit 1.5 mul sub ypos Radius unit 0.7 mul add
- Radius unit 0 360 arc 0 setgray fill
- /ypos ypos lineheight unit sub def
- } def
-
- /WPlayer { % stack: (wplayer)
- PlayerFont
- /Radius lineheight 0.4 mul def
- dup stringwidth pop
- headwidth sub -0.5 mul Radius unit add LM add
- /xpos exch def xpos
- ypos moveto show
- 0 setgray stroke
- xpos Radius unit 1.5 mul sub ypos Radius unit 0.7 mul add
- Radius unit 0 360 arc
- gsave 1 setgray fill grestore 0 setgray stroke
- /ypos ypos lineheight unit sub def
- } def
-
- /Info { % stack: (info)
- DescriFont
- dup stringwidth pop
- headwidth sub -0.5 mul LM add
- ypos moveto show
- /ypos ypos lineheight unit sub def
- } def
-
- /StoneRadius { unitlength 2.1 div } bind def % stone radius
-
- /W { % stack: x y (s)
- /str exch def % draw a white stone at x y with mark s at center
- /my exch yshift sub def
- /mx exch xshift sub def
- kowhite 0 eq
- { my 1 ge my boardsize 1 add le and
- { Moves MoveC [ mx my /WC ] put
- /MoveC MoveC 1 add def
- } if
- }
- { /kowhite 0 def
- } ifelse
- mx my
- unit 1 unit sub /cy exch def
- unit 1 unit sub /cx exch def
- newpath
- cx cy StoneRadius 0 360 arc
- gsave 1 setgray fill grestore 0 setgray stroke
- /xp { cx str stringwidth pop 0.5 mul sub } bind def
- /yp { cy sfs 0.325 mul sub} bind def
- xp yp moveto str show
- singlemove 0 ne
- { copypage } if
- } bind def
-
- /B { % stack: x y (s)
- /str exch def % draw a black stone at x y with mark s at center
- /my exch yshift sub def
- /mx exch xshift sub def
- kowhite 0 eq
- { my 1 ge my boardsize 1 add le and
- { Moves MoveC [ mx my /BC ] put
- /MoveC MoveC 1 add def
- } if
- }
- { /kowhite 0 def
- /ar Moves MoveC 1 sub get def
- ar 2 /BC put
- Moves MoveC 1 sub ar put
- } ifelse
- mx my
- unit 1 unit sub /cy exch def
- unit 1 unit sub /cx exch def
- newpath
- cx cy StoneRadius 0 360 arc
- 0 setgray fill
- /xp { cx str stringwidth pop 0.5 mul sub } bind def
- /yp { cy sfs 0.325 mul sub} bind def
- 1 setgray xp yp moveto
- str show
- singlemove 0 ne
- { copypage } if
- } bind def
-
- /Mark { % stack: x y (s)
- /str exch def % draw a mark s centered at x y
- yshift sub 1 sub unit /cy exch def
- xshift sub 1 sub unit /cx exch def
- singlemove 0 eq
- { markmode 0 eq
- { newpath 1 setgray cx cy
- StoneRadius 0.8 mul 0 360 arc fill stroke } if
- /xp { cx str stringwidth pop 0.5 mul sub } bind def
- /yp { cy sfs 0.325 mul sub} bind def
- markmode 2 ne
- { 0 setgray } { 1 setgray } ifelse
- xp yp moveto str show
- } if
- } bind def
-
- /E { /markmode 0 def Mark } bind def
- /EB { /markmode 1 def Mark } bind def
- /EW { /markmode 2 def Mark } bind def
-
- /mr {unitlength 7 div} bind def % radius of mark circle
- /SetMark % stack: x y
- { mr 0 360 arc fill } bind def % set mark at 9 special points
-
- /DrawGrid {
- 0 setgray
- linewidth setlinewidth
- % vertical lines
- newpath
- 0 1 unit boardsize unit
- { 0 moveto 0 boardsize unit rlineto } for stroke
- % horizontal lines
- newpath
- 0 1 unit boardsize unit
- { 0 exch moveto boardsize unit 0 rlineto } for stroke
- % margin lines
- linewidth 3 mul setlinewidth
- newpath
- 0 0 moveto 0 boardsize unit lineto
- boardsize unit boardsize unit lineto
- boardsize unit 0 lineto 0 0 lineto
- closepath stroke
- linewidth setlinewidth
- % mark handicap points
- boardsize 7 ge
- { /hpos boardsize 11 ge { 3 } { 2 } ifelse def
- boardsize 2 mod 0 eq
- { /hstep boardsize 2 div hpos sub def }
- { /hstep boardsize hpos sub hpos sub def } ifelse
- hpos hstep boardsize hpos sub
- { unit hpos unit SetMark } for % set marks
- boardsize 2 mod 0 eq
- { hpos hstep boardsize hpos sub
- { unit boardsize 2 div unit SetMark} for
- } if
- hpos hstep boardsize hpos sub
- { unit boardsize hpos sub unit SetMark} for
- } if
- } bind def
-
- /DrawCaption {
- StoneFont
- caption 0 ne
- { 0 1 boardsize
- { dup dup 9 ge
- { (1) stringwidth pop neg -1 unit add }
- { -1 unit } ifelse
- exch unit
- sfs 0.325 mul sub moveto
- 1 add /mark 2 string def
- mark cvs show
- } for
- 0 1 boardsize
- { dup unit (I) stringwidth pop 0.5 mul sub
- -1 unit moveto
- 65 add % assume Ascii coding
- dup 72 gt {1 add} if
- /mark 1 string def
- mark 0 3 -1 roll put mark show
- } for
- } if
- } def
-
- /StartComment { } def % upward compatiable (will be ommitted later)
-
- /StartCom {
- /RM LM colwidth add def % right margin for comments
- /lineheight comyincr unit def % distance between lines of text
- /ypos -2 unit def % board lowleft y margin
- /xpos LM def
- singlemove 0 eq
- { CommentFont
- kolines -1 1
- { pop
- xpos ypos moveto
- kostr1 show
- /ypos ypos lineheight sub def
- xpos ypos moveto
- kostr2 show
- /ypos ypos lineheight sub def
- } for
- xpos ypos moveto
- kolines 0 gt { Newline } if
- } if
- /kowhite 0 def % flag for Ko
- /kox koxstart def
- /koy koystart def
- StoneFont
- } def
-
- /DrawBoard {
- /str exch def
- heading 0 lt
- { /heading ystart ypos sub def } if
- ypos boardsize 0.5 add unit sub
- kolines lineheight mul sub
- Bottom lt
- { ColBreak } if
- StoneFont
- LM ypos boardsize 0.5 add unit sub moveto
- currentpoint
- dup neg Bottom add /Bottom exch def
- translate % set actuell position to origon
- /LM 0 def % left margin
- DrawGrid
- DrawCaption
- % redraw old moves
- MoveC 0 gt
- { /scr counter def
- /counter -9999 def
- /xsh xshift def /xshift 0 def
- /ysh yshift def /yshift 0 def
- Moves
- { dup null eq {pop exit} if
- aload pop
- 3 1 roll dup 3 -1 roll dup 4 1 roll
- 0 gt exch 0 gt and
- { 3 -1 roll
- cvx exec
- } if
- } forall
- /counter scr def
- /xshift xsh def
- /yshift ysh def
- } if
- CommentFont
- % 0.5 unit setlinewidth
- str stringwidth pop
- boardsize unit sub -0.5 mul % dup
- % -1 unit sfs 0.33 mul add moveto 1 setgray strlen 0 rlineto stroke
- -1 unit moveto 0 setgray str show
- % linewidth setlinewidth
- StartCom % old StartComment must follow
- } def
-
- /StartGame % clears any previous stored moves
- { StoneFont
- /Moves boardsize 1 add dup mul 40 add % hope it's enough
- array def
- /MoveC 0 def
- } def
-
- % A text formater for printing comments
- /Newline { % moveto begin of next line
- /ypos ypos lineheight sub def
- /xpos LM def
- ypos Bottom lt
- { pagec columns mod 0 ne
- { /LM RM intercolumns add def % left margin for board and comments
- /xpos LM def
- /RM LM colwidth add def % right margin for comments
- /ypos yoff factor div Bottom add ystart add def % y start
- /pagec pagec 1 add def
- headmargin 0 ne
- { /ypos ypos heading sub def } if
- }
- { /oldfont currentfont def
- PageBreak
- oldfont setfont
- } ifelse
- } if
- xpos ypos moveto
- } def % move to next line
-
- /Com { % stack: str
- CommentFont
- xpos ypos moveto
- /str exch def
- str stringwidth pop
- xpos add /xpos exch def
- xpos RM le
- { 0 setgray str show StoneFont }
- { () str % partition of input string on stack
- str length -1 1
- { dup /index exch def 1 sub
- 1 getinterval dup stringwidth pop
- xpos sub neg /xpos exch def
- ( ) eq xpos RM le and
- { pop str 0 index getinterval
- str index str length index sub getinterval
- exit
- } if
- str
- } for
- exch dup () eq xpos LM le and
- { pop (word too long) ErrorMsg } if % error: word widther than column width
- 0 setgray show
- Newline
- Com % tail recursion
- } ifelse
- } def
-
- /Comment { Com } def % upward compatiable (will be ommitted later)
-
- /Ko {
- /my exch def
- /mx exch def
- Moves MoveC [ mx my /WC ] put
- MoveC 1 add /MoveC exch def
- /kowhite 1 def
- singlemove 0 ne
- { mx my }
- { kox koxincr add dup /kox exch def
- kox boardsize 1 add gt
- { /koy koy comyincr 2 mul sub def /kox koxstart koxincr add def } if
- kox xshift add
- koy yshift add
- } ifelse
- } bind def
-
- /At { kox xshift add koy yshift add comyincr sub } bind def
-
- /WCMP { % stack: x y (s)
- /scratch exch def
- Ko WC
- At scratch E } def
-
- /BCMP { % stack: x y (s)
- /scratch exch def
- Ko BC
- At scratch E } def
-
- /SetC { % stack: n1
- /counter exch def } bind def
-
- /SetCaption { /caption 1 caption sub def } bind def
-
- /SetCharC { % stack: n1
- /digits exch def
- 1.8 digits 1 add div 0.1 add unit ceiling
- /sfs exch def % stone font size
- } bind def
-
- /SetView { /singlemove 1 def } bind def
-
- /ToggleRedraw { /autoredraw 1 autoredraw sub def } bind def
-
- /Heading { %stack: n1 n2 n3
- dup dup 1 ne exch 0 ne and
- { pop pop pop (last parameter of Heading must be 0 or 1) ErrorMsg } if
- /headmargin exch def
- /lineheight exch def
- dup dup dup floor ne exch 1 lt or
- { pop (the head width must be positive and integral number) ErrorMsg } if
- dup /headcol exch def
- dup colwidth mul exch 1 sub intercolumns mul add /headwidth exch def
- 0 setgray
- } bind def
-
- /ToggleHead { /headmargin 1 headmargin sub def } bind def
-
- /SetHead { /lineheight exch def 0 setgray } bind def
-
- /Movelines { % stack : n1
- /kolines exch def } bind def
-
- /GetCounterAndPosition {
- /len 1 def
- counter 10 idiv
- 0 gt { /len len 1 add def } if
- counter 100 idiv
- 0 gt { /len len 1 add def } if
- counter 1000 idiv
- 0 gt { /len len 1 add def } if
- /no len string def
- counter no cvs
- /no exch def
- /xp { cx no stringwidth pop 0.5 mul sub } bind def
- /yp { cy sfs 0.325 mul sub} bind def
- xp yp moveto
- } bind def
-
- /WC { % stack: x y
- /my exch yshift sub def
- /mx exch xshift sub def
- counter -999 ge
- { kowhite 0 eq
- { my 1 ge my boardsize 1 add le and
- { Moves MoveC [ mx my /WC ] put
- /MoveC MoveC 1 add def
- } if
- }
- { /kowhite 0 def
- } ifelse
- } if
- mx my
- 1 sub unit /cy exch def
- 1 sub unit /cx exch def
- newpath
- cx cy StoneRadius 0 360 arc
- gsave 1 setgray fill grestore 0 setgray stroke
- /counter counter 1 add def
- counter 0 gt
- { GetCounterAndPosition
- no show
- singlemove 0 ne
- { copypage } if
- } if
- } bind def
-
- /BC { % stack: x y
- /my exch yshift sub def
- /mx exch xshift sub def
- counter -999 ge
- { kowhite 0 eq
- { my 1 ge my boardsize 1 add le and
- { Moves MoveC [ mx my /BC ] put
- /MoveC MoveC 1 add def
- } if
- }
- { /kowhite 0 def
- /ar Moves MoveC 1 sub get def
- ar 2 /BC put
- Moves MoveC 1 sub ar put
- } ifelse
- } if
- mx my
- 1 sub unit /cy exch def
- 1 sub unit /cx exch def
- newpath
- cx cy StoneRadius 0 360 arc
- 0 setgray fill
- /counter counter 1 add def
- counter 0 gt
- { GetCounterAndPosition
- 1 setgray
- no show
- singlemove 0 ne
- { copypage } if
- } if
- } bind def
-
- /WM {
- /cy ypos StoneRadius 0.35 mul add def
- /cx xpos StoneRadius 1.1 mul add def
- newpath
- cx cy StoneRadius 0 360 arc
- gsave 1 setgray fill grestore 0 setgray stroke
- /xpos xpos StoneRadius 2.5 mul add def
- counter 0 gt
- { GetCounterAndPosition
- no show
- } if
- } bind def
-
- /BM {
- /cy ypos StoneRadius 0.35 mul add def
- /cx xpos StoneRadius 1.1 mul add def
- newpath
- cx cy StoneRadius 0 360 arc
- 0 setgray fill
- /xpos xpos StoneRadius 2.5 mul add def
- counter 0 gt
- { GetCounterAndPosition
- 1 setgray
- no show
- } if
- } bind def
-
- /WS {
- /Radius StoneRadius 0.7 mul def
- /cy ypos Radius 0.4 mul add def
- /cx xpos Radius 1.1 mul add def
- newpath
- cx cy Radius 0 360 arc
- gsave 1 setgray fill grestore 0 setgray stroke
- /xpos xpos Radius 2.5 mul add def
- } bind def
-
- /BS {
- /Radius StoneRadius 0.7 mul def
- /cy ypos Radius 0.4 mul add def
- /cx xpos Radius 1.1 mul add def
- newpath
- cx cy Radius 0 360 arc
- 0 setgray fill
- /xpos xpos Radius 2.5 mul add def
- } bind def
-
- /CBS { Com BS } bind def % shortened form
- /CWS { Com WS } bind def % shortened form
-
- /PageBreak {
- showpage
- Initialize
- headmargin 0 ne
- { /ypos ypos heading sub def } if
- /pagec pagec 1 add def
- autoredraw 0 ne { () DrawBoard } if
- } def
-
- /ColBreak { /ypos Bottom def Newline } def
-
- /poppop { pop pop } bind def
-
- /R { % stack: x y % remove a stone at x y if possible
- /my exch def
- /mx exch def
- /ind 0 def
- Moves
- { dup null eq {pop exit} if
- aload pop
- /poppop ne exch my eq and exch mx eq and
- { Moves ind [ mx my /poppop ] put
- singlemove 0 ne
- { my 1 sub unit /cy exch def
- mx 1 sub unit /cx exch def
- /lx mx 1 gt { 0.5 } { 0.0 } ifelse def
- /ly my 1 gt { 0.5 } { 0.0 } ifelse def
- /rx mx boardsize le { 0.5 } { 0.0 } ifelse def
- /uy my boardsize le { 0.5 } { 0.0 } ifelse def
- newpath
- 1 setgray cx cy StoneRadius 0 360 arc fill stroke
- 0 setgray
- cx lx unit sub cy moveto lx rx add unit 0 rlineto stroke
- cx cy ly unit sub moveto 0 ly uy add unit rlineto stroke
- } if
- exit
- } if
- /ind ind 1 add def
- } forall
- } bind def
-
- /DrawPart { %stack: n1 n2 m (cap)
- /str exch def
- /marg exch 15 xor def
- /my exch 1 sub def
- /mx exch 1 sub def
- heading 0 lt
- { /heading ystart ypos sub def } if
- % mx 0 lt { return } if
- % my 0 lt { return } if
- ypos my 0.5 add unit sub
- Bottom lt
- { ColBreak } if
- /lx marg 1 and 0.5 mul def % left margin
- /rx marg 2 and 0.25 mul def % right margin
- /ly marg 4 and 0.125 mul def % lower margin
- /uy marg 8 and 0.0625 mul def % upper margin
- LM ypos my 0.5 add unit sub moveto
- currentpoint
- dup neg Bottom add /Bottom exch def
- translate % set actuell position to origon
- /LM 0 def % left margin
- 0 setgray
- linewidth setlinewidth
- newpath
- 0 1 unit mx unit
- { 0 ly sub unit moveto
- 0 my uy add ly add unit rlineto } for stroke
- newpath
- 0 1 unit my unit
- { 0 lx sub unit exch moveto
- mx rx add lx add unit 0 rlineto } for stroke
- linewidth 3 mul setlinewidth
- currentlinecap
- 2 setlinecap
- lx 0.0 eq
- { newpath 0 0 ly sub unit moveto
- 0 my uy add ly add unit rlineto stroke } if
- rx 0.0 eq
- { newpath mx unit 0 ly sub unit moveto
- 0 my uy add ly add unit rlineto stroke } if
- ly 0.0 eq
- { newpath 0 lx sub unit 0 moveto
- mx rx add lx add unit 0 rlineto stroke } if
- uy 0.0 eq
- { newpath 0 lx sub unit my unit moveto
- mx rx add lx add unit 0 rlineto stroke } if
- setlinecap
- linewidth setlinewidth
- CommentFont
- str stringwidth pop
- mx unit sub -0.5 mul
- -1 unit moveto str show
- StartCom
- StoneFont
- } def
-
- /SetCoord { % stack: x y
- /yshift exch def
- /xshift exch def
- } bind def
-
- % -------- Program 18 / Making Small Changes to Encoding Vectors
- % -------- from PostScript Language Tutorial and Cookbook
- /reencsmalldict 12 dict def
- /ReEncodeSmall % --- 3 args: the name of the existing font, the name of
- % the new font , an array of new characters
- { reencsmalldict begin
- /newcodesandnames exch def
- /newfontname exch def
- /basefontname exch def
- /basefontdict basefontname findfont def
- /newfont basefontdict maxlength 1 add dict def
- basefontdict
- { exch dup /FID ne
- { dup /Encoding eq
- { exch dup length array copy
- newfont 3 1 roll put }
- { exch newfont 3 1 roll put }
- ifelse
- }
- { pop pop }
- ifelse
- } forall
- newfont /FontName newfontname put
-
- newcodesandnames aload pop
- newcodesandnames length 2 idiv
- { newfont /Encoding get 3 1 roll put }
- repeat
-
- newfontname newfont definefont pop
- end
- } bind def
-
- /accentvec[
- 8#260 /Scaron %scandinavy
- 8#265 /scaron %scandinavy
- 8#276 /Agrave %french
- 8#300 /Oacute %spain & scandy
- 8#311 /Adieresis %german & scandy
- 8#314 /agrave %french
- 8#321 /oacute %spain & scandy
- 8#322 /Ugrave %french
- 8#323 /Uacute %spain
- 8#324 /ugrave %french
- 8#325 /uacute %spain
- 8#326 /Egrave %french
- 8#327 /egrave %french
- 8#330 /Edieresis %french & scandy
- 8#331 /adieresis %german & scandy
- 8#332 /edieresis %french & scandy
- 8#333 /Odieresis %german & scandy
- 8#334 /odieresis %german & scandy
- 8#335 /Udieresis %german
- 8#336 /udieresis %german
- 8#337 /ntilde %spain
- 8#340 /Aacute %spain & scandy
- 8#342 /Aring %scandinavy
- 8#344 /Iacute %spain
- 8#345 /Idieresis %french
- 8#346 /idieresis %french
- 8#347 /Eacute %french & spain
- 8#354 /ecircumflex %french
- 8#355 /acircumflex %french
- 8#356 /icircumflex %french
- 8#357 /ocircumflex %french
- 8#360 /aacute %spain & scandy
- 8#362 /aring %scandinavy
- 8#363 /Ccedilla %french
- 8#364 /iacute %spain
- 8#366 /ccedilla %french
- 8#367 /eacute %french & spain
- %8#374 /openbullet
- %8#375 /fillbullet
- %8#376 /ahalf
- 8#200 /ograve %scandinavy
- 8#201 /Ograve %scandinavy
- 8#202 /Zcaron %scandinavy
- 8#203 /zcaron %scandinavy
- 8#204 /Ydieresis %turkey
- 8#205 /ydieresis %turkey
- %8#373 /germandbls %german
- %8#261 /Oslash %scandinavy
- %8#270 /oslash %scandinavy
- %8#262 /OE %scandinavy
- %8#271 /oe %scandinavy
- %8#255 /AE %scandinavy
- %8#264 /ae %scandinavy
- %8#257 /Lslash %poland
- %8#267 /lslash %poland
- ]def
- /Times-Italic /Times-Italic-Accent accentvec ReEncodeSmall
- /Times-Bold /Times-Bold-Accent accentvec ReEncodeSmall
- /Times-Roman /Times-Roman-Accent accentvec ReEncodeSmall
- /Helvetica-Bold /Helvetica-Bold-Accent accentvec ReEncodeSmall
-
- % -------- Program 8.5.3 Spezialitaeten mit Userfonts
- % -------- from Programmieren mit PostScript / Wilfried Soeker / Vieweg
- /NewFontSymbols { % stack: basefontname , newfontname, codingarray
- 10 dict dup begin
- /FontType 3 def
- /FontMatrix [0.001 0 0 0.001 0 0 ] def
- /FontBBox [ 0 0 1000 1000 ] def
- /basefont 5 -1 roll findfont def
- /Encoding 256 array def
- 0 1 255 {
- Encoding exch false put } for
- exch aload length 2 idiv
- { Encoding 3 1 roll put } repeat
-
- /BuildChar { %stack font, char
- exch begin
- basefont 1000 scalefont setfont
- dup Encoding exch get
- dup false eq
- { pop
- ( ) dup 0 4 -1 roll put
- dup stringwidth setcharwidth
- 0 0 moveto show
- }
- { exch pop aload pop
- 3 -1 roll (M) stringwidth 3 1 roll mul exch setcharwidth
- % exch aload pop setcachedevice
- 0 0 moveto
- exec
- pop % Bounding Box
- }
- ifelse
- end
- } bind def
- end
-
- definefont pop
- } def
-
- /openbullet
- { gsave newpath
- 380 300 400 0 360 arc
- closepath stroke grestore
- } bind def
-
- /fillbullet
- { gsave newpath
- 380 300 400 0 360 arc
- closepath fill stroke grestore
- } bind def
-
- /ahalf
- { 5 dict begin
- /regularfont currentfont def
- /fractionfont currentfont [0.6 0 0 0.5 0 0] makefont def % scaling
- gsave
- newpath
- 0 0 moveto
- (1) true charpath
- flattenpath pathbbox
- /height exch def pop pop pop
- (_) stringwidth pop
- fractionfont setfont
- (1) stringwidth pop
- sub 0.5 mul dup
- 0.60 height mul moveto (1) show
- 0.10 height mul neg moveto (2) show
- regularfont setfont
- 0 0.65 height mul moveto (_) show
- grestore
- end
- } def
-
- /newsymbols
- [
- 8#374 [ 1.0 [ 0 0 1.0 1.0] { openbullet } ]
- 8#375 [ 1.0 [ 0 0 1.0 1.0] { fillbullet } ]
- 8#376 [ 0.6 [ 0 0 1.0 1.0] { ahalf } ]
- ] def
- /Times-Roman-Accent /Times-Roman-Symbol newsymbols NewFontSymbols
- /Times-Italic-Accent /Times-Italic-Symbol newsymbols NewFontSymbols
-
-
- % -------- Main Program --------
- % 1.6 Scale 180 Yoff -60 Xoff % as large as possible
- % 1.2 Scale 10 Yoff % my standard, if you want
- % 0.9 Scale -140 Yoff 50 Xoff % 2 centered dia (1 Movelines possible)
- % 0.85 Scale -170 Yoff 50 Xoff % 2 centered dia (3 Movelines possible)
- % 0.7 Scale -220 Yoff -60 Xoff 2 SetColumn % 2 column output
- % 0.5 Scale -290 Yoff -80 Xoff 3 SetColumn % 3 column output
- % 0.37 Scale -360 Yoff -80 Xoff 4 SetColumn % 4 column output
- % 0.31 Scale -390 Yoff -80 Xoff 5 SetColumn % 5 column output
- @EOF
-
- chmod 644 layout/diagram.ps
-
- echo x - layout/smart2ps.c
- cat >layout/smart2ps.c <<'@EOF'
- /**************************************************************************/
- /* */
- /* Author: Achim Flammenkamp, department of mathematics */
- /* University of Bielefeld, 4800 Bielefeld 1 , Germany */
- /* */
- /* Date: 11.8.1992 Time: 14:26 MEST Version 3.6 */
- /* tested on: ULTRIX V4.2 , HP-UX 8.07 , SunOS 4.1 , MS-DOS 5.0 */
- /* */
- /* Send comments or bug reports to achim@hrz.uni-bielefeld.de */
- /* You are free to use and distribute it noncommerical :-) */
- /* */
- /**************************************************************************/
- #include <stdio.h>
- #define MAX 256 /* maximal linelength */
- #define SIZE 24 /* max boardsize + 1 */
- #define MPP 9999 /* huge step of pagebreaking (practical none) */
- #define NoCom 0 /* ignore comments during playing */
- #define NoPrison 0 /* specify whether there can't be ChangeStone[] */
-
- /************* c o m m a n d l i n e o p t i o n s ********************/
- /* */
- /* # sets the default pagebreak all # moves at least (default: MPP ) */
- /* -c toggles suppression of comments during playing (default: FALSE) */
- /* -r toggles existing of Ranking-entries in SGF (default: FALSE) */
- /* -p toggles existing of prisoner-entries in SGF (default: FALSE) */
- /* -x mirrors movecoordinates at x-centerline (default: FALSE) */
- /* -y mirrors movecoordinates at y-centerline (default: FALSE) */
- /* -i ignores nonspecific infos above the board (default: TRUE) */
- /* -m toggles prelude of comments by movesymbol (default: FALSE) */
- /* -s toggles caption of board by coordinates (default: TRUE) */
- /* -v toggles the previewing option (each move a page)(default: FALSE) */
- /* -d sets a new diagram after each move in the list following */
- /* -l@ select the language of key words (@ is a digit) (default: 0) */
- /* -z set move counter to zero each new diagram (default: FALSE) */
- /* -k@ set the number of 'reserved Movelines' to @ (default: 1) */
- /* -? shows legal options for this program and exits */
- /* */
- /**************************************************************************/
-
-
- char* pscheck(buffer,len)
- char buffer[];
- int *len;
- {
- int h, i, j=0;
- char octal[10];
- sprintf(octal,"%.3o%.3o%.3o",(unsigned)')',(unsigned)'(',(unsigned)'\\');
- for (i=0;buffer[i];i++)
- j += buffer[i] == '(' || buffer[i] == '\\' || buffer[i] == ')' ;
- j *=3;
- *len += j;
- for (h=i+1;buffer[h];h++);
- for (;h>i;h--)
- buffer[h+j] = buffer[h];
- j+=i;
- for (;i>=0;i--,j--)
- if ((buffer[j] = buffer[i])== ')' )
- { buffer[j--] = octal[2];
- buffer[j--] = octal[1];
- buffer[j--] = octal[0];
- buffer[j ] = '\\';
- }
- else if ( buffer[i] == '(' )
- { buffer[j--] = octal[5];
- buffer[j--] = octal[4];
- buffer[j--] = octal[3];
- buffer[j ] = '\\';
- }
- else if ( buffer[i] == '\\' )
- { buffer[j--] = octal[8];
- buffer[j--] = octal[7];
- buffer[j--] = octal[6];
- buffer[j ] = '\\';
- }
- return buffer;
- }
-
-
- #define MB 4
- #define MASK ((1<<MB)-1)
- #define MARK (1<<(MB-1))
- /***** IMPORTANT: 0 != 'W'&(MARK-1) != 'B'&(MARK-1) != 0 *****/
- /***** there is at least space for 1<<(8*sizeof(int) - MB) moves ***/
- /***** assuming 8 bits per char in a binary coding ****/
- static int size=19, stno, remove_list[SIZE*SIZE], act_board[SIZE][SIZE],
- board[SIZE][SIZE], komi=0, handi=0, kono=0, lett=0, boardlett[26];
- static int xmirror=0, ymirror=0, movesperpage=0, ranking=0, nocomm=NoCom,
- noprison=NoPrison, igninfo=1, prelude=0, caption=1, preview=0,
- lastno=0, dialist[SIZE*SIZE], diano, dias=0, lang=0, zero=0, kol=1;
- static char* words[10][18]; /* english, german, french, dutch, ... */
- static double pagel, pagew, topm, bottomm, leftm, rightm, intercol,
- scale=1.0, headscale=1.0;
- static int cols=1, headwidth=1, hflag=1, matchtime=0;
-
- move(x,y,z,no)
- int x, y, no;
- char *z;
- { int i, p, q, old;
- char mc = (z[0]!='(' ? z[0] : z[3] );
- if (no!=1 && no%movesperpage==1 || movesperpage==1 ||
- no==dialist[diano]+1)
- { if (noprison)
- for (p=0;p<=size;p++)
- for (q=0;q<=size;q++)
- board[p][q]=act_board[p][q];
- lastno = no-1;
- if (zero) printf("0 SetC\n");
- if (no==dialist[diano]+1)
- printf("() DrawBoard\n"), diano++;
- else
- printf("PageBreak\n");
- }
- old = board[x][y]>>MB;
- if (x && y && !old)
- { board[x][y] = (no<<MB) + (mc&MARK-1);
- printf("%2d %2d %s\n",x,y,z);
- }
- else
- { kono++;
- if (!x && !y)
- printf("%2d %2d (%s) %sMP\n",x,y,words[lang][17],z);
- else if (old > lastno)
- printf("%2d %2d (%d) %sMP\n",x,y,old,z);
- else
- { for (i=0;i<lett;i++)
- if (boardlett[i] == old) break;
- printf("%2d %2d (%c) %sMP\n",x,y,'A'+i,z);
- if (i==lett)
- { if (lett >= 26) fprintf(stderr,"boardlett too small\n");
- else boardlett[lett++] = old;
- printf("%2d %2d (%c) E%c\n",x,y,'A'+i,
- ( (board[x][y]&MARK-1)==('W'&MARK-1) ? 'B' : 'W' ) );
- }
- }
- }
- if (prelude) prelude=(mc=='W'?-1:1);
- if (noprison)
- { act_board[x][y] = (no<<MB) + (mc&MARK-1);
- check_for_prisoners(x,y);
- }
- return;
- }
-
- #define getcoord x = buffer[len]-'a'+1; y = buffer[len+1]-'a'+1; \
- if (x==size+1 && y==size+1) x=y=0; /* PASS */ \
- else if (x<=0 || x > size || y <= 0 || y > size) \
- fprintf(stderr,"invalid coords %s\n",buffer+len),x=y=0;\
- else { if(xmirror) x=size+1-x; if(!ymirror) y=size+1-y; }
- #define makestring incomm=getoption(buffer,&len); if (!incomm) ignore=0;
- #define checkincomm if(incomm){fprintf(stderr,"lines cut off:");ignore=1;}
- #define startboard if (!commruns) \
- { if (komi==1) printf("(Komi: \376"); \
- else if (komi&1) printf("(Komi: %d \376",komi/2); \
- else if (komi) printf("(Komi: %d", komi/2); \
- else if (handi) printf("("); \
- if (handi && komi) printf(" "); \
- if (handi) printf("%s: %d",words[lang][10],handi); \
- if (handi || komi) printf(") Info\n"); \
- if (preview) printf("SetView\n"); \
- if (caption) printf("SetCaption\n"); \
- printf("%d Movelines\n () DrawBoard\n",kol); \
- commruns = 1; }
- #define start startboard; if (!no) printf("StartGame\n"); \
- if (!gameruns) { if (startone) no=0; else no = !!no; \
- printf("%d SetC\n",no); gameruns=1; }
-
- getoption(buffer,len)
- char buffer[];
- int *len;
- { int i, j= *len, ret;
- for(i=j;buffer[i]&&buffer[i]!=']'&&buffer[i]!='\n'; i++)
- buffer[i-j]=buffer[i];
- ret = (buffer[i]!=']');
- buffer[i-j]='\000';
- if (buffer[i])
- for (i++;buffer[i-j]=buffer[i];i++);
- else
- buffer[i-j+1]='\000';
- *len=i-j;
- return (ret);
- }
-
- static char item[10];
-
- int scan_into_item(string,len)
- char string[];
- int *len;
- {
- int i;
- for(i=0;string[*len] && string[*len]!='[' ;(*len)++)
- if (string[*len] >= 'A' && string[*len] <= 'Z' && i<10)
- item[i++] = string[*len];
- if (string[*len]=='[') (*len)++;
- item[i]='\000';
- return i;
- }
-
- int is_item(entry)
- char *entry;
- {
- int i;
- for(i=0; *(entry+i) == item[i] ; i++)
- if (!item[i]) return 1;
- return 0;
- }
-
-
-
- main(argc,argv)
- int argc;
- char* argv[];
- {
-
- int i, x, y, len, no=0;
- unsigned gameruns = 0, commruns = 0, incomm = 0, ignore=0, header=1,
- startone = 0;
- char buffer[4*MAX], bname[MAX/2], wname[MAX/2];
- words[0][0] = "Black";
- words[0][1] = "White";
- words[0][2] = "Date";
- words[0][3] = "Place";
- words[0][4] = "Result";
- words[0][5] = "wins";
- words[0][6] = "loses";
- words[0][7] = "resignation";
- words[0][8] = "points";
- words[0][9] = "Timelimit";
- words[0][10] = "Handicap";
- words[0][11] = "Source";
- words[0][12] = "by";
- words[0][13] = "by";
- words[0][14] = "on";
- words[0][15] = "time";
- words[0][16] = "Tie";
- words[0][17] = "pass";
- words[1][0] = "Schwarz";
- words[1][1] = "Wei\373";
- words[1][2] = "Datum";
- words[1][3] = "Ort";
- words[1][4] = "Ergebnis";
- words[1][5] = "gewinnt";
- words[1][6] = "verliert";
- words[1][7] = "Aufgabe";
- words[1][8] = "Punkten";
- words[1][9] = "Bedenkzeit";
- words[1][10] = "Vorgabe";
- words[1][11] = "Quelle";
- words[1][12] = "mit";
- words[1][13] = "durch";
- words[1][14] = "auf";
- words[1][15] = "Zeit";
- words[1][16] = "Unentschieden";
- words[1][17] = "pa\373t";
- words[2][0] = "Noir";
- words[2][1] = "Blanc";
- words[2][2] = "Date";
- words[2][3] = "Lieu";
- words[2][4] = "R\367sultat";
- words[2][5] = "gagne";
- words[2][6] = "perd";
- words[2][7] = "abandon";
- words[2][8] = "points";
- words[2][9] = "Temps de restant";
- words[2][10] = "Handicap";
- words[2][11] = "Source";
- words[2][12] = "avec";
- words[2][13] = "par";
- words[2][14] = "par manque de";
- words[2][15] = "temps";
- words[2][16] = "Partie nulle";
- words[2][17] = "passe";
- words[3][0] = "Zwart";
- words[3][1] = "Wit";
- words[3][2] = "Datum";
- words[3][3] = "Plaats"; /* Oord */
- words[3][4] = "Resultaat";
- words[3][5] = "wint";
- words[3][6] = "verliest";
- words[3][7] = "opgave";
- words[3][8] = "punten";
- words[3][9] = "Bedenktijd";
- words[3][10] = "Voorgift";
- words[3][11] = "Bron";
- words[3][12] = "met";
- words[3][13] = "door";
- words[3][14] = "op";
- words[3][15] = "tijd";
- words[3][16] = "Gelijk spel";
- words[3][17] = "past";
- for (lang=4;lang<10;lang++)
- for (i=0;i<18;i++)
- words[lang][i] = "";
- lang=0;
- for (len=1;len<argc;len++)
- { if (*argv[len] == '-')
- { i=0;
- while( *(argv[len]+ ++i) )
- { switch (*(argv[len]+i) )
- {
- case 'c': nocomm^=1; break;
- case 'r': ranking^=1; break;
- case 'p': noprison^=1; break;
- case 'x': xmirror^=1; break;
- case 'y': ymirror^=1; break;
- case 'i': igninfo^=1; break;
- case 'm': prelude^=1; break;
- case 's': caption^=1; break;
- case 'v': preview^=1; break;
- case 'd': do {
- int h; i++;
- sscanf(argv[len]+i,"%u%n",&dialist[dias],&h);
- if (dialist[dias] <= 0)
- fprintf(stderr,
- "invalid numbers in diagram list: %s\n",
- argv[len]+i);
- else if (dias && dialist[dias-1] >= dialist[dias])
- fprintf(stderr,
- "numbers in diagram list must increase\n");
- else
- dias++;
- i += h;
- } while( *(argv[len]+i) == ',' );
- i--;
- break;
- case 'l': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%u%n",&lang,&h) ||
- lang >= 4)
- fprintf(stderr,"invalid digit in language code\n");
- i += h-1;
- break;
- }
- case 'k': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%u%n",&kol,&h) )
- fprintf(stderr,"invalid digit in no of reserved lines\n");
- i += h-1;
- break;
- }
- case 'z': zero^=1; break;
- case 'L': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&pagel,&h) )
- fprintf(stderr,"invalid value in pagelength\n");
- i += h-1;
- break;
- }
- case 'W': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&pagew,&h) )
- fprintf(stderr,"invalid value in pagwwidth\n");
- i += h-1;
- break;
- }
- case 'T': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&topm,&h) )
- fprintf(stderr,"invalid value in topmargin\n");
- i += h-1;
- break;
- }
- case 'M': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&leftm,&h) )
- fprintf(stderr,"invalid value in leftmargin\n");
- i += h-1;
- break;
- }
- case 'R': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&rightm,&h) )
- fprintf(stderr,"invalid value in leftmargin\n");
- i += h-1;
- break;
- }
- case 'S': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&scale,&h) )
- fprintf(stderr,"invalid value in scale factor\n");
- i += h-1;
- break;
- }
- case 'I': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&intercol,&h) )
- fprintf(stderr,"invalid value in inter col space\n");
- i += h-1;
- break;
- }
- case 'C': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%u%n",&cols,&h) )
- fprintf(stderr,"invalid value in columns\n");
- i += h-1;
- break;
- }
- case 'B': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&bottomm,&h) )
- fprintf(stderr,"invalid value in bottom margin\n");
- i += h-1;
- break;
- }
- case 'H': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%lf%n",&headscale,&h) )
- fprintf(stderr,"invalid value in head scale\n");
- i += h-1;
- break;
- }
- case 'h': hflag^=1; break;
- case 'J': { int h; i++;
- if (1!=sscanf(argv[len]+i,"%u%n",&headwidth,&h) )
- fprintf(stderr,"invalid value in head width\n");
- i += h-1;
- break;
- }
- default: fprintf(stderr,"unknown option: %s\n", argv[len]+i);
- case '?': fprintf(stderr,"version 3.6: usage: %s ",argv[0]);
- fprintf(stderr,"[# -c -r -p -x -y -i -m -s -dLIST -v -l@ -k@ -z -?");
- fprintf(stderr," -L -W -T -M -R -S -I -C -B -H -h -J]\n");
- exit(0);
- }
- }
- }
- else if (*argv[len] >= '0' && *argv[len] <= '9')
- sscanf(argv[len],"%d",&movesperpage);
- else
- fprintf(stderr,"ignored option: %s\n",argv[len]);
- }
- diano = 0;
- dialist[dias] = MPP;
- for (x=0;x<SIZE;x++)
- for (y=0;y<SIZE;y++)
- board[x][y] = act_board[x][y] = 0;
- if (!movesperpage) movesperpage=MPP;
- buffer[len=0]='\0';
- while( buffer[len] || (len=0, fgets(buffer,MAX-1,stdin)) )
- { if (incomm || ignore)
- { int oldign=ignore;
- makestring;
- if (oldign)
- /** fprintf(stderr,"%s\n",buffer) **/ ;
- else if (buffer[0] && (commruns || !igninfo))
- printf("(%s) %s\n",pscheck(buffer,&len), (commruns?"Com":"Info"));
- if (!oldign && commruns) printf("Newline\n");
- continue;
- }
- else
- for( ;buffer[len]; len++)
- if (buffer[len] > ' ')
- { if (header)
- { if (buffer[len] != '(' || buffer[len+1] != '\n') continue;
- header=0;
- printf("%% ---------- begin of game record ---------\n");
- if (pagel)
- printf("%lf Pagelength\n", pagel);
- if (pagew)
- printf("%lf Pagewidth\n", pagew);
- if (leftm || rightm || intercol)
- printf("%d %.3lf %.3lf %.3lf SetColumns\n",cols,leftm, rightm, intercol);
- else if (cols != 1)
- printf("%d SetColumn\n",cols);
- if (topm)
- printf("%.3lf TopMargin\n", topm);
- if (bottomm)
- printf("%.3lf BottomMargin\n", bottomm);
- if (scale != 1.0)
- printf("%lf Scale\n", scale);
- if (headscale != 1.0 || headwidth != 1)
- printf("%d %.3lf %d Heading\n",headwidth,headscale,hflag);
- printf("Initialize\n");
- }
- else if (buffer[len] == ';') {}
- else if (buffer[len] == '(') {}
- else if (buffer[len] == ')') {}
- else break;
- }
- if (buffer[len] == '[')
- { incomm=1; continue;
- }
- else if (!scan_into_item(buffer,&len))
- {}
- else if (is_item("W"))
- { start; no++; getcoord; move(x,y,"WC",no); len+=3; }
- else if (is_item("B"))
- { start; no++; getcoord; move(x,y,"BC",no); len+=3; }
- else if (is_item("C"))
- { makestring;
- if (nocomm)
- { if (incomm) ignore=1; }
- else
- { if (prelude && commruns)
- printf("%s ",(prelude==1?"BM":"WM"));
- if (buffer[0] && (commruns || !igninfo))
- printf("(%s) %s\n",pscheck(buffer,&len), (commruns?"Com":"Info"));
- }
- }
- else if (is_item("SZ"))
- { char del[2];
- sscanf(buffer+len,"%d%1s%n",&size,del,&i);
- if (size >= SIZE) return( fprintf(stderr,"SIZE too small\n") );
- len +=i;
- }
- else if (is_item("EV") || is_item("E"))
- { printf(" %d Size\n -999 SetC\n",size);
- makestring; printf(" (%s) Title\n",buffer); checkincomm;
- }
- else if (is_item("DT"))
- { makestring; printf(" (%s: %s) Info\n",words[lang][2],buffer);
- checkincomm;
- }
- else if (is_item("PC"))
- { makestring; printf(" (%s: %s) Info\n",words[lang][3],buffer);
- checkincomm;
- }
- else if (is_item("BS"))
- { makestring;
- printf(" (%s) BPlayer\n",buffer);
- checkincomm;
- }
- else if (is_item("WS"))
- { makestring;
- printf(" (%s) WPlayer\n",buffer);
- checkincomm;
- }
- else if (is_item("PB"))
- { makestring;
- if (ranking)
- for (i=0;bname[i]= *(buffer+i);i++) ;
- else
- printf(" (%s) BPlayer\n",buffer);
- checkincomm;
- }
- else if (is_item("PW"))
- { makestring;
- if (ranking)
- for (i=0;wname[i]= *(buffer+i);i++) ;
- else
- printf(" (%s) WPlayer\n",buffer);
- checkincomm;
- }
- else if (is_item("RE"))
- { double pkt; makestring;
- if ((buffer[0]=='W' || buffer[0]=='B') &&
- (buffer[1]=='+' || buffer[1]=='-') )
- { printf(" (%s: %s %s ", words[lang][4],
- (buffer[0]=='B'?words[lang][0]:words[lang][1]),
- (buffer[1]=='+'?words[lang][5]:words[lang][6]) );
- if ( !strcmp(buffer+2,"resign") || !strcmp(buffer+2,"Resign") )
- printf("%s %s) Info\n", words[lang][13], words[lang][7] );
- else if ( !strcmp(buffer+2,"time") || !strcmp(buffer+2,"Time") )
- printf("%s %s) Info\n", words[lang][14], words[lang][15] );
- else if (1==sscanf(buffer+2,"%lf%n",&pkt,&i) && !buffer[2+i] )
- printf("%s %s %s) Info\n",words[lang][12],buffer+2,words[lang][8]);
- else if (buffer[2])
- printf("%s %s) Info\n", words[lang][13], buffer+2);
- else printf(") Info\n");
- }
- else if ((buffer[0]=='0' || buffer[0]=='=') && buffer[1]=='\0' )
- printf(" (%s: %s) Info\n",words[lang][4],words[lang][16]);
- else
- printf(" (%s: %s) Info\n",words[lang][4],buffer);
- checkincomm;
- }
- else if (is_item("US"))
- { makestring; printf(" (%s) Info\n",buffer);
- checkincomm;
- }
- else if (is_item("GC"))
- { makestring; printf(" (%s) Info\n",buffer);
- checkincomm;
- }
- else if (is_item("BL"))
- { if (!matchtime && !commruns)
- { char del[2]; int matchsec;
- sscanf(buffer+len,"%d%1s%n",&matchsec,del,&i);
- len +=i;
- if (matchsec)
- { matchtime=1;
- printf(" (%s: %d min) Info\n",words[lang][9],(matchsec+30)/60);
- }
- }
- }
- else if (is_item("WL"))
- { if (!matchtime && !commruns)
- { char del[2]; int matchsec;
- sscanf(buffer+len,"%d%1s%n",&matchsec,del,&i);
- len +=i;
- if (matchsec)
- { matchtime=1;
- printf(" (%s: %d min) Info\n",words[lang][9],(matchsec+30)/60);
- }
- }
- }
- else if (is_item("TM"))
- { makestring;
- printf(" (%s: %s) Info\n",words[lang][9],buffer);
- matchtime = 1;
- checkincomm;
- }
- else if (is_item("BR"))
- { makestring;
- if (ranking)
- printf(" (%s, %s) BPlayer\n",bname,buffer);
- checkincomm;
- }
- else if (is_item("WR"))
- { makestring;
- if (ranking)
- printf(" (%s, %s) WPlayer\n",wname,buffer);
- checkincomm;
- }
- else if (is_item("KM"))
- { double v; char del[2];
- sscanf(buffer+len,"%lf%1s%n",&v,del,&i);
- komi = (int)(v<0?2*v-0.5:2*v+0.5);
- len +=i;
- }
- else if (is_item("HA"))
- { char del[2];
- sscanf(buffer+len,"%d%1s%n",&handi,del,&i);
- len +=i;
- }
- else if (is_item("AB"))
- { startboard;
- if (!no) printf("StartGame\n");
- do { no--; getcoord; move(x,y,"() B",no); len+=3; }
- while(buffer[len++]=='[');
- len--;
- }
- else if (is_item("AW"))
- { startboard;
- if (!no) printf("StartGame\n");
- do { no--; getcoord; move(x,y,"() W",no); len+=3; }
- while(buffer[len++]=='[');
- len--;
- startone = 1;
- }
- else if (is_item("PL"))
- { makestring;
- printf(" (%s to move) %s\n",buffer,(commruns?"Com Newline":"Info"));
- }
- else if (is_item("SO"))
- { makestring; printf(" (%s: %s) Info\n",words[lang][11],buffer);
- checkincomm;
- }
- else if (is_item("CS")) /* ChangeStone[] game dependend */
- { do { getcoord; printf("%2d %2d R\n",x,y); len+=3; }
- while(buffer[len++]=='[');
- len--;
- }
- else if (is_item("GM"))
- { int h; char del[2];
- sscanf(buffer+len,"%d%1s%n",&h,del,&i);
- if (h != 1) return( fprintf(stderr,"This game is not Go!\n") );
- len +=i;
- }
- else if (is_item("L"))
- { i=0;
- do { getcoord; printf("%2d %2d (%c) E\n",x,y,'A'+ i++); len+=3; }
- while(buffer[len++]=='[');
- len--;
- }
- else if (is_item("FG"))
- { makestring;
- printf("PageBreak\n");
- checkincomm;
- }
- else if (is_item("VW"))
- { if (buffer[len] != ']')
- { int h1, h2;
- getcoord;
- h1=x; h2=y; len+=4;
- getcoord;
- i=0;
- if (h1==1 || x==1) i |= 1;
- if (h1==size || x==size) i |= 2;
- if (h2==1 || y==1) i |= 4;
- if (h2==size || y==size) i |= 8;
- printf("%2d %2d %d () DrawPart\n",abs(x-h1),abs(y-h2),i);
- printf("%2d %2d SetCoord\n",(x<h1?x:h1),(y<h2?y:h2));
- len+=3;
- }
- else
- len++;
- }
- else if (is_item("N")) { makestring; checkincomm; }
- else if (is_item("V")) { makestring; checkincomm; }
- else if (is_item("CH")) { makestring; checkincomm; }
- else if (is_item("GB")) { makestring; checkincomm; }
- else if (is_item("GW")) { makestring; checkincomm; }
- else if (is_item("TE")) { makestring; checkincomm; }
- else if (is_item("BM")) { makestring; checkincomm; }
- else if (is_item("AE")) { makestring; checkincomm; }
- else if (is_item("GN")) { makestring; checkincomm; }
- else if (is_item("RO")) { makestring; checkincomm; }
- else if (is_item("EL")) { makestring; checkincomm; }
- else if (is_item("EX")) { makestring; checkincomm; }
- else if (is_item("SL")) { makestring; checkincomm; }
- else if (is_item("M")) { makestring; checkincomm; }
- else if (is_item("TB")) { makestring; checkincomm; }
- else if (is_item("TW")) { makestring; checkincomm; }
- else if (is_item("SC")) { makestring; checkincomm; }
- else if (is_item("RG")) { makestring; checkincomm; }
- else
- fprintf(stderr,"unknown property: %s at>%s\n",item,buffer);
- }
- if (!header)
- { printf("%% --------- end of game record ---------\n");
- i = (size - 1.9) / 1.2;
- printf("%% (%d moves) Info\n%% %d Movelines\n",no, (kono+i-1)/i);
- printf("showpage\n");
- }
- }
-
-
-
- check_for_prisoners(x,y)
- int x, y;
- { unsigned char type, stone, other;
- int i, rx, ry, sum=0;
- if ( !('W'&MARK-1) || !('B'&MARK-1) || ('W'&MARK-1)==('B'&MARK-1) )
- return( fprintf(stderr,"Coding Error: increase MB\n"), 0 );
- type=act_board[x][y]&MASK;
- other = (type==('B'&MARK-1)?'W'&MARK-1:'B'&MARK-1);
- stno=0;
- if (x > 1 && (stone=act_board[x-1][y]&MASK) && stone==other &&
- !count_liberties(x-1,y,stone) ) sum += remove_stones();
- for (i=0;i<stno;i++)
- { rx=remove_list[i]%size + 1;
- ry=remove_list[i]/size + 1;
- act_board[rx][ry] &= ~MARK;
- }
- stno=0;
- if (x < size && (stone=act_board[x+1][y]&MASK) && stone==other &&
- !count_liberties(x+1,y,stone) ) sum += remove_stones();
- for (i=0;i<stno;i++)
- { rx=remove_list[i]%size + 1;
- ry=remove_list[i]/size + 1;
- act_board[rx][ry] &= ~MARK;
- }
- stno=0;
- if (y > 1 && (stone=act_board[x][y-1]&MASK) && stone==other &&
- !count_liberties(x,y-1,stone) ) sum += remove_stones();
- for (i=0;i<stno;i++)
- { rx=remove_list[i]%size + 1;
- ry=remove_list[i]/size + 1;
- act_board[rx][ry] &= ~MARK;
- }
- stno=0;
- if (y < size && (stone=act_board[x][y+1]&MASK) && stone==other &&
- !count_liberties(x,y+1,stone) ) sum += remove_stones();
- for (i=0;i<stno;i++)
- { rx=remove_list[i]%size + 1;
- ry=remove_list[i]/size + 1;
- act_board[rx][ry] &= ~MARK;
- }
- stno=0;
- if (!count_liberties(x,y,type) ) sum -= remove_stones(); /* sucide */
- for (i=0;i<stno;i++)
- { rx=remove_list[i]%size + 1;
- ry=remove_list[i]/size + 1;
- act_board[rx][ry] &= ~MARK;
- }
- return sum;
- }
-
-
- count_liberties(x,y,type)
- int x, y;
- unsigned char type;
- { unsigned char stone;
- act_board[x][y] |= MARK;
- remove_list[stno++] = (y-1)*size + (x-1);
- if (x > 1 && !(stone=act_board[x-1][y]&MASK)) return 1;
- if (x > 1 && stone==type && count_liberties(x-1,y,type)) return 1;
- if (x < size && !(stone=act_board[x+1][y]&MASK)) return 1;
- if (x < size && stone==type && count_liberties(x+1,y,type)) return 1;
- if (y > 1 && !(stone=act_board[x][y-1]&MASK)) return 1;
- if (y > 1 && stone==type && count_liberties(x,y-1,type)) return 1;
- if (y < size && !(stone=act_board[x][y+1]&MASK)) return 1;
- if (y < size && stone==type && count_liberties(x,y+1,type)) return 1;
- return 0;
- }
-
- remove_stones()
- {
- int rx, ry, i;
- for (i=0;i<stno;i++)
- { rx=remove_list[i]%size + 1;
- ry=remove_list[i]/size + 1;
- act_board[rx][ry] = 0;
- printf("%2d %2d R\n",rx,ry);
- }
- stno = 0;
- return i;
- }
- @EOF
-
- chmod 644 layout/smart2ps.c
-
- echo x - layout/look
- cat >layout/look <<'@EOF'
- #!/bin/sh
- # shellscript for interactive use of smart2ps & ghostscript , 27th July 92
- file=$1 ; shift
- viewer="gs -g739x1045"
- printer=80
- editor=vi
- options="-rpm $@"
- if [ ! -r $file.ps ]
- then
- if [ ! -r $file.mgt ]
- then echo "$file.mgt not found"; exit 1
- fi
- cp diagram.ps $file.ps
- cat $file.mgt | smart2ps $options >> $file.ps
- else
- start=`head -1 $file.ps | cut -c1-4`
- if [ "$start" != "%!PS" ]
- then cp diagram.ps .scr.ps
- cat $file.ps >> .scr.ps ; file=.scr
- fi
- fi
- while :
- do
- echo "view(v) , print(p), quit(q), edit(e), remove(r) , format(f) ?"
- read ans
- if [ $ans = "v" ]
- then $viewer $file.ps
- elif [ $ans = "p" ]
- then lpr -x -P$printer $file.ps
- elif [ $ans = "e" ]
- then $editor $file.ps
- elif [ $ans = "r" ]
- then rm -i $file.ps; exit 0
- elif [ $ans = "q" ]
- then exit 0
- elif [ $ans = "f" -a -r $file.mgt ]
- then echo "new options ?" ; read opt
- cp diagram.ps $file.ps
- cat $file.mgt | smart2ps $opt >> $file.ps
- elif [ $ans = "f" ]
- then echo "$file.mgt not found"
- else echo "invalid command: $ans"
- fi
- done
- @EOF
-
- chmod 755 layout/look
-
- echo x - layout/example.ps
- cat >layout/example.ps <<'@EOF'
- % -------- begin of record ---------
- 1.2 Scale
- Initialize
- (No Way Out?) Title
- (Gui-Si:) Info
- (A life and death problem ) Info
- (from an ancient Chinese WeiQi book.) Info
- () DrawBoard
- Newline Newline
- (<WeiQi.PS>) Comment
- Newline
- (A PostScript program for drawing Go game.) Comment
- Newline
- (PostScript is a trade mark of ) Comment
- (Adobe System, Incorporated. ) Comment
- Newline
- (Weiqi is Go in Chinese.) Comment
- ( Baduk is Go in Korean.) Comment
- Newline
- Newline
- (Please send any comment and suggestion to ) Comment
- (achim@hrz.uni-bielefeld.de) Comment
- StartGame
- % -------- Problem --------
- 6 3 () B
- 7 3 () B
- 8 3 () B
- 5 4 () B
- 9 4 () B
- 5 6 () B
- 9 6 () B
- 7 6 () B
- 7 7 () B
- 6 4 () W
- 6 5 () W
- 7 4 () W
- 8 4 () W
- 8 5 () W
- % -------- transformation --------
- 14 17 () B
- 13 17 () B
- 12 17 () B
- 15 16 () B
- 11 16 () B
- 15 14 () B
- 11 14 () B
- 13 14 () B
- 13 13 () B
- 14 16 () W
- 14 15 () W
- 13 16 () W
- 12 16 () W
- 12 15 () W
- 13 18 Ko (1) W At (?) E
- % ------ solution ---------
- 13 12 (1) W
- 15 15 (2) B
- 11 15 (3) W
- 10 15 (4) B
- 10 16 (5) W
- 11 17 (6) B
- 10 14 (7) W
- 9 15 (8) B
- 12 14 (9) W
- 11 13 (10) B
- 12 13 (11) W
- 12 12 (12) B
- 11 12 (13) W
- showpage
- % -------- end of record ---------
- @EOF
-
- chmod 644 layout/example.ps
-
- echo x - layout/sample_old.ps
- cat >layout/sample_old.ps <<'@EOF'
- 1.2 Scale -10 Yoff -80 Xoff 2 SetColumn
- Initialize
- 26 Size
- ToggleRedraw
- (PLL-Liga Problem 10) Title
- (a middle game problem) Info
- 12 Size
- 0 Movelines
- 13 10 5 (Problem: black to play) DrawPart
- -999 SetC
- StartGame
- 4 4 BC
- 6 4 BC
- 4 10 BC
- 7 3 BC
- 8 4 BC
- 3 6 WC
- 7 4 WC
- 7 5 WC
- 8 3 WC
- 13 10 5 (white plays for influence) DrawPart
- -999 SetC
- StartGame
- 4 4 BC
- 6 4 BC
- 4 10 BC
- 7 3 BC
- 8 4 BC
- 3 6 WC
- 7 4 WC
- 7 5 WC
- 8 3 WC
- 0 SetC
- 6 5 BC
- 6 3 WC
- 7 2 BC
- 6 2 WC
- 8 2 BC
- 9 3 WC
- 8 5 BC
- 7 6 WC
- 5 3 BC
- 9 6 WC
- 8 6 BC
- 8 7 WC
- 7 7 BC
- 6 6 WC
- 9 7 BC
- 8 8 WC
- 9 5 BC
- 10 6 WC
- 10 5 BC
- 11 5 WC
- 11 6 BC
- 10 7 WC
- 11 4 BC
- 12 5 WC
- 10 4 BC
- 9 2 WC
- 5 2 BC
- 8 1 WC
- 6 1 BC
- 6 3 R
- 6 2 R
- 12 4 WC
- 11 3 BC
- 11 2 WC
- 12 3 BC
- 13 3 WC
- 12 2 BC
- 13 2 WC
- 10 2 BC
- 12 1 WC
- 11 1 BC
- 11 2 R
- 13 1 WC
- 10 1 BC
- 10 3 WC
- 7 1 BC
- 6 8 WC
- 13 10 5 (correct: white takes the corner) DrawPart
- -999 SetC
- StartGame
- 4 4 BC
- 6 4 BC
- 4 10 BC
- 7 3 BC
- 8 4 BC
- 3 6 WC
- 7 4 WC
- 7 5 WC
- 8 3 WC
- 0 SetC
- 6 5 BC
- 6 3 WC
- 7 2 BC
- 6 2 WC
- 8 2 BC
- 3 3 WC
- 4 3 BC
- 4 2 WC
- 3 2 BC
- 2 2 WC
- 5 2 BC
- 3 1 WC
- 6 1 BC
- ColBreak
- 13 10 5 (move 9 is blacks failure) DrawPart
- -999 SetC
- StartGame
- 4 4 BC
- 6 4 BC
- 4 10 BC
- 7 3 BC
- 8 4 BC
- 3 6 WC
- 7 4 WC
- 7 5 WC
- 8 3 WC
- 0 SetC
- 6 5 BC
- 6 3 WC
- 7 2 BC
- 6 2 WC
- 8 2 BC
- 3 3 WC
- 4 3 BC
- 4 2 WC
- 5 2 BC
- 5 3 WC
- 3 2 BC
- 5 1 WC
- 3 4 BC
- 2 3 WC
- 2 2 BC
- 5 4 WC
- 5 5 BC
- 2 4 WC
- 2 5 BC
- 4 5 WC
- 3 5 BC
- 4 6 WC
- 2 6 (A) E
- 6 6 (B) E
- 13 10 5 (white resists strong) DrawPart
- -999 SetC
- StartGame
- 4 4 BC
- 6 4 BC
- 4 10 BC
- 7 3 BC
- 8 4 BC
- 3 6 WC
- 7 4 WC
- 7 5 WC
- 8 3 WC
- 0 SetC
- 6 5 BC
- 6 3 WC
- 7 2 BC
- 6 2 WC
- 8 2 BC
- 3 3 WC
- 4 3 BC
- 4 2 WC
- 3 2 BC
- 5 3 WC
- 3 4 BC
- 2 3 WC
- 2 2 BC
- 2 4 WC
- 6 1 BC
- 3 5 WC
- 4 5 BC
- 4 1 (A) E
- 1 2 (B) E
- 13 10 5 (second attempt of white) DrawPart
- -999 SetC
- StartGame
- 4 4 BC
- 6 4 BC
- 4 10 BC
- 7 3 BC
- 8 4 BC
- 3 6 WC
- 7 4 WC
- 7 5 WC
- 8 3 WC
- 0 SetC
- 6 5 BC
- 6 3 WC
- 7 2 BC
- 6 2 WC
- 8 2 BC
- 3 3 WC
- 4 3 BC
- 4 2 WC
- 3 2 BC
- 5 2 WC
- 3 4 BC
- 2 3 WC
- 2 2 BC
- 2 4 WC
- 2 5 BC
- 3 5 WC
- 1 4 BC
- 5 4 WC
- 5 5 BC
- % ---- end of game record 97 moves ---------
- showpage
- @EOF
-
- chmod 644 layout/sample_old.ps
-
- echo x - layout/sample_new.ps
- cat >layout/sample_new.ps <<'@EOF'
- % 0.7 Scale -220 Yoff -60 Xoff 2 SetColumn % 2 column output
- 1.0 TopMargin
- 2 0.5 0.5 0.5 SetColumns
- Initialize
- 1 1.0 0 Heading
- 19 Size
- (Problem 16 der PPL) Title
- 0 Movelines
- -999 SetC
- 0 13 SetCoord
- 19 6 11 (Wei\373 am Zug) DrawPart
- StartGame
- 4 18 () B
- 6 18 () B
- 6 17 () B
- 7 16 () B
- 7 15 () B
- 8 15 () B
- 9 16 () B
- 10 17 () B
- 9 17 () B
- 11 18 () B
- 7 18 () W
- 8 18 () W
- 8 17 () W
- 8 16 () W
- 9 15 () W
- 10 15 () W
- 11 17 () W
- 12 16 () W
- 14 17 () W
- Newline
- StartGame
- 19 6 11 (Ko wenn Wei\373 alles fangen will) DrawPart
- 4 18 () B
- 6 18 () B
- 6 17 () B
- 7 16 () B
- 7 15 () B
- 8 15 () B
- 9 16 () B
- 10 17 () B
- 9 17 () B
- 11 18 () B
- 7 18 () W
- 8 18 () W
- 8 17 () W
- 8 16 () W
- 9 15 () W
- 10 15 () W
- 11 17 () W
- 12 16 () W
- 14 17 () W
- 0 SetC
- 12 18 WC
- 9 18 BC
- 9 19 WC
- 10 19 BC
- 7 19 WC
- 6 19 BC
- 10 16 WC
- 8 19 BC
- Newline
- StartGame
- -999 SetC
- 19 6 11 (Schwarz rettet einen Stein) DrawPart
- 4 18 () B
- 6 18 () B
- 6 17 () B
- 7 16 () B
- 7 15 () B
- 8 15 () B
- 9 16 () B
- 10 17 () B
- 9 17 () B
- 11 18 () B
- 7 18 () W
- 8 18 () W
- 8 17 () W
- 8 16 () W
- 9 15 () W
- 10 15 () W
- 11 17 () W
- 12 16 () W
- 14 17 () W
- 0 SetC
- 9 19 WC
- 12 17 BC
- 11 16 WC
- 13 17 BC
- 10 18 WC
- 14 18 BC
- 15 17 WC
- 15 18 BC
- 16 17 WC
- 13 16 BC
- Newline
- StartGame
- 19 6 11 (Schwarz rettet einen Stein) DrawPart
- -999 SetC
- 4 18 () B
- 6 18 () B
- 6 17 () B
- 7 16 () B
- 7 15 () B
- 8 15 () B
- 9 16 () B
- 10 17 () B
- 9 17 () B
- 11 18 () B
- 7 18 () W
- 8 18 () W
- 8 17 () W
- 8 16 () W
- 9 15 () W
- 10 15 () W
- 11 17 () W
- 12 16 () W
- 14 17 () W
- 0 SetC
- 9 19 WC
- 12 17 BC
- 11 16 WC
- 13 17 BC
- 10 18 WC
- 12 18 BC
- 14 16 WC
- 14 18 BC
- 15 18 WC
- 13 19 BC
- 15 19 WC
- 14 19 BC
- % --------- end of game record ---------
- ColBreak
- 1 1.0 0 Heading
- (Problem 17 der PPL) Title
- 1 Movelines
- StartGame
- 0 13 SetCoord
- 19 6 11 (Wei\373 am Zug) DrawPart
- -999 SetC
- 3 18 () B
- 2 17 () B
- 4 17 () B
- 4 16 () B
- 3 15 () B
- 5 16 () B
- 6 17 () B
- 7 17 () B
- 8 17 () B
- 7 18 () B
- 9 18 () B
- 10 18 () B
- 3 17 () W
- 3 16 () W
- 4 18 () W
- 5 18 () W
- 5 17 () W
- 6 16 () W
- 7 16 () W
- 8 16 () W
- 9 17 () W
- 10 17 () W
- 11 17 () W
- 11 18 () W
- Newline
- StartGame
- 1 Movelines
- -999 SetC
- 19 6 11 (Teilerfolg von Wei\373) DrawPart
- 3 18 () B
- 2 17 () B
- 4 17 () B
- 4 16 () B
- 3 15 () B
- 5 16 () B
- 6 17 () B
- 7 17 () B
- 8 17 () B
- 7 18 () B
- 9 18 () B
- 10 18 () B
- 3 17 () W
- 3 16 () W
- 4 18 () W
- 5 18 () W
- 5 17 () W
- 6 16 () W
- 7 16 () W
- 8 16 () W
- 9 17 () W
- 10 17 () W
- 11 17 () W
- 11 18 () W
- 0 SetC
- 2 18 WC
- 2 16 BC
- 3 19 WC
- 3 17 BC
- 6 19 WC
- 8 19 BC
- 10 19 WC
- 4 19 BC
- 11 19 WC
- 2 19 BC
- 9 19 WC
- 3 19 Ko BC At (2) E
- 7 19 WC
- 5 19 BC
- 8 18 WC
- 6 18 BC
- Newline
- StartGame
- 1 Movelines
- -999 SetC
- 19 6 11 (Mit Ko kann Schwarz etwas mehr haben) DrawPart
- 3 18 () B
- 2 17 () B
- 4 17 () B
- 4 16 () B
- 3 15 () B
- 5 16 () B
- 6 17 () B
- 7 17 () B
- 8 17 () B
- 7 18 () B
- 9 18 () B
- 10 18 () B
- 3 17 () W
- 3 16 () W
- 4 18 () W
- 5 18 () W
- 5 17 () W
- 6 16 () W
- 7 16 () W
- 8 16 () W
- 9 17 () W
- 10 17 () W
- 11 17 () W
- 11 18 () W
- 0 SetC
- 2 18 WC
- 2 16 BC
- 3 19 WC
- 6 19 BC
- 3 17 WC
- 5 19 BC
- 8 19 WC
- 3 16 BC
- 6 18 WC
- 3 18 BC
- 3 19 Ko WC At (X) E
- % --------- end of game record ---------
- showpage
- @EOF
-
- chmod 644 layout/sample_new.ps
-
- chmod 751 layout
-
- exit 0
-