home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / go / prog / smart2ps.sh < prev    next >
Encoding:
Text File  |  1993-06-20  |  76.9 KB  |  2,723 lines

  1.  
  2. # This is a shell archive.  Remove anything before this line,
  3. # then unpack it by saving it in a file and typing "sh file".
  4. #
  5. # Wrapped by Achim Flammenkamp <achim@dozy> on Tue Mar 16 17:41:45 1993
  6. #
  7. # This archive contains:
  8. #    layout    
  9. #
  10.  
  11. LANG=""; export LANG
  12. PATH=/bin:/usr/bin:$PATH; export PATH
  13.  
  14. echo mkdir - layout
  15. mkdir layout
  16.  
  17. echo x - layout/dia.doc
  18. cat >layout/dia.doc <<'@EOF'
  19.                            A   D O C U M E N T I O N 
  20.  
  21.                             of the User Functions in
  22.  
  23.                               d i a g r a m . p s
  24.  
  25.                                   Version 3.8
  26.  
  27.  
  28. General:
  29.        For PS novices:  PostScript is a programming language from Adobe Inc.
  30.        for high quality graphic output. It is stack orientated. Therefore
  31.        arguments must prelead a function call. The symbol % ever starts a
  32.        comment until the actual line ends. All tokens need only separated by
  33.        at least one white space character (blank, tab, CRLF).
  34.        The Fonts are extended that you can use accented letters in strings.
  35.        Look up their octal coding in /accentvec ; e. g. (pla\356t \314 homme).
  36.        You can not only print a single game record, but also form your own
  37.        layout of go diagrams. The default papersize is assumed to be DIN A4.
  38.  
  39. User Layout Functions:
  40.  
  41.    Pagelength
  42.       val Pagelength  ---  set the pagelength to val inches
  43.    Pagewidth 
  44.       val Pagewidth  ---  set the pagewidth to val inches
  45.    Scale
  46.       val Scale  ---  set the global scale factor of the graphic to val
  47.    Yoff 
  48.       val Yoff  ---  increase the global top margin by val pts (1/72 inch)
  49.                      the real margin depends on scale factor 
  50.    Xoff 
  51.       val Xoff  ---  increase the global left margin by val pts (1/72 inch)
  52.                      the real margin depends on scale factor 
  53.    TopMargin
  54.       val TopMargin  ---  set the global top margin to val inches
  55.                         the real top margin is independent of the scale factor 
  56.    BottomMargin
  57.       val BottomMargin  ---  set the global bottom margin to val inches. the
  58.                         real bottom margin is independent of the scale factor 
  59.    Size
  60.        n1 Size  ---  set the size of the board to n1 (1 <= n1 <= 25)
  61.                      (default: 19). Also usefull to change the columnwidth,
  62.                      which is as large as the boardsize times 1/4 inch.
  63.    SetColumn 
  64.        n1 SetColumn  ---  set the number of columns per page to n1 (>= 1), but
  65.                           do not check whether the pagewidth is large enough
  66.                           or the actual scale factor and the colwidth are ok
  67.    SetColumns
  68.        n1 lm rm ic SetColumns  ---  set the number of columns per page to n1.
  69.                                Computes a new scale factor depending of the
  70.                                pagewidth, the inter columns space, ic, the
  71.                                left margin, lm, the right margin, rm, and
  72.                                the size of the board. Therefore this command
  73.                                should be given after that is correct set. The
  74.                                values of lm, rm and ic are interpretated as
  75.                                inches. Also Xoff is fitted to ensure a left
  76.                                margin of lm inches. The value ic will be
  77.                                ignored if n1 equals 1 but must be given.
  78.                                
  79.    Initialize
  80.       Initialize  ---  must ALWAYS prelude the sequence of PS commands, 
  81.                        EXECPT the x-y-sizing macros must be in front of it.
  82.                        These are:  Pagelength, Pagewidth, Xoff, Yoff, Scale,
  83.                                    TopMargin, BottomMargin, Size, SetColumn,
  84.                                    SetColumns
  85.  
  86. User Game Functions:
  87.  
  88.    Heading
  89.       n1 val flag  ---  centers the heading above the next n1 ( > 0 ) columns
  90.                         set the scaling factor of the head to val ( >= 0 )
  91.                         flag indicates whether the space of the headmargin
  92.                         should be reserved on the next pages.  ATTENTION:
  93.                         multiple game records must be separated by this command
  94.    Title
  95.        (string) Title  ---  print title (string) in the heading
  96.    BPlayer
  97.        (string) BPlayer  ---  print name (string) of black player in heading
  98.    WPlayer
  99.        (string) WPlayer  ---  print name (string) of white player in heading
  100.    Info
  101.        (string) Info  ---  print information (string) in heading
  102.    SetCaption
  103.        SetCaption  ---  toggles the caption of the board (default: off)
  104.    Movelines
  105.        n1 Movelines  ---  set the number of reserved lines to n1 (n1 >= 0)
  106.                           These will automatic generated with DrawBoard and
  107.                           DrawPart below the board to show moves on occupied
  108.                           positions (default: 1)
  109.                         
  110.    DrawBoard
  111.        (string) DrawBoard  ---  draw a size times size goboard with subscrip-
  112.                            tion (string) . Attention will overlap the caption
  113.  
  114.    StartGame
  115.        StartGame  ---  begin to input game data. Must be given exact onetime
  116.                        for each game record (clears internal move counter)
  117.                        Given in front of DrawBoard will garanty an empty board
  118.                        (useful trick to show different games on a page)
  119.    Com
  120.        (string) Com     ---  print comment (string) below the board
  121.    Newline
  122.        Newline  ---  break line (maybe page) in comment text
  123.    W
  124.        n1 n2 (n3) W  ---  put a white stone at coordinate n1 n2,
  125.                           and set mark with (n3). () gives no mark.
  126.                           1 <= n1 <= boardsize, 1<= n2 <= boardsize,
  127.                           n3 can be any character or string.
  128.    B
  129.        n1 n2 (n3) B  ---  same as W, but for black stone
  130.    E
  131.        n1 n2 (n3) E  ---  set a black marker at coordinate n1 n2.
  132.                           1 <= n1 <= boardsize, 1<= n2 <= boardsize,
  133.                           selects white background.
  134.    EB
  135.        n1 n2 (n3) EB  ---  same as E, but select no background.
  136.    EW
  137.        n1 n2 (n3) EW  ---  same as EB, but set white marker
  138.    SetC
  139.        n1 SetC  ---  set move counter to n1 (n1 must be an integer)
  140.    WC
  141.        n1 n2 WC  ---  put a white stone at coordinate n1 n2, and increase
  142.                       counter. if counter > 0 then set mark 'counter'.
  143.                       1 <= n1 <= boardsize, 1<= n2 <= boardsize,
  144.    BC
  145.        n1 n2 BC  ---  put a black stone at coordinate n1 n2, and increase
  146.                       counter. if counter > 0 then set mark 'counter'.
  147.                       1 <= n1 <= boardsize, 1<= n2 <= boardsize,
  148.    WCMP
  149.        n1 n2 (n3) WCMP  ---  put a white stone at coordinates n1 n2, but draw
  150.                              it with mark 'counter' below the board and draw
  151.                              the (n3) string beside this move in the reserved
  152.                              lines. Equivalent to    n1 n2 Ko WC At (n3) E
  153.    BCMP
  154.        n1 n2 (n3) BCMP  ---  put a black stone at coordinates n1 n2, but draw
  155.                              it with mark 'counter' below the board and draw
  156.                              the (n3) string beside this move in the reserved
  157.                              lines. Equivalent to    n1 n2 Ko BC At (n3) E
  158.    Ko
  159.        n1 n2 Ko       ---  there is a move at coordinates n1 n2 , but it
  160.                            will be drawn below the board in the reserved lines
  161.        n1 n2 Ko (n3) W  ---  draws W stone with mark n3 below the board
  162.        n1 n2 Ko (n3) B  ---  draws B stone with mark n3 below the board
  163.        n1 n2 Ko     WC  ---  draws W stone with mark 'counter' below the board
  164.        n1 n2 Ko     BC  ---  draws B stone with mark 'counter' below the board
  165.    At
  166.        At (n3) E  ---  draws mark (n3) below the ko stone in the reserved lines
  167.                        only sensible after a Ko command. Two examples:
  168.                        n1 n2 Ko WC At (pass) E    ,   n1 n2 Ko (n3) B At (A) E
  169.    WM
  170.        WM  ---  white move in comment with referrence to last move
  171.    BM
  172.        BM  ---  black move in comment with referrence to last move
  173.    WS
  174.        WS  ---  white stone symbol in comment. Should be replaced by the
  175.                 special character \374 in comment
  176.    BS
  177.        BS  ---  black stone symbol in comment. Should be replaced by the
  178.                 special chararcter \375 in comment
  179.    CBS
  180.        CBS ---  shortened form of Com BS
  181.    CWS
  182.        CWS ---  shortened form of Com WS
  183.    PageBreak
  184.        PageBreak  ---  starts a new page and can redraw the board
  185.    R
  186.        n1 n2 R ---  remove stone at coordinates n1 n2   
  187.                     1 <= n1 <= boardsize, 1<= n2 <= boardsize
  188.                     the result will be visulable on the next page only
  189.    ColBreak
  190.        ColBreak  ---  explicit column break
  191.    SetView
  192.        SetView  ---  set the singlemove view mode
  193.    SetCharC  
  194.        n1 SetCharC   ---  set the max. number of characters per marker to n1
  195.                           will be used in calculating the size of StoneFont
  196.    ToggleRedraw
  197.        ToggleRedraw  ---  toggles the automatic redrawing of the board at
  198.                           PageBreak (default is redrawing on)
  199.    Togglehead
  200.        ToggleHead  ---  toggles the common headmargin (default is head margin
  201.                         of first heading in opposite to no head margin)
  202.    DrawPart
  203.        n1 n2 m (cap) DrawPart  ---  draws a n1 times n2 part of a go board
  204.                               with margins indicated in m and caption (cap)
  205.                               m (< 16) is interpreted as 4digit binary number;
  206.                               each binary digit, if it is 1, indicates a margin
  207.                               to draw. the digits are numbered from lower- to
  208.                               highervalued ones:
  209.                                  the 1. digit represents the left margin
  210.                                  the 2. digit represents the right margin
  211.                                  the 3. digit represents the lower margin
  212.                                  the 4. digit represents the upper margin
  213.    SetCoord  
  214.        n1 n2 SetCoord   ---  set the xshift n1 and yshift n2 to be subtracted
  215.                              from all move coordinates. this defines virtually
  216.                              the offset of the lower left corner of the board
  217.    showpage
  218.        showpage  ---  prints the (last) page. Should be the final PS command
  219.  
  220.  
  221. Please, send any bug reprorts, comments or suggestions for improvements to
  222.  
  223.          achim@unibi.hrz.uni-bielefeld.de
  224.  
  225.                                                      Bielefeld, August 11 1992
  226. @EOF
  227.  
  228. chmod 644 layout/dia.doc
  229.  
  230. echo x - layout/README
  231. sed 's/^@//' >layout/README <<'@EOF'
  232. To compile this program, type
  233.    cc -o smart2ps smart2ps.c
  234.  
  235. Use smart2ps to generate the postscript for a SGF file like
  236.    cp diagram.ps file.ps ; smart2ps <file.mgt >>file.ps
  237.  
  238.  
  239. @From: Achim Flammenkamp <achim@unibi.hrz.uni-bielefeld.de>
  240.  
  241.  
  242.    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)
  243.  
  244.  
  245. SGF means smart go format  and  PS  means PostScript in the following context.
  246.  
  247. 'smart2ps' converts many SGF files into PS format. It's not a perfect converter
  248. but I hope it is practical. You can easly extend or change it if you under-
  249. stand C programming.
  250. With some commandline options you can variate the layout of its PS-output.
  251.  
  252. They are: 
  253.  
  254. #    any natural number # sets the default pagebreak of the PS code every #
  255.      moves at least. E.g. to get (al least) every 50 moves a new sheet you must
  256.      append 50 somewhere after your command 'smart2ps'. If there are enough
  257.      comments to fill the page then there will be a pagebreak, too.
  258. -c   this option toggles the suppression of comments during playing. Its
  259.      default value doesn't suppress these comments to be printed in PS.
  260. -r   tell the converter whether there are seperate ranking entries for the
  261.      players to aspect. They will be collected and put together with the 
  262.      corresponding players' names into PS.
  263. -p   without this option the converter doesn't check liberties of groups in go
  264.      and generate no implicit R(EMOVE) PS-command. This means captured stones
  265.      are visible on new sheets of the printing. With this option the converter
  266.      checks the liberties of each move and generate corresponding R(EMOVE) PS-
  267.      commands, if neccessary. An extension to SGF is the ChangeStone[xy][xy].
  268.      entry with can occure and changes the positions [xy] where a stone is 
  269.      located (in Go it can only be changed to empty by capturing). If you
  270.      convert e.g.  ishi-std-format to SGF you will like this facility.
  271. -x   mirrors all stones at the x-centerline of the board in comparision to
  272.      their original positions (maybe wishful for some purpose). 
  273. -y   mirrors all stones at the y-centerline of the board in comparision to
  274.      their original positions (maybe useful to convert IGS recorded go-games). 
  275. -i   ignores all Comment entries in SGF before the start of the match (would be
  276.      placed above the board in PS format and would shift down the board repre-
  277.      sentation.)
  278. -m   toggles the prelude of comments by black and white stone symbols while
  279.      playing. (If not set you will have difficulties probably to map the
  280.      comments to played moves.)
  281. -s   toggles the default caption of the board by numbers(y-axes) and letters
  282.      (x-axes) to no caption.
  283. -v   generates a PS-code easy to view with ghostscript or other PS-viewers.
  284.      (Not recommended for printing because it will generate each move on a
  285.      new page.)
  286. -dLIST  generates after each move of the LIST a new diagram. LIST is a non
  287.      empty, strict increasing list of natural numbers separated by commas.
  288. -l@  sets the language of key words to english (@=0), german (@=1), french
  289.      (@=2), dutch (@=3). Further codes maybe defined in future releases.
  290. -k@  sets the number of 'Movelines' to @. These reserved lines below the
  291.      diagram services to the ko moves and other multiple occupied points.
  292. -z   toggles the move counter to zero for each new diagramm. Move numbers will
  293.      start with 1 in each diagramm if this option is set. Defaultly it is off.
  294. -?   will show you all legal options of this program and the actual version
  295.      number and exits.
  296. -L#  sets the pagelength to # inches (default 11.5)
  297. -W#  sets the pagewidth to # inches  (default 8.25)
  298. -S#  sets the global scaling factor to # (default 1.0)
  299. -T#  sets the topmargin to # inches
  300. -M#  sets the leftmargin to # inches  
  301. -R#  sets the rightmargin to # inches
  302. -I#  sets the inter column space to # inches (default is 0.5)
  303. -C@  sets the the number of columns (default 1) you want to have to @
  304. -B#  sets the bottommargin to # inches
  305. -H#  sets the scaling factor of the head to # (default 1.0)
  306. -h   toggles the reservation of space of the headmargin on next pages
  307. -J@  sets the head width to @ columns (default 1) including inter column space
  308.  
  309.  
  310.  
  311.   An unix-borne-shell script  look  is included to show the use of smart2ps
  312.   and the PS-code in diagram.ps for easy interactive use. Probably you have
  313.   to change the printer name inside  look  and perhaps the viewer 'gs'. Maybe
  314.   you want to have different default options of smart2ps.
  315.  
  316.                                           Bielefeld, Germany, March 16th 1993
  317.  
  318. @EOF
  319.  
  320. chmod 644 layout/README
  321.  
  322. echo x - layout/diagram.ps
  323. cat >layout/diagram.ps <<'@EOF'
  324. %!PS-Adobe-2.0
  325. % ******* WeiQi.PS ******* 3.8 ***
  326. % A PostScript Program for Drawing Go game.
  327. %
  328. % Achim Flammenkamp,  Wed Dec 19 18:30 MET 1992
  329. % Youyi Chen,  Wed Aug 8 15:41:30 EDT 1990
  330. %
  331. %       Achim Flammenkamp    achim@hrz.uni-bielefeld.de
  332. %     Department of Mathematics
  333. %     University of Bielefeld
  334. %     4800 Bielefeld 1
  335. %     Germany
  336. %
  337. %       Youyi Chen    yychen@watdragon.uwaterloo.ca
  338. %       Department of Statistics and Actuarial Science
  339. %       University of Waterloo
  340. %       Waterloo, Ontario
  341. %       Canada, N2L 3G1
  342. %
  343. %
  344. % General:
  345. %    Two sample problems are supplied with this program. Append one
  346. %    of the examples and send all directly to a Postscript printer,
  347. %    you will get a very interesting ancient Chinese WeiQi life and
  348. %    death problem drawn by PostScript.
  349. %
  350. %   At the bottom of this file different layouts are presented.
  351. %   Select one of them or creat one of your own if you like.
  352. %    If you want to print your own games, you only need to edit
  353. %    the example data, title, comments using the same format.
  354. %
  355. %
  356. % CopyLeft:
  357. %    You are free to use and distribute it non commercial.
  358. %    Please send me your suggestions, comments and bug reports.
  359. %
  360. % PostScript is a trademark of Adobe Systems, Incorporated.
  361.  
  362. % -------- global variables and procedures --------
  363. /boardsize  19 1 sub def  % default size of board - 1
  364. /unitlength 18 def    % unit length = 1/4 inch = 18/72 inch
  365. /unit { unitlength mul } bind def
  366. /inch { unitlength mul 4 mul } bind def
  367. /pagelength 11.7 inch def  % DIN A4 format % 2^(-1.75) m
  368. /pagewidth 8.25 inch def %  DIN A4 format % 2^(-2.25) m
  369. %remember:  1'' = 25.4mm = 0.0254 meter     1 meter  ~  39.37 inch
  370. % area of a DIN An sheet = 1/2^n m^2   , n ranges from 0, 1, 2, 3, ...
  371. % ratio of length to width of a DIN An sheey = sqrt(2) : 1
  372. % => divide a DIN An sheet in 2 DIN A(n+1) sheets by a horizontal central cut
  373. /xoff  6 unit def   % default x_offset
  374. /yoff 14 unit def   % default y_offset
  375. /factor  1.0 def    % default scale
  376. /ystart 24 unit def % historical set to 24 units artifically :-)
  377. /bottommargin 1 unit def % fine adjust to stay on the page
  378. /colwidth boardsize unit def % default colwidth
  379. /linewidth 0.5 def    % board grid linewidth
  380. /lineheight 1.0 def    % default linefeed
  381. /digits 3 def   % maximum number of character of marks
  382. /counter 0 def    % user move counter
  383. /caption 0 def  % default no board caption
  384. /kolines 1 def  % default one reserved line
  385. /autoredraw 1 def % default board redrawing on
  386. /markmode 0 def % default marker is black on white background
  387. /singlemove 0 def % default viewing off
  388. /pagec  1 def   % pagecounter
  389. /MoveC -1 def   % internal move counter
  390. /columns 1 def  % default only one column per page
  391. /intercolumns 2 unit def % space between columns
  392. /heading -1.0 def % default heading space must be negativ
  393. /headwidth  boardsize unit def  % default headwidth
  394. /headmargin 1 def % default  one main heading of multiple columns or pages
  395. /xshift 0 def % default no x shift of move coordinates
  396. /yshift 0 def % default no y shift of move coordinates
  397. /kostr1 (Move) def  % (Zug) () (Zet) % caption is language dependend
  398. /kostr2 (  at) def  % (auf) () ( op) % englisch, german, french, dutch, ...
  399. /koxstart  1.9 def  % x start position of reserved lines
  400. /koxincr   1.2 def
  401. /koystart -0.8 def  % y start position of reserved lines
  402. /comyincr  0.9 def
  403.  
  404. /ErrorMsg { % stack: (msg)
  405.   showpage
  406.   /Times-Roman findfont 20 scalefont setfont
  407.   0 100 moveto 0 setgray show
  408.   showpage
  409.   stop
  410. } bind def
  411.  
  412. /Pagewidth {  % stack: n1
  413.   dup 0 le 
  414.   { pop (pagewidth must be positiv) ErrorMsg } if
  415.   inch /pagewidth exch def } bind def
  416. /Pagelength {  % stack: n1
  417.   dup 0 le 
  418.   { pop (pagelength must be positiv) ErrorMsg } if
  419.   inch /pagelength exch def } bind def
  420. /Xoff {  % stack: n1
  421.   xoff add /xoff exch def } bind def
  422. /Yoff {  % stack: n1
  423.   neg yoff add /yoff exch def } bind def
  424. /Scale {  % stack: n1
  425.   dup 0.0 gt
  426.   { /factor exch def }
  427.   { pop (scale factor must be positiv) ErrorMsg } ifelse
  428. } bind def
  429.  
  430. /TopMargin { % stack: n1
  431.   inch /topmargin exch def
  432. % /yoff pagelength bottommargin sub topmargin sub factor ystart mul sub def
  433. } bind def
  434.  
  435. /BottomMargin { % stack: n1
  436.   inch /bottommargin exch def
  437. } bind def
  438.  
  439. /Size {  % stack: n1
  440.   dup dup floor ne { pop (size must be an integer) ErrorMsg } if
  441.   dup 1 gt
  442.   { 1 sub dup /boardsize exch def   % new board size
  443.     unit dup /headwidth exch def    % new head width
  444.     dup colwidth div /relf exch def % relative factor
  445.     /colwidth exch def              % new column width
  446.     userdict /rightmargin known     % if SetColumns used :
  447.     { 1.0 relf div
  448.       userdict /LM known { dup dup scale } if
  449.       userdict /RM known { /RM LM colwidth add def } if
  450.       factor mul /factor exch def
  451.       intercolumns relf mul /intercolumns exch def
  452.     } if
  453.     userdict /topmargin known       % if TopMargin used :
  454.     { /yoff pagelength bottommargin sub topmargin sub
  455.       factor ystart mul sub def
  456.     } if
  457.     userdict /Bottom known          % if Bottom used :
  458.     { Bottom relf mul /Bottom exch def } if
  459.     heading relf mul /heading exch def
  460.     userdict /headcol known     % if Heading used :
  461.     { headcol dup colwidth mul exch 1 sub intercolumns mul add
  462.       /headwidth exch def
  463.     } if
  464.   }
  465.   { pop (size must be greater 1) ErrorMsg } ifelse
  466. } bind def
  467.  
  468. /SetColumn { % stack: n1
  469.   dup 1 ge
  470.   { /columns exch def }
  471.   { pop (columns must be greater 0) ErrorMsg } ifelse
  472. } bind def
  473.  
  474. /SetColumns { % stack: n1 n2 n3 n4
  475.   inch /intercolumns exch def
  476.   inch /rightmargin exch def
  477.   inch /leftmargin exch def
  478.   dup 1 ge
  479.   { /columns exch def
  480.     /factor pagewidth leftmargin sub rightmargin sub
  481.     columns 1 sub intercolumns mul sub columns colwidth mul
  482.     div def
  483.     factor 0 le { (page to small for margins) ErrorMsg } if
  484.     /xoff leftmargin def
  485.     /intercolumns intercolumns factor div def
  486.   } { pop (columns must be greater 0) ErrorMsg } ifelse
  487. } bind def
  488.  
  489. /Initialize {
  490.   0 bottommargin translate    % bottom margin
  491.   userdict /topmargin known
  492.   { /yoff pagelength bottommargin sub topmargin sub
  493.     factor ystart mul sub def
  494.   } if                      % calculate yoff if topmargin is given
  495.   xoff yoff translate        % move the origin
  496.   factor factor scale        % set global scale
  497.   yoff factor div /Bottom exch neg def
  498.   /LM  0 def                % left margin for board and comments
  499.   /RM LM colwidth add def    % right margin for comments
  500.   /ypos ystart def   % y start
  501. } bind def
  502.  
  503. /TitleFont { 
  504.   /Times-Bold-Accent findfont 
  505.   25 lineheight mul scalefont setfont 
  506. } def
  507.  
  508. /PlayerFont { 
  509.   /Times-Bold-Accent findfont 
  510.   18 lineheight mul scalefont setfont 
  511. } def
  512.  
  513. /DescriFont { 
  514.   /Times-Roman-Symbol findfont 
  515.   15 lineheight mul scalefont setfont 
  516. } def
  517.  
  518. /sfs    % stone font size
  519. 1.8 digits 1 add div 0.1 add unit ceiling def
  520.  
  521. /StoneFont {
  522.   /Helvetica-Bold-Accent findfont 
  523.   sfs scalefont
  524.   setfont
  525. } def
  526.  
  527. /CommentFont { 
  528.   /Times-Italic-Symbol findfont 
  529.   sfs scalefont  setfont 
  530. } def
  531.  
  532. /Title {        % stack: (title)
  533.   TitleFont
  534.   dup stringwidth pop
  535.   headwidth sub -0.5 mul LM add
  536.   ypos moveto show
  537.   /ypos ypos lineheight unit 1.2 mul sub def
  538. } def
  539.  
  540. /BPlayer {        % stack: (bplayer)
  541.   PlayerFont
  542.   /Radius lineheight 0.4 mul def
  543.   dup stringwidth pop
  544.   headwidth sub -0.5 mul Radius unit add LM add
  545.   /xpos exch def xpos
  546.   ypos moveto show
  547.   1 setgray stroke
  548.   xpos Radius unit 1.5 mul sub ypos Radius unit 0.7 mul add
  549.   Radius unit 0 360 arc 0 setgray fill
  550.   /ypos ypos lineheight unit sub def
  551. } def
  552.  
  553. /WPlayer {        % stack: (wplayer)
  554.   PlayerFont
  555.   /Radius lineheight 0.4 mul def
  556.   dup stringwidth pop
  557.   headwidth sub -0.5 mul Radius unit add LM add
  558.   /xpos exch def xpos
  559.   ypos moveto show
  560.   0 setgray stroke
  561.   xpos Radius unit 1.5 mul sub ypos Radius unit 0.7 mul add
  562.   Radius unit 0 360 arc
  563.   gsave 1 setgray fill grestore 0 setgray stroke
  564.   /ypos ypos lineheight unit sub def
  565. } def
  566.  
  567. /Info {        % stack: (info)
  568.   DescriFont
  569.   dup stringwidth pop
  570.   headwidth sub -0.5 mul LM add
  571.   ypos moveto show
  572.   /ypos ypos lineheight unit sub def
  573. } def
  574.    
  575. /StoneRadius { unitlength 2.1 div } bind def   % stone radius
  576.  
  577. /W {            % stack: x y (s) 
  578.   /str exch def        % draw a white stone at x y with mark s at center
  579.   /my exch yshift sub def
  580.   /mx exch xshift sub def
  581.   kowhite 0 eq 
  582.   { my 1 ge my boardsize 1 add le and
  583.     { Moves MoveC [ mx my /WC ] put
  584.       /MoveC MoveC 1 add def
  585.     } if
  586.   }
  587.   { /kowhite 0 def
  588.   } ifelse
  589.   mx my
  590.   unit 1 unit sub /cy exch def
  591.   unit 1 unit sub /cx exch def
  592.   newpath
  593.   cx cy StoneRadius 0 360 arc 
  594.   gsave 1 setgray fill grestore 0 setgray stroke
  595.   /xp { cx str stringwidth pop 0.5 mul sub } bind def
  596.   /yp { cy sfs 0.325 mul sub} bind def
  597.   xp yp moveto str show
  598.   singlemove 0 ne
  599.   { copypage } if
  600. } bind def
  601.  
  602. /B {            % stack: x y (s)
  603.   /str exch def     % draw a black stone at x y with mark s at center
  604.   /my exch yshift sub def
  605.   /mx exch xshift sub def
  606.   kowhite 0 eq 
  607.   { my 1 ge my boardsize 1 add le and
  608.     { Moves MoveC [ mx my /BC ] put
  609.       /MoveC MoveC 1 add def
  610.     } if
  611.   }
  612.   { /kowhite 0 def
  613.     /ar Moves MoveC 1 sub get def
  614.     ar 2 /BC put
  615.     Moves MoveC 1 sub ar put
  616.   } ifelse
  617.   mx my
  618.   unit 1 unit sub  /cy exch def
  619.   unit 1 unit sub  /cx exch def
  620.   newpath
  621.   cx cy StoneRadius 0 360 arc 
  622.   0 setgray fill
  623.   /xp { cx str stringwidth pop 0.5 mul sub } bind def
  624.   /yp { cy sfs 0.325 mul sub} bind def
  625.   1 setgray xp yp moveto 
  626.   str show
  627.   singlemove 0 ne
  628.   { copypage } if
  629. } bind def
  630.  
  631. /Mark {            % stack: x y (s) 
  632.   /str exch def        % draw a mark s centered at x y
  633.   yshift sub 1 sub unit /cy exch def
  634.   xshift sub 1 sub unit /cx exch def
  635.   singlemove 0 eq
  636.   { markmode 0 eq
  637.     { newpath 1 setgray cx cy
  638.       StoneRadius 0.8 mul 0 360 arc fill stroke } if
  639.     /xp { cx str stringwidth pop 0.5 mul sub } bind def
  640.     /yp { cy sfs 0.325 mul sub} bind def
  641.     markmode 2 ne
  642.     { 0 setgray } { 1 setgray } ifelse
  643.     xp yp moveto str show
  644.   } if
  645. } bind def
  646.  
  647. /E {  /markmode 0 def Mark } bind def
  648. /EB { /markmode 1 def Mark } bind def
  649. /EW { /markmode 2 def Mark } bind def
  650.   
  651. /mr {unitlength 7 div} bind def    % radius of mark circle
  652. /SetMark            % stack: x y
  653.   { mr 0 360 arc fill } bind def    % set mark at 9 special points
  654.  
  655. /DrawGrid {
  656.   0 setgray
  657.   linewidth setlinewidth
  658. % vertical lines
  659.   newpath
  660.   0 1 unit boardsize unit
  661.   { 0 moveto 0 boardsize unit rlineto } for stroke
  662. % horizontal lines
  663.   newpath 
  664.   0 1 unit boardsize unit 
  665.   { 0 exch moveto boardsize unit 0 rlineto } for stroke
  666. % margin lines
  667.   linewidth 3 mul setlinewidth
  668.   newpath
  669.   0 0 moveto 0 boardsize unit lineto 
  670.   boardsize unit boardsize unit lineto
  671.   boardsize unit 0 lineto 0 0 lineto
  672.   closepath stroke
  673.   linewidth setlinewidth
  674. % mark handicap points
  675.   boardsize 7 ge
  676.   { /hpos boardsize 11 ge { 3 } { 2 } ifelse def
  677.     boardsize 2 mod 0 eq
  678.     { /hstep boardsize 2 div hpos sub def }
  679.     { /hstep boardsize hpos sub hpos sub def } ifelse
  680.     hpos hstep boardsize hpos sub
  681.     { unit hpos unit SetMark } for    % set marks
  682.     boardsize 2 mod 0 eq
  683.     { hpos hstep boardsize hpos sub
  684.       { unit boardsize 2 div unit SetMark} for
  685.     } if
  686.     hpos hstep boardsize hpos sub
  687.     { unit boardsize hpos sub unit SetMark} for
  688.   } if
  689. } bind def
  690.  
  691. /DrawCaption {
  692.   StoneFont
  693.   caption 0 ne
  694.   { 0 1 boardsize
  695.     { dup dup 9 ge
  696.       { (1) stringwidth pop neg -1 unit add }
  697.       { -1 unit } ifelse
  698.       exch unit
  699.       sfs 0.325 mul sub moveto
  700.       1 add /mark 2 string def
  701.       mark cvs show
  702.     } for
  703.     0 1 boardsize
  704.     { dup unit (I) stringwidth pop 0.5 mul sub
  705.       -1 unit moveto
  706.       65 add   % assume Ascii coding
  707.       dup 72 gt {1 add} if
  708.       /mark 1 string def
  709.       mark 0 3 -1 roll put mark show
  710.     } for
  711.   } if
  712. } def
  713.  
  714. /StartComment { } def  % upward compatiable (will be ommitted later)
  715.  
  716. /StartCom {
  717.   /RM LM colwidth add def        % right margin for comments
  718.   /lineheight comyincr unit def    % distance between lines of text
  719.   /ypos -2 unit def       % board lowleft y margin
  720.   /xpos LM def
  721.   singlemove 0 eq
  722.   { CommentFont
  723.     kolines -1 1
  724.     { pop
  725.       xpos ypos moveto
  726.       kostr1 show    
  727.       /ypos ypos lineheight sub def
  728.       xpos ypos moveto
  729.       kostr2 show
  730.       /ypos ypos lineheight sub def
  731.     } for
  732.     xpos ypos moveto
  733.     kolines 0 gt { Newline } if
  734.   } if
  735.   /kowhite 0 def % flag for Ko
  736.   /kox koxstart def
  737.   /koy koystart def
  738.   StoneFont
  739. } def
  740.  
  741. /DrawBoard {
  742.   /str exch def
  743.   heading 0 lt
  744.   { /heading ystart ypos sub def } if
  745.   ypos boardsize 0.5 add unit sub 
  746.   kolines lineheight mul sub
  747.   Bottom lt
  748.   { ColBreak } if
  749.   StoneFont
  750.   LM ypos boardsize 0.5 add unit sub moveto
  751.   currentpoint
  752.   dup neg Bottom add /Bottom exch def
  753.   translate  % set actuell position to origon
  754.   /LM  0 def      % left margin
  755.   DrawGrid
  756.   DrawCaption
  757. % redraw old moves
  758.   MoveC 0 gt
  759.   { /scr counter def
  760.     /counter -9999 def
  761.     /xsh xshift def  /xshift 0 def
  762.     /ysh yshift def  /yshift 0 def
  763.     Moves
  764.     { dup null eq {pop exit} if
  765.       aload pop
  766.       3 1 roll dup 3 -1 roll dup 4 1 roll
  767.       0 gt exch 0 gt and
  768.       { 3 -1 roll
  769.         cvx exec 
  770.       } if
  771.     } forall
  772.     /counter scr def
  773.     /xshift xsh def
  774.     /yshift ysh def
  775.   } if
  776.   CommentFont
  777. % 0.5 unit setlinewidth
  778.   str stringwidth pop
  779.   boardsize unit sub -0.5 mul % dup
  780. % -1 unit sfs 0.33 mul add moveto 1 setgray strlen 0 rlineto stroke
  781.   -1 unit moveto 0 setgray str show
  782. % linewidth setlinewidth
  783.   StartCom  % old StartComment must follow
  784. } def
  785.  
  786. /StartGame  % clears any previous stored moves
  787.  { StoneFont
  788.    /Moves boardsize 1 add dup mul    40 add   % hope it's enough
  789.    array def 
  790.    /MoveC 0 def
  791.  } def
  792.  
  793. % A text formater for printing comments
  794. /Newline {            % moveto begin of next line
  795.   /ypos ypos lineheight sub def
  796.   /xpos LM def
  797.   ypos Bottom lt
  798.   { pagec columns mod 0 ne
  799.     { /LM  RM intercolumns add def  % left margin for board and comments
  800.       /xpos LM def
  801.       /RM LM colwidth add def  % right margin for comments
  802.       /ypos yoff factor div Bottom add ystart add def  % y start
  803.       /pagec pagec 1 add def
  804.       headmargin 0 ne
  805.       { /ypos ypos heading sub def } if
  806.     }
  807.     { /oldfont currentfont def
  808.       PageBreak
  809.       oldfont setfont
  810.     } ifelse
  811.   } if
  812.   xpos ypos moveto
  813. } def        % move to next line
  814.  
  815. /Com {            % stack: str
  816.   CommentFont
  817.   xpos ypos moveto
  818.   /str exch def
  819.   str stringwidth pop
  820.   xpos add /xpos exch def 
  821.   xpos RM le    
  822.   { 0 setgray str show StoneFont }
  823.   { () str   % partition of input string on stack
  824.     str length -1 1 
  825.     { dup /index exch def 1 sub
  826.       1 getinterval dup stringwidth pop
  827.       xpos sub neg /xpos exch def
  828.       ( ) eq xpos RM le and
  829.       { pop str 0 index getinterval
  830.         str index str length index sub getinterval
  831.         exit
  832.       } if
  833.       str
  834.     } for 
  835.     exch dup () eq xpos LM le and
  836.     { pop (word too long) ErrorMsg } if % error: word widther than column width
  837.     0 setgray show
  838.     Newline
  839.     Com          % tail recursion
  840.   } ifelse
  841. } def
  842.  
  843. /Comment { Com } def  % upward compatiable (will be ommitted later)
  844.  
  845. /Ko {
  846.   /my exch def
  847.   /mx exch def
  848.   Moves MoveC [ mx my /WC ] put
  849.   MoveC 1 add /MoveC exch def
  850.   /kowhite 1 def
  851.   singlemove 0 ne
  852.   { mx my }
  853.   { kox koxincr add dup /kox exch def
  854.     kox boardsize 1 add gt
  855.     { /koy koy comyincr 2 mul sub def /kox koxstart koxincr add def } if
  856.     kox xshift add
  857.     koy yshift add
  858.   } ifelse
  859. } bind def
  860.  
  861. /At { kox xshift add koy yshift add comyincr sub } bind def
  862.  
  863. /WCMP { % stack: x y (s) 
  864.   /scratch exch def
  865.   Ko WC
  866.   At scratch E } def
  867.  
  868. /BCMP { % stack: x y (s) 
  869.   /scratch exch def
  870.   Ko BC
  871.   At scratch E } def
  872.  
  873. /SetC {  % stack: n1
  874.   /counter exch def } bind def
  875.  
  876. /SetCaption { /caption 1 caption sub def } bind def
  877.  
  878. /SetCharC { % stack: n1
  879.   /digits exch def
  880.   1.8 digits 1 add div 0.1 add unit ceiling 
  881.   /sfs exch def        % stone font size
  882. } bind def
  883.  
  884. /SetView { /singlemove 1 def } bind def
  885.  
  886. /ToggleRedraw { /autoredraw 1 autoredraw sub def } bind def
  887.  
  888. /Heading  {  %stack:  n1  n2  n3
  889.   dup dup 1 ne exch 0 ne and
  890.   { pop pop pop (last parameter of Heading must be 0 or 1) ErrorMsg } if
  891.   /headmargin exch def
  892.   /lineheight exch def
  893.   dup dup dup floor ne exch 1 lt or
  894.   { pop (the head width must be positive and integral number) ErrorMsg } if
  895.   dup /headcol exch def
  896.   dup colwidth mul exch 1 sub intercolumns mul add /headwidth exch def
  897.   0 setgray
  898. } bind def
  899.  
  900. /ToggleHead { /headmargin 1 headmargin sub def } bind def
  901.  
  902. /SetHead  { /lineheight exch def 0 setgray } bind def
  903.  
  904. /Movelines {  % stack : n1
  905.   /kolines exch def } bind def
  906.  
  907. /GetCounterAndPosition {
  908.   /len 1 def
  909.   counter 10 idiv
  910.   0 gt { /len len 1 add def } if
  911.   counter 100 idiv
  912.   0 gt { /len len 1 add def } if
  913.   counter 1000 idiv
  914.   0 gt { /len len 1 add def } if
  915.   /no len string def
  916.   counter no cvs 
  917.   /no exch def
  918.   /xp { cx no stringwidth pop 0.5 mul sub } bind def
  919.   /yp { cy sfs 0.325 mul sub} bind def
  920.   xp yp moveto 
  921. } bind def
  922.  
  923. /WC {            % stack: x y 
  924.   /my exch yshift sub def
  925.   /mx exch xshift sub def
  926.   counter -999 ge
  927.   { kowhite 0 eq 
  928.     { my 1 ge my boardsize 1 add le and
  929.       { Moves MoveC [ mx my /WC ] put
  930.         /MoveC MoveC 1 add def
  931.       } if
  932.     }
  933.     { /kowhite 0 def
  934.     } ifelse
  935.   } if
  936.   mx my
  937.   1 sub unit /cy exch def
  938.   1 sub unit /cx exch def
  939.   newpath
  940.   cx cy StoneRadius 0 360 arc 
  941.   gsave 1 setgray fill grestore 0 setgray stroke
  942.   /counter counter 1 add def
  943.   counter 0 gt
  944.   { GetCounterAndPosition
  945.     no show
  946.     singlemove 0 ne
  947.     { copypage } if
  948.   } if
  949. } bind def
  950.  
  951. /BC {            % stack: x y
  952.   /my exch yshift sub def
  953.   /mx exch xshift sub def
  954.   counter -999 ge
  955.   { kowhite 0 eq 
  956.     { my 1 ge my boardsize 1 add le and
  957.       { Moves MoveC [ mx my /BC ] put
  958.         /MoveC MoveC 1 add def
  959.       } if
  960.     }
  961.     { /kowhite 0 def
  962.       /ar Moves MoveC 1 sub get def
  963.       ar 2 /BC put
  964.       Moves MoveC 1 sub ar put
  965.     } ifelse
  966.   } if
  967.   mx my
  968.   1 sub unit /cy exch def
  969.   1 sub unit /cx exch def
  970.   newpath
  971.   cx cy StoneRadius 0 360 arc 
  972.   0 setgray fill
  973.   /counter counter 1 add def
  974.   counter 0 gt
  975.   { GetCounterAndPosition
  976.     1 setgray
  977.     no show
  978.     singlemove 0 ne
  979.     { copypage } if
  980.   } if
  981. } bind def
  982.  
  983. /WM {    
  984.   /cy ypos StoneRadius 0.35 mul add def
  985.   /cx xpos StoneRadius 1.1 mul add def
  986.   newpath
  987.   cx cy StoneRadius 0 360 arc 
  988.   gsave 1 setgray fill grestore 0 setgray stroke
  989.   /xpos xpos StoneRadius 2.5 mul add def
  990.   counter 0 gt
  991.   { GetCounterAndPosition
  992.     no show
  993.   } if
  994. } bind def
  995.  
  996. /BM {
  997.   /cy ypos StoneRadius 0.35 mul add def
  998.   /cx xpos StoneRadius 1.1 mul add def
  999.   newpath
  1000.   cx cy StoneRadius 0 360 arc 
  1001.   0 setgray fill
  1002.   /xpos xpos StoneRadius 2.5 mul add def
  1003.   counter 0 gt
  1004.   { GetCounterAndPosition
  1005.     1 setgray
  1006.     no show
  1007.   } if
  1008. } bind def
  1009.  
  1010. /WS {    
  1011.   /Radius StoneRadius 0.7 mul def
  1012.   /cy ypos Radius 0.4 mul add def
  1013.   /cx xpos Radius 1.1 mul add def
  1014.   newpath
  1015.   cx cy Radius 0 360 arc 
  1016.   gsave 1 setgray fill grestore 0 setgray stroke
  1017.   /xpos xpos Radius 2.5 mul add def
  1018. } bind def
  1019.  
  1020. /BS {
  1021.   /Radius StoneRadius 0.7 mul def
  1022.   /cy ypos Radius 0.4 mul add def
  1023.   /cx xpos Radius 1.1 mul add def
  1024.   newpath
  1025.   cx cy Radius 0 360 arc 
  1026.   0 setgray fill
  1027.   /xpos xpos Radius 2.5 mul add def
  1028. } bind def
  1029.  
  1030. /CBS { Com BS } bind def   % shortened form
  1031. /CWS { Com WS } bind def   % shortened form
  1032.  
  1033. /PageBreak {
  1034.   showpage
  1035.   Initialize
  1036.   headmargin 0 ne
  1037.   { /ypos ypos heading sub def } if
  1038.   /pagec pagec 1 add def
  1039.   autoredraw 0 ne { () DrawBoard } if
  1040. } def
  1041.  
  1042. /ColBreak { /ypos Bottom def Newline } def
  1043.  
  1044. /poppop { pop pop } bind def
  1045.  
  1046. /R {            % stack: x y     % remove a stone at x y if possible
  1047.   /my exch def
  1048.   /mx exch def
  1049.   /ind 0 def
  1050.   Moves
  1051.   { dup null eq {pop exit} if
  1052.     aload pop
  1053.     /poppop ne exch my eq and exch mx eq and
  1054.     { Moves ind [ mx my /poppop ] put
  1055.       singlemove 0 ne
  1056.       { my 1 sub unit /cy exch def
  1057.         mx 1 sub unit /cx exch def
  1058.         /lx mx 1 gt { 0.5 } { 0.0 } ifelse def
  1059.         /ly my 1 gt { 0.5 } { 0.0 } ifelse def
  1060.         /rx mx boardsize le { 0.5 } { 0.0 } ifelse def
  1061.         /uy my boardsize le { 0.5 } { 0.0 } ifelse def
  1062.         newpath
  1063.         1 setgray cx cy StoneRadius 0 360 arc fill stroke
  1064.         0 setgray
  1065.         cx lx unit sub cy moveto lx rx add unit 0 rlineto stroke
  1066.         cx cy ly unit sub moveto 0 ly uy add unit rlineto stroke
  1067.       } if
  1068.       exit
  1069.     } if
  1070.     /ind ind 1 add def
  1071.   } forall
  1072. } bind def
  1073.  
  1074. /DrawPart {   %stack:  n1 n2 m (cap)
  1075.   /str exch def
  1076.   /marg exch 15 xor def
  1077.   /my exch 1 sub def
  1078.   /mx exch 1 sub def
  1079.   heading 0 lt
  1080.   { /heading ystart ypos sub def } if
  1081. % mx 0 lt { return } if
  1082. % my 0 lt { return } if
  1083.   ypos my 0.5 add unit sub 
  1084.   Bottom lt
  1085.   { ColBreak } if
  1086.   /lx marg 1 and 0.5 mul def  % left margin
  1087.   /rx marg 2 and 0.25 mul def  % right margin
  1088.   /ly marg 4 and 0.125 mul def  % lower margin
  1089.   /uy marg 8 and 0.0625 mul def  % upper margin
  1090.   LM ypos my 0.5 add unit sub moveto
  1091.   currentpoint
  1092.   dup neg Bottom add /Bottom exch def
  1093.   translate  % set actuell position to origon
  1094.   /LM  0 def      % left margin
  1095.   0 setgray
  1096.   linewidth setlinewidth
  1097.   newpath
  1098.   0 1 unit mx unit
  1099.   { 0 ly sub unit moveto
  1100.     0 my uy add ly add unit rlineto } for stroke
  1101.   newpath 
  1102.   0 1 unit my unit 
  1103.   { 0 lx sub unit exch moveto
  1104.     mx rx add lx add unit 0 rlineto } for stroke
  1105.   linewidth 3 mul setlinewidth
  1106.   currentlinecap
  1107.   2 setlinecap
  1108.   lx 0.0 eq 
  1109.   { newpath 0 0 ly sub unit moveto
  1110.     0 my uy add ly add unit rlineto stroke } if
  1111.   rx 0.0 eq 
  1112.   { newpath mx unit 0 ly sub unit moveto
  1113.     0 my uy add ly add unit rlineto stroke } if
  1114.   ly 0.0 eq 
  1115.   { newpath 0 lx sub unit 0 moveto
  1116.     mx rx add lx add unit 0 rlineto stroke } if
  1117.   uy 0.0 eq 
  1118.   { newpath 0 lx sub unit my unit moveto
  1119.     mx rx add lx add unit 0 rlineto stroke } if
  1120.   setlinecap
  1121.   linewidth setlinewidth
  1122.   CommentFont
  1123.   str stringwidth pop
  1124.   mx unit sub -0.5 mul
  1125.   -1 unit moveto str show
  1126.   StartCom
  1127.   StoneFont
  1128. } def
  1129.  
  1130. /SetCoord { % stack:  x y
  1131.   /yshift exch def
  1132.   /xshift exch def
  1133. } bind def
  1134.  
  1135. % -------- Program 18 / Making Small Changes to Encoding Vectors
  1136. % -------- from   PostScript  Language  Tutorial and Cookbook
  1137. /reencsmalldict 12 dict def
  1138. /ReEncodeSmall     % --- 3 args:   the name of the existing font, the name of
  1139.                    %               the new font , an array of new characters
  1140.  { reencsmalldict begin
  1141.    /newcodesandnames exch def
  1142.    /newfontname exch def
  1143.    /basefontname exch def
  1144.    /basefontdict basefontname findfont def
  1145.    /newfont basefontdict maxlength 1 add dict def
  1146.    basefontdict
  1147.    { exch dup /FID ne
  1148.      { dup /Encoding eq
  1149.        { exch dup length array copy
  1150.          newfont 3 1 roll put }
  1151.        { exch newfont 3 1 roll put }
  1152.        ifelse
  1153.      }
  1154.      { pop pop }
  1155.      ifelse
  1156.    } forall
  1157.    newfont /FontName newfontname put
  1158.  
  1159.    newcodesandnames aload pop
  1160.    newcodesandnames length 2 idiv
  1161.    { newfont /Encoding get 3 1 roll put }
  1162.    repeat
  1163.  
  1164.    newfontname newfont definefont pop
  1165.    end
  1166.  } bind def
  1167.  
  1168. /accentvec[
  1169.  8#260 /Scaron      %scandinavy
  1170.  8#265 /scaron      %scandinavy
  1171.  8#276 /Agrave      %french
  1172.  8#300 /Oacute      %spain & scandy
  1173.  8#311 /Adieresis   %german & scandy
  1174.  8#314 /agrave      %french
  1175.  8#321 /oacute      %spain & scandy
  1176.  8#322 /Ugrave      %french
  1177.  8#323 /Uacute      %spain
  1178.  8#324 /ugrave      %french
  1179.  8#325 /uacute      %spain
  1180.  8#326 /Egrave      %french
  1181.  8#327 /egrave      %french
  1182.  8#330 /Edieresis   %french & scandy
  1183.  8#331 /adieresis   %german & scandy
  1184.  8#332 /edieresis   %french & scandy
  1185.  8#333 /Odieresis   %german & scandy
  1186.  8#334 /odieresis   %german & scandy
  1187.  8#335 /Udieresis   %german
  1188.  8#336 /udieresis   %german
  1189.  8#337 /ntilde      %spain
  1190.  8#340 /Aacute      %spain & scandy 
  1191.  8#342 /Aring       %scandinavy
  1192.  8#344 /Iacute      %spain
  1193.  8#345 /Idieresis   %french
  1194.  8#346 /idieresis   %french
  1195.  8#347 /Eacute      %french & spain
  1196.  8#354 /ecircumflex %french
  1197.  8#355 /acircumflex %french
  1198.  8#356 /icircumflex %french
  1199.  8#357 /ocircumflex %french
  1200.  8#360 /aacute      %spain & scandy
  1201.  8#362 /aring       %scandinavy
  1202.  8#363 /Ccedilla    %french
  1203.  8#364 /iacute      %spain
  1204.  8#366 /ccedilla    %french
  1205.  8#367 /eacute      %french & spain
  1206. %8#374 /openbullet
  1207. %8#375 /fillbullet
  1208. %8#376 /ahalf
  1209.  8#200 /ograve      %scandinavy
  1210.  8#201 /Ograve      %scandinavy
  1211.  8#202 /Zcaron      %scandinavy
  1212.  8#203 /zcaron      %scandinavy
  1213.  8#204 /Ydieresis   %turkey
  1214.  8#205 /ydieresis   %turkey
  1215. %8#373 /germandbls  %german
  1216. %8#261 /Oslash      %scandinavy
  1217. %8#270 /oslash      %scandinavy
  1218. %8#262 /OE          %scandinavy
  1219. %8#271 /oe          %scandinavy
  1220. %8#255 /AE          %scandinavy
  1221. %8#264 /ae          %scandinavy
  1222. %8#257 /Lslash      %poland    
  1223. %8#267 /lslash      %poland    
  1224. ]def
  1225. /Times-Italic /Times-Italic-Accent accentvec ReEncodeSmall
  1226. /Times-Bold /Times-Bold-Accent accentvec ReEncodeSmall
  1227. /Times-Roman /Times-Roman-Accent accentvec ReEncodeSmall
  1228. /Helvetica-Bold /Helvetica-Bold-Accent accentvec ReEncodeSmall 
  1229.  
  1230. % -------- Program 8.5.3 Spezialitaeten mit Userfonts
  1231. % -------- from   Programmieren mit PostScript / Wilfried Soeker / Vieweg
  1232. /NewFontSymbols {  % stack:  basefontname , newfontname, codingarray
  1233.   10 dict dup begin
  1234.   /FontType 3 def
  1235.   /FontMatrix [0.001 0 0 0.001 0 0 ] def
  1236.   /FontBBox [ 0 0 1000 1000 ] def
  1237.   /basefont 5 -1 roll findfont def
  1238.   /Encoding 256 array def
  1239.   0 1 255 {
  1240.     Encoding exch false put } for
  1241.   exch aload length 2 idiv
  1242.   { Encoding 3 1 roll put } repeat
  1243.  
  1244.   /BuildChar { %stack font, char
  1245.     exch begin
  1246.     basefont 1000 scalefont setfont
  1247.     dup Encoding exch get
  1248.     dup false eq
  1249.     { pop
  1250.       ( ) dup 0 4 -1 roll put
  1251.       dup stringwidth setcharwidth
  1252.       0 0 moveto show
  1253.     }
  1254.     { exch pop aload pop
  1255.       3 -1 roll (M) stringwidth 3 1 roll mul exch setcharwidth
  1256. %     exch aload pop setcachedevice
  1257.       0 0 moveto
  1258.       exec
  1259.       pop   % Bounding Box
  1260.     }
  1261.     ifelse
  1262.     end
  1263.     } bind def
  1264.   end
  1265.  
  1266.   definefont pop
  1267. } def
  1268.  
  1269. /openbullet
  1270. { gsave newpath
  1271.   380 300 400 0 360 arc
  1272.   closepath stroke grestore
  1273. } bind def
  1274.  
  1275. /fillbullet
  1276. { gsave newpath
  1277.   380 300 400 0 360 arc
  1278.   closepath fill stroke grestore
  1279. } bind def
  1280.  
  1281. /ahalf
  1282. { 5 dict begin
  1283.   /regularfont currentfont def
  1284.   /fractionfont currentfont [0.6 0 0 0.5 0 0] makefont def  % scaling 
  1285.   gsave
  1286.   newpath
  1287.   0 0 moveto
  1288.   (1) true charpath
  1289.   flattenpath pathbbox
  1290.   /height exch def pop pop pop
  1291.   (_) stringwidth pop 
  1292.   fractionfont setfont
  1293.   (1) stringwidth pop 
  1294.   sub 0.5 mul dup
  1295.     0.60 height mul moveto (1) show
  1296.     0.10 height mul neg moveto (2) show
  1297.   regularfont setfont
  1298.   0 0.65 height mul moveto (_) show
  1299.   grestore
  1300.   end
  1301. } def
  1302.  
  1303. /newsymbols
  1304. [
  1305.  8#374 [ 1.0 [ 0 0 1.0 1.0] { openbullet } ]
  1306.  8#375 [ 1.0 [ 0 0 1.0 1.0] { fillbullet } ]
  1307.  8#376 [ 0.6 [ 0 0 1.0 1.0] { ahalf } ]
  1308. ] def
  1309. /Times-Roman-Accent /Times-Roman-Symbol newsymbols NewFontSymbols
  1310. /Times-Italic-Accent /Times-Italic-Symbol newsymbols NewFontSymbols
  1311.  
  1312.  
  1313. % -------- Main Program --------
  1314. %  1.6 Scale   180 Yoff -60 Xoff  % as large as possible
  1315. %  1.2 Scale    10 Yoff           % my standard, if you want
  1316. %  0.9 Scale  -140 Yoff  50 Xoff  % 2 centered dia (1 Movelines possible)
  1317. %  0.85 Scale -170 Yoff  50 Xoff  % 2 centered dia (3 Movelines possible)
  1318. %  0.7 Scale  -220 Yoff -60 Xoff  2 SetColumn  % 2 column output
  1319. %  0.5 Scale  -290 Yoff -80 Xoff  3 SetColumn  % 3 column output
  1320. %  0.37 Scale -360 Yoff -80 Xoff  4 SetColumn  % 4 column output
  1321. %  0.31 Scale -390 Yoff -80 Xoff  5 SetColumn  % 5 column output
  1322. @EOF
  1323.  
  1324. chmod 644 layout/diagram.ps
  1325.  
  1326. echo x - layout/smart2ps.c
  1327. cat >layout/smart2ps.c <<'@EOF'
  1328. /**************************************************************************/
  1329. /*                                                                        */
  1330. /*    Author:  Achim Flammenkamp,  department of mathematics              */
  1331. /*             University of Bielefeld,  4800 Bielefeld 1 ,  Germany      */
  1332. /*                                                                        */
  1333. /*    Date:  11.8.1992       Time: 14:26 MEST         Version 3.6         */
  1334. /*      tested on:  ULTRIX V4.2 , HP-UX 8.07 , SunOS 4.1 , MS-DOS 5.0     */
  1335. /*                                                                        */
  1336. /*     Send comments or bug reports to  achim@hrz.uni-bielefeld.de        */
  1337. /*       You are free to use and distribute it noncommerical :-)          */
  1338. /*                                                                        */
  1339. /**************************************************************************/
  1340. #include <stdio.h>
  1341. #define  MAX    256   /* maximal linelength */
  1342. #define  SIZE    24   /* max boardsize + 1 */
  1343. #define  MPP   9999   /* huge step of pagebreaking (practical none) */
  1344. #define  NoCom    0   /* ignore comments during playing */
  1345. #define  NoPrison 0   /* specify whether there can't be ChangeStone[] */
  1346.  
  1347. /*************   c o m m a n d l i n e o p t i o n s   ********************/
  1348. /*                                                                        */
  1349. /*   #  sets the default pagebreak all # moves at least (default:  MPP )  */
  1350. /*  -c  toggles suppression of comments during playing  (default: FALSE)  */
  1351. /*  -r  toggles existing of Ranking-entries in SGF      (default: FALSE)  */
  1352. /*  -p  toggles existing of prisoner-entries in SGF     (default: FALSE)  */
  1353. /*  -x  mirrors movecoordinates at x-centerline         (default: FALSE)  */
  1354. /*  -y  mirrors movecoordinates at y-centerline         (default: FALSE)  */
  1355. /*  -i  ignores nonspecific infos above the board       (default: TRUE)   */
  1356. /*  -m  toggles prelude of comments by movesymbol       (default: FALSE)  */
  1357. /*  -s  toggles caption of board by coordinates         (default: TRUE)   */
  1358. /*  -v  toggles the previewing option (each move a page)(default: FALSE)  */
  1359. /*  -d  sets a new diagram after each move in the list following          */
  1360. /*  -l@ select the language of key words (@ is a digit)    (default: 0)   */
  1361. /*  -z  set move counter to zero each new diagram       (default: FALSE)  */
  1362. /*  -k@ set the number of 'reserved Movelines' to @     (default: 1)      */
  1363. /*  -?  shows legal options for this program and exits                    */
  1364. /*                                                                        */
  1365. /**************************************************************************/
  1366.  
  1367.  
  1368. char*  pscheck(buffer,len)
  1369. char  buffer[];
  1370. int  *len;
  1371. {
  1372. int  h, i, j=0;
  1373. char  octal[10];
  1374. sprintf(octal,"%.3o%.3o%.3o",(unsigned)')',(unsigned)'(',(unsigned)'\\');
  1375. for (i=0;buffer[i];i++)
  1376.    j += buffer[i] == '('  ||  buffer[i] == '\\'  ||  buffer[i] == ')' ;
  1377. j *=3;
  1378. *len += j;
  1379. for (h=i+1;buffer[h];h++);
  1380. for (;h>i;h--)
  1381.    buffer[h+j] = buffer[h];
  1382. j+=i;
  1383. for (;i>=0;i--,j--)
  1384.    if ((buffer[j] = buffer[i])== ')' )
  1385.    {  buffer[j--] = octal[2];
  1386.       buffer[j--] = octal[1];
  1387.       buffer[j--] = octal[0];
  1388.       buffer[j  ] = '\\';
  1389.    }
  1390.    else if ( buffer[i] == '(' )
  1391.    {  buffer[j--] = octal[5];
  1392.       buffer[j--] = octal[4];
  1393.       buffer[j--] = octal[3];
  1394.       buffer[j  ] = '\\';
  1395.    }
  1396.    else if ( buffer[i] == '\\' )
  1397.    {  buffer[j--] = octal[8];
  1398.       buffer[j--] = octal[7];
  1399.       buffer[j--] = octal[6];
  1400.       buffer[j  ] = '\\';
  1401.    }
  1402. return  buffer;
  1403. }
  1404.  
  1405.  
  1406. #define  MB   4
  1407. #define  MASK  ((1<<MB)-1)
  1408. #define  MARK (1<<(MB-1))
  1409. /*****  IMPORTANT: 0 != 'W'&(MARK-1) != 'B'&(MARK-1) != 0  *****/ 
  1410. /*****  there is at least space for 1<<(8*sizeof(int) - MB)  moves  ***/
  1411. /*****  assuming 8 bits per char in a binary coding ****/
  1412. static int  size=19, stno, remove_list[SIZE*SIZE], act_board[SIZE][SIZE],
  1413.             board[SIZE][SIZE], komi=0, handi=0, kono=0, lett=0, boardlett[26];
  1414. static int  xmirror=0, ymirror=0, movesperpage=0, ranking=0, nocomm=NoCom,
  1415.             noprison=NoPrison, igninfo=1, prelude=0, caption=1, preview=0,
  1416.             lastno=0, dialist[SIZE*SIZE], diano, dias=0, lang=0, zero=0, kol=1;
  1417. static char*  words[10][18];  /* english, german, french, dutch, ... */
  1418. static double  pagel, pagew, topm, bottomm, leftm, rightm, intercol,
  1419.                scale=1.0, headscale=1.0;
  1420. static int     cols=1, headwidth=1, hflag=1, matchtime=0;
  1421.  
  1422. move(x,y,z,no)
  1423. int  x, y, no;
  1424. char  *z;
  1425. {  int  i, p, q, old;
  1426.    char  mc = (z[0]!='(' ? z[0] : z[3] );
  1427.    if (no!=1 && no%movesperpage==1 || movesperpage==1  ||
  1428.        no==dialist[diano]+1)
  1429.    {  if (noprison)
  1430.          for (p=0;p<=size;p++)
  1431.             for (q=0;q<=size;q++)
  1432.                board[p][q]=act_board[p][q];
  1433.       lastno = no-1;
  1434.       if (zero)  printf("0 SetC\n");
  1435.       if (no==dialist[diano]+1)
  1436.          printf("() DrawBoard\n"),  diano++;
  1437.       else
  1438.          printf("PageBreak\n");
  1439.    }
  1440.    old = board[x][y]>>MB;
  1441.    if (x && y && !old)
  1442.    {  board[x][y] = (no<<MB) + (mc&MARK-1);
  1443.       printf("%2d %2d %s\n",x,y,z);
  1444.    }
  1445.    else
  1446.    {  kono++;
  1447.       if (!x && !y)   
  1448.          printf("%2d %2d (%s) %sMP\n",x,y,words[lang][17],z);
  1449.       else if (old > lastno)
  1450.          printf("%2d %2d (%d) %sMP\n",x,y,old,z);
  1451.       else 
  1452.       {  for (i=0;i<lett;i++)
  1453.             if (boardlett[i] == old)  break;
  1454.          printf("%2d %2d (%c) %sMP\n",x,y,'A'+i,z);
  1455.          if (i==lett)
  1456.          {  if (lett >= 26)  fprintf(stderr,"boardlett too small\n");
  1457.             else  boardlett[lett++] = old;
  1458.             printf("%2d %2d (%c) E%c\n",x,y,'A'+i,
  1459.                     ( (board[x][y]&MARK-1)==('W'&MARK-1) ? 'B' : 'W' ) );
  1460.          }
  1461.       }         
  1462.    }
  1463.    if (prelude)  prelude=(mc=='W'?-1:1);
  1464.    if (noprison)
  1465.    {  act_board[x][y] = (no<<MB) + (mc&MARK-1);
  1466.       check_for_prisoners(x,y);
  1467.    }
  1468.    return;
  1469. }
  1470.  
  1471. #define  getcoord   x = buffer[len]-'a'+1;   y = buffer[len+1]-'a'+1;  \
  1472.                     if (x==size+1 && y==size+1)   x=y=0;  /* PASS */  \
  1473.                     else if (x<=0 || x > size || y <= 0 || y > size)  \
  1474.                     fprintf(stderr,"invalid coords %s\n",buffer+len),x=y=0;\
  1475.                     else { if(xmirror) x=size+1-x; if(!ymirror) y=size+1-y; }
  1476. #define  makestring  incomm=getoption(buffer,&len); if (!incomm)  ignore=0;
  1477. #define  checkincomm  if(incomm){fprintf(stderr,"lines cut off:");ignore=1;}
  1478. #define  startboard   if (!commruns)  \
  1479.                       {  if (komi==1) printf("(Komi: \376"); \
  1480.                          else if (komi&1) printf("(Komi: %d \376",komi/2); \
  1481.                          else if (komi) printf("(Komi: %d", komi/2);      \
  1482.                          else if (handi) printf("(");  \
  1483.                          if (handi && komi) printf("       "); \
  1484.                          if (handi) printf("%s: %d",words[lang][10],handi); \
  1485.                          if (handi || komi) printf(") Info\n"); \
  1486.                          if (preview) printf("SetView\n");  \
  1487.                          if (caption)  printf("SetCaption\n");  \
  1488.                          printf("%d Movelines\n () DrawBoard\n",kol); \
  1489.                          commruns = 1; }
  1490. #define  start        startboard; if (!no) printf("StartGame\n"); \
  1491.                       if (!gameruns)  { if (startone) no=0; else no = !!no; \
  1492.                                       printf("%d SetC\n",no); gameruns=1; }
  1493.  
  1494. getoption(buffer,len)
  1495. char  buffer[];
  1496. int  *len;
  1497. {  int i, j= *len, ret;
  1498.    for(i=j;buffer[i]&&buffer[i]!=']'&&buffer[i]!='\n'; i++)
  1499.        buffer[i-j]=buffer[i];
  1500.    ret = (buffer[i]!=']');
  1501.    buffer[i-j]='\000';
  1502.    if (buffer[i])
  1503.       for (i++;buffer[i-j]=buffer[i];i++);
  1504.    else
  1505.       buffer[i-j+1]='\000';
  1506.    *len=i-j;
  1507.    return (ret);
  1508. }
  1509.  
  1510. static char  item[10];
  1511.  
  1512. int scan_into_item(string,len)
  1513. char  string[];
  1514. int  *len;
  1515. {
  1516.    int  i;
  1517.    for(i=0;string[*len] && string[*len]!='[' ;(*len)++)
  1518.       if (string[*len] >= 'A' && string[*len] <= 'Z' && i<10)
  1519.          item[i++] = string[*len];
  1520.    if (string[*len]=='[')  (*len)++;
  1521.    item[i]='\000';
  1522.    return i;
  1523. }
  1524.  
  1525. int is_item(entry)
  1526. char *entry;
  1527. {
  1528.    int  i;
  1529.    for(i=0; *(entry+i) == item[i] ; i++)
  1530.       if (!item[i])  return  1;
  1531.    return 0;
  1532. }
  1533.  
  1534.                       
  1535.  
  1536. main(argc,argv)
  1537. int  argc;
  1538. char* argv[];
  1539. {
  1540.  
  1541. int  i, x, y, len, no=0;
  1542. unsigned  gameruns = 0, commruns = 0,  incomm = 0,  ignore=0,  header=1,
  1543.           startone = 0;
  1544. char  buffer[4*MAX], bname[MAX/2], wname[MAX/2];
  1545. words[0][0] = "Black";
  1546. words[0][1] = "White";
  1547. words[0][2] = "Date";
  1548. words[0][3] = "Place";
  1549. words[0][4] = "Result";
  1550. words[0][5] = "wins";
  1551. words[0][6] = "loses";
  1552. words[0][7] = "resignation";
  1553. words[0][8] = "points";
  1554. words[0][9] = "Timelimit";
  1555. words[0][10] = "Handicap";
  1556. words[0][11] = "Source";
  1557. words[0][12] = "by";
  1558. words[0][13] = "by";
  1559. words[0][14] = "on";
  1560. words[0][15] = "time";
  1561. words[0][16] = "Tie";
  1562. words[0][17] = "pass";
  1563. words[1][0] = "Schwarz";
  1564. words[1][1] = "Wei\373";
  1565. words[1][2] = "Datum";
  1566. words[1][3] = "Ort";
  1567. words[1][4] = "Ergebnis";
  1568. words[1][5] = "gewinnt";
  1569. words[1][6] = "verliert";
  1570. words[1][7] = "Aufgabe";
  1571. words[1][8] = "Punkten";
  1572. words[1][9] = "Bedenkzeit";
  1573. words[1][10] = "Vorgabe";
  1574. words[1][11] = "Quelle";
  1575. words[1][12] = "mit";
  1576. words[1][13] = "durch";
  1577. words[1][14] = "auf";
  1578. words[1][15] = "Zeit";
  1579. words[1][16] = "Unentschieden";
  1580. words[1][17] = "pa\373t";
  1581. words[2][0] = "Noir";
  1582. words[2][1] = "Blanc";
  1583. words[2][2] = "Date";
  1584. words[2][3] = "Lieu";
  1585. words[2][4] = "R\367sultat";
  1586. words[2][5] = "gagne";
  1587. words[2][6] = "perd";
  1588. words[2][7] = "abandon";
  1589. words[2][8] = "points";
  1590. words[2][9] = "Temps de restant";
  1591. words[2][10] = "Handicap";
  1592. words[2][11] = "Source";
  1593. words[2][12] = "avec";
  1594. words[2][13] = "par";
  1595. words[2][14] = "par manque de";
  1596. words[2][15] = "temps";
  1597. words[2][16] = "Partie nulle";
  1598. words[2][17] = "passe";
  1599. words[3][0] = "Zwart";
  1600. words[3][1] = "Wit";
  1601. words[3][2] = "Datum";
  1602. words[3][3] = "Plaats";  /* Oord */
  1603. words[3][4] = "Resultaat";
  1604. words[3][5] = "wint";
  1605. words[3][6] = "verliest";
  1606. words[3][7] = "opgave";
  1607. words[3][8] = "punten";
  1608. words[3][9] = "Bedenktijd";
  1609. words[3][10] = "Voorgift";
  1610. words[3][11] = "Bron";
  1611. words[3][12] = "met";
  1612. words[3][13] = "door";
  1613. words[3][14] = "op";
  1614. words[3][15] = "tijd";
  1615. words[3][16] = "Gelijk spel";
  1616. words[3][17] = "past";
  1617. for (lang=4;lang<10;lang++)
  1618. for (i=0;i<18;i++)
  1619.    words[lang][i] = "";
  1620. lang=0;
  1621. for (len=1;len<argc;len++)
  1622. {   if (*argv[len] == '-')
  1623.     {  i=0;
  1624.        while( *(argv[len]+ ++i) )
  1625.        {  switch (*(argv[len]+i) )
  1626.           {
  1627.              case 'c':  nocomm^=1;   break;
  1628.              case 'r':  ranking^=1;  break;
  1629.              case 'p':  noprison^=1; break;
  1630.              case 'x':  xmirror^=1;  break;
  1631.              case 'y':  ymirror^=1;  break;
  1632.              case 'i':  igninfo^=1;  break;
  1633.              case 'm':  prelude^=1;  break;
  1634.              case 's':  caption^=1;  break;
  1635.              case 'v':  preview^=1;  break;
  1636.              case 'd':  do {
  1637.                            int  h;  i++;
  1638.                            sscanf(argv[len]+i,"%u%n",&dialist[dias],&h);
  1639.                            if (dialist[dias] <= 0)
  1640.                               fprintf(stderr,
  1641.                                       "invalid numbers in diagram list: %s\n",
  1642.                                       argv[len]+i);
  1643.                            else if (dias && dialist[dias-1] >= dialist[dias])
  1644.                               fprintf(stderr,
  1645.                                   "numbers in diagram list must increase\n");
  1646.                            else
  1647.                               dias++;
  1648.                            i += h;
  1649.                         } while( *(argv[len]+i) == ',' );
  1650.                         i--;
  1651.                         break;
  1652.              case 'l':  {  int  h;  i++;
  1653.                            if (1!=sscanf(argv[len]+i,"%u%n",&lang,&h) || 
  1654.                                lang >= 4)
  1655.                            fprintf(stderr,"invalid digit in language code\n");
  1656.                            i += h-1;
  1657.                            break;
  1658.                         }
  1659.              case 'k':  {  int  h;  i++;
  1660.                            if (1!=sscanf(argv[len]+i,"%u%n",&kol,&h) )
  1661.                            fprintf(stderr,"invalid digit in no of reserved lines\n");
  1662.                            i += h-1;
  1663.                            break;
  1664.                         }
  1665.              case 'z':  zero^=1;  break;
  1666.              case 'L':  {  int  h;  i++;
  1667.                            if (1!=sscanf(argv[len]+i,"%lf%n",&pagel,&h) )
  1668.                            fprintf(stderr,"invalid value in pagelength\n");
  1669.                            i += h-1;
  1670.                            break;
  1671.                         }
  1672.              case 'W':  {  int  h;  i++;
  1673.                            if (1!=sscanf(argv[len]+i,"%lf%n",&pagew,&h) )
  1674.                            fprintf(stderr,"invalid value in pagwwidth\n");
  1675.                            i += h-1;
  1676.                            break;
  1677.                         }
  1678.              case 'T':  {  int  h;  i++;
  1679.                            if (1!=sscanf(argv[len]+i,"%lf%n",&topm,&h) )
  1680.                            fprintf(stderr,"invalid value in topmargin\n");
  1681.                            i += h-1;
  1682.                            break;
  1683.                         }
  1684.              case 'M':  {  int  h;  i++;
  1685.                            if (1!=sscanf(argv[len]+i,"%lf%n",&leftm,&h) )
  1686.                            fprintf(stderr,"invalid value in leftmargin\n");
  1687.                            i += h-1;
  1688.                            break;
  1689.                         }
  1690.              case 'R':  {  int  h;  i++;
  1691.                            if (1!=sscanf(argv[len]+i,"%lf%n",&rightm,&h) )
  1692.                            fprintf(stderr,"invalid value in leftmargin\n");
  1693.                            i += h-1;
  1694.                            break;
  1695.                         }
  1696.              case 'S':  {  int  h;  i++;
  1697.                            if (1!=sscanf(argv[len]+i,"%lf%n",&scale,&h) )
  1698.                            fprintf(stderr,"invalid value in scale factor\n");
  1699.                            i += h-1;
  1700.                            break;
  1701.                         }
  1702.              case 'I':  {  int  h;  i++;
  1703.                            if (1!=sscanf(argv[len]+i,"%lf%n",&intercol,&h) )
  1704.                            fprintf(stderr,"invalid value in inter col space\n");
  1705.                            i += h-1;
  1706.                            break;
  1707.                         }
  1708.              case 'C':  {  int  h;  i++;
  1709.                            if (1!=sscanf(argv[len]+i,"%u%n",&cols,&h) )
  1710.                            fprintf(stderr,"invalid value in columns\n");
  1711.                            i += h-1;
  1712.                            break;
  1713.                         }
  1714.              case 'B':  {  int  h;  i++;
  1715.                            if (1!=sscanf(argv[len]+i,"%lf%n",&bottomm,&h) )
  1716.                            fprintf(stderr,"invalid value in bottom margin\n");
  1717.                            i += h-1;
  1718.                            break;
  1719.                         }
  1720.              case 'H':  {  int  h;  i++;
  1721.                            if (1!=sscanf(argv[len]+i,"%lf%n",&headscale,&h) )
  1722.                            fprintf(stderr,"invalid value in head scale\n");
  1723.                            i += h-1;
  1724.                            break;
  1725.                         }
  1726.              case 'h':  hflag^=1;  break;
  1727.              case 'J':  {  int  h;  i++;
  1728.                            if (1!=sscanf(argv[len]+i,"%u%n",&headwidth,&h) )
  1729.                            fprintf(stderr,"invalid value in head width\n");
  1730.                            i += h-1;
  1731.                            break;
  1732.                         }
  1733.  default:   fprintf(stderr,"unknown option: %s\n", argv[len]+i);
  1734.  case '?':  fprintf(stderr,"version 3.6: usage: %s ",argv[0]);
  1735.             fprintf(stderr,"[# -c -r -p -x -y -i -m -s -dLIST -v -l@ -k@ -z -?");
  1736.             fprintf(stderr," -L -W -T -M -R -S -I -C -B -H -h -J]\n");
  1737.                         exit(0);
  1738.           }
  1739.        }
  1740.     }
  1741.     else if (*argv[len] >= '0' && *argv[len] <= '9')
  1742.        sscanf(argv[len],"%d",&movesperpage); 
  1743.     else
  1744.        fprintf(stderr,"ignored option: %s\n",argv[len]);
  1745. }
  1746. diano = 0;
  1747. dialist[dias] = MPP;
  1748. for (x=0;x<SIZE;x++)
  1749. for (y=0;y<SIZE;y++)
  1750.    board[x][y] = act_board[x][y] = 0;
  1751. if (!movesperpage)  movesperpage=MPP;
  1752. buffer[len=0]='\0';
  1753. while( buffer[len] || (len=0, fgets(buffer,MAX-1,stdin)) )
  1754. { if (incomm || ignore)
  1755.    {  int  oldign=ignore;
  1756.       makestring;
  1757.       if (oldign)
  1758.          /** fprintf(stderr,"%s\n",buffer) **/ ;
  1759.       else if (buffer[0]  &&  (commruns || !igninfo))
  1760.          printf("(%s)  %s\n",pscheck(buffer,&len), (commruns?"Com":"Info"));
  1761.       if (!oldign && commruns)  printf("Newline\n");
  1762.       continue;
  1763.    }
  1764.    else
  1765.       for( ;buffer[len]; len++)
  1766.          if (buffer[len] > ' ')
  1767.          {  if (header)
  1768.             {  if (buffer[len] != '(' || buffer[len+1] != '\n')  continue;
  1769.                header=0;
  1770.                printf("%% ---------- begin of game record ---------\n");
  1771.                if (pagel)
  1772.                   printf("%lf Pagelength\n", pagel);
  1773.                if (pagew)
  1774.                   printf("%lf Pagewidth\n", pagew);
  1775.                if (leftm || rightm || intercol)
  1776.                   printf("%d %.3lf %.3lf %.3lf SetColumns\n",cols,leftm, rightm, intercol);
  1777.                else if (cols != 1)
  1778.                   printf("%d SetColumn\n",cols);
  1779.                if (topm)
  1780.                   printf("%.3lf TopMargin\n", topm);
  1781.                if (bottomm)
  1782.                   printf("%.3lf BottomMargin\n", bottomm);
  1783.                if (scale != 1.0)
  1784.                   printf("%lf Scale\n", scale);
  1785.                if (headscale != 1.0 || headwidth != 1)
  1786.                   printf("%d %.3lf %d Heading\n",headwidth,headscale,hflag);
  1787.                printf("Initialize\n");
  1788.             }
  1789.             else if (buffer[len] == ';') {}
  1790.             else if (buffer[len] == '(') {}
  1791.             else if (buffer[len] == ')') {}
  1792.             else  break;
  1793.          }
  1794.    if (buffer[len] == '[')
  1795.    {  incomm=1;  continue;
  1796.    }
  1797.    else if (!scan_into_item(buffer,&len))
  1798.    {}
  1799.    else if (is_item("W"))
  1800.    {  start;  no++;  getcoord;   move(x,y,"WC",no);  len+=3;  }
  1801.    else if (is_item("B"))
  1802.    {  start;  no++;  getcoord;   move(x,y,"BC",no);  len+=3;  }
  1803.    else if (is_item("C"))
  1804.    {  makestring;
  1805.       if (nocomm)
  1806.       { if (incomm)  ignore=1; }
  1807.       else 
  1808.       {  if (prelude && commruns)
  1809.             printf("%s ",(prelude==1?"BM":"WM"));
  1810.          if (buffer[0]  &&  (commruns || !igninfo))
  1811.             printf("(%s) %s\n",pscheck(buffer,&len), (commruns?"Com":"Info"));
  1812.       }
  1813.    }
  1814.    else if (is_item("SZ"))
  1815.    {  char  del[2];
  1816.       sscanf(buffer+len,"%d%1s%n",&size,del,&i);
  1817.       if (size >= SIZE)  return( fprintf(stderr,"SIZE too small\n") ); 
  1818.       len +=i;
  1819.    }
  1820.    else if (is_item("EV") || is_item("E"))
  1821.    {  printf(" %d Size\n  -999  SetC\n",size);
  1822.       makestring;  printf("  (%s)  Title\n",buffer);  checkincomm;
  1823.    }
  1824.    else if (is_item("DT"))
  1825.    {  makestring;   printf("  (%s: %s)  Info\n",words[lang][2],buffer);
  1826.       checkincomm;
  1827.    }
  1828.    else if (is_item("PC"))
  1829.    {  makestring;   printf("  (%s: %s)  Info\n",words[lang][3],buffer);
  1830.       checkincomm;
  1831.    }
  1832.    else if (is_item("BS"))
  1833.    {  makestring;
  1834.       printf("  (%s)  BPlayer\n",buffer);
  1835.       checkincomm;
  1836.    }
  1837.    else if (is_item("WS"))
  1838.    {  makestring;
  1839.       printf("  (%s)  WPlayer\n",buffer);
  1840.       checkincomm;
  1841.    }
  1842.    else if (is_item("PB"))
  1843.    {  makestring;
  1844.       if (ranking)
  1845.          for (i=0;bname[i]= *(buffer+i);i++) ;
  1846.       else
  1847.          printf("  (%s)  BPlayer\n",buffer);
  1848.       checkincomm;
  1849.    }
  1850.    else if (is_item("PW"))
  1851.    {  makestring; 
  1852.       if (ranking)
  1853.          for (i=0;wname[i]= *(buffer+i);i++) ;
  1854.       else
  1855.          printf("  (%s)  WPlayer\n",buffer);
  1856.       checkincomm;
  1857.    }
  1858.    else if (is_item("RE"))
  1859.    {  double  pkt;  makestring;
  1860.       if ((buffer[0]=='W' || buffer[0]=='B') &&
  1861.           (buffer[1]=='+' || buffer[1]=='-') )
  1862.       {  printf("  (%s: %s %s ", words[lang][4],
  1863.                 (buffer[0]=='B'?words[lang][0]:words[lang][1]),
  1864.                 (buffer[1]=='+'?words[lang][5]:words[lang][6]) );
  1865.          if ( !strcmp(buffer+2,"resign") || !strcmp(buffer+2,"Resign") )
  1866.             printf("%s %s)  Info\n", words[lang][13], words[lang][7] );
  1867.          else if ( !strcmp(buffer+2,"time") || !strcmp(buffer+2,"Time") )
  1868.             printf("%s %s)  Info\n", words[lang][14], words[lang][15] );
  1869.          else if (1==sscanf(buffer+2,"%lf%n",&pkt,&i) && !buffer[2+i] )
  1870.             printf("%s %s %s)  Info\n",words[lang][12],buffer+2,words[lang][8]);
  1871.          else if (buffer[2])
  1872.             printf("%s %s)  Info\n", words[lang][13], buffer+2);
  1873.          else  printf(")  Info\n");
  1874.       }
  1875.       else if ((buffer[0]=='0' || buffer[0]=='=') && buffer[1]=='\0' )
  1876.          printf("  (%s: %s)  Info\n",words[lang][4],words[lang][16]);
  1877.       else 
  1878.          printf("  (%s: %s)  Info\n",words[lang][4],buffer);
  1879.       checkincomm;
  1880.    }
  1881.    else if (is_item("US"))
  1882.    {  makestring;   printf("  (%s)  Info\n",buffer);
  1883.       checkincomm;
  1884.    }
  1885.    else if (is_item("GC"))
  1886.    {  makestring;   printf("  (%s)  Info\n",buffer);
  1887.       checkincomm;
  1888.    }
  1889.    else if (is_item("BL"))
  1890.    {  if (!matchtime && !commruns)
  1891.       {  char  del[2];  int  matchsec;
  1892.          sscanf(buffer+len,"%d%1s%n",&matchsec,del,&i);
  1893.          len +=i;
  1894.          if (matchsec)
  1895.          {  matchtime=1;
  1896.             printf("  (%s: %d min)  Info\n",words[lang][9],(matchsec+30)/60);
  1897.          }
  1898.       }
  1899.    }
  1900.    else if (is_item("WL"))
  1901.    {  if (!matchtime && !commruns)
  1902.       {  char  del[2];  int  matchsec;
  1903.          sscanf(buffer+len,"%d%1s%n",&matchsec,del,&i);
  1904.          len +=i;
  1905.          if (matchsec)
  1906.          {  matchtime=1;
  1907.             printf("  (%s: %d min)  Info\n",words[lang][9],(matchsec+30)/60);
  1908.          }
  1909.       }
  1910.    }
  1911.    else if (is_item("TM"))
  1912.    {  makestring;
  1913.       printf("  (%s: %s)  Info\n",words[lang][9],buffer);
  1914.       matchtime = 1;
  1915.       checkincomm;
  1916.    }
  1917.    else if (is_item("BR"))
  1918.    {  makestring;
  1919.       if (ranking)
  1920.          printf("  (%s, %s)  BPlayer\n",bname,buffer);
  1921.       checkincomm;
  1922.    }
  1923.    else if (is_item("WR"))
  1924.    {  makestring;
  1925.       if (ranking)
  1926.          printf("  (%s, %s)  WPlayer\n",wname,buffer);
  1927.       checkincomm;
  1928.    }
  1929.    else if (is_item("KM"))
  1930.    {  double  v;  char  del[2];
  1931.       sscanf(buffer+len,"%lf%1s%n",&v,del,&i);
  1932.       komi = (int)(v<0?2*v-0.5:2*v+0.5);
  1933.       len +=i;
  1934.    }
  1935.    else if (is_item("HA"))
  1936.    {  char  del[2];
  1937.       sscanf(buffer+len,"%d%1s%n",&handi,del,&i);
  1938.       len +=i;
  1939.    }
  1940.    else if (is_item("AB"))
  1941.    {  startboard;
  1942.       if (!no) printf("StartGame\n");
  1943.       do { no--; getcoord;  move(x,y,"() B",no); len+=3; }
  1944.       while(buffer[len++]=='[');
  1945.       len--;
  1946.    }
  1947.    else if (is_item("AW"))
  1948.    {  startboard;
  1949.       if (!no) printf("StartGame\n");
  1950.       do { no--; getcoord;  move(x,y,"() W",no); len+=3; }
  1951.       while(buffer[len++]=='[');
  1952.       len--;
  1953.       startone = 1;
  1954.    }
  1955.    else if (is_item("PL"))
  1956.    {  makestring;
  1957.       printf("  (%s to move) %s\n",buffer,(commruns?"Com Newline":"Info"));
  1958.    }
  1959.    else if (is_item("SO"))
  1960.    {  makestring;   printf("  (%s: %s)  Info\n",words[lang][11],buffer);
  1961.       checkincomm;
  1962.    }
  1963.    else if (is_item("CS"))  /* ChangeStone[] game dependend */
  1964.    {  do { getcoord;  printf("%2d %2d R\n",x,y); len+=3; }
  1965.       while(buffer[len++]=='[');
  1966.       len--;
  1967.    }
  1968.    else if (is_item("GM"))
  1969.    {  int  h;  char  del[2];
  1970.       sscanf(buffer+len,"%d%1s%n",&h,del,&i);
  1971.       if (h != 1)  return( fprintf(stderr,"This game is not Go!\n") ); 
  1972.       len +=i;
  1973.    }
  1974.    else if (is_item("L"))
  1975.    {  i=0;
  1976.       do { getcoord; printf("%2d %2d (%c) E\n",x,y,'A'+ i++); len+=3; }
  1977.       while(buffer[len++]=='[');
  1978.       len--;
  1979.    }
  1980.    else if (is_item("FG"))
  1981.    {  makestring;
  1982.       printf("PageBreak\n");
  1983.       checkincomm;
  1984.    }
  1985.    else if (is_item("VW"))
  1986.    {  if (buffer[len] != ']')
  1987.       {  int  h1, h2;
  1988.          getcoord;
  1989.          h1=x;  h2=y;  len+=4;
  1990.          getcoord;
  1991.          i=0;
  1992.          if (h1==1  || x==1)   i |= 1;
  1993.          if (h1==size  || x==size)   i |= 2;
  1994.          if (h2==1  || y==1)   i |= 4;
  1995.          if (h2==size  || y==size)   i |= 8;
  1996.          printf("%2d %2d %d () DrawPart\n",abs(x-h1),abs(y-h2),i);
  1997.          printf("%2d %2d SetCoord\n",(x<h1?x:h1),(y<h2?y:h2));
  1998.          len+=3;
  1999.       }
  2000.       else
  2001.          len++;
  2002.    }
  2003.    else if (is_item("N")) { makestring; checkincomm; }
  2004.    else if (is_item("V")) { makestring; checkincomm; }
  2005.    else if (is_item("CH")) { makestring; checkincomm; }
  2006.    else if (is_item("GB")) { makestring; checkincomm; }
  2007.    else if (is_item("GW")) { makestring; checkincomm; }
  2008.    else if (is_item("TE")) { makestring; checkincomm; }
  2009.    else if (is_item("BM")) { makestring; checkincomm; }
  2010.    else if (is_item("AE")) { makestring; checkincomm; }
  2011.    else if (is_item("GN")) { makestring; checkincomm; }
  2012.    else if (is_item("RO")) { makestring; checkincomm; }
  2013.    else if (is_item("EL")) { makestring; checkincomm; }
  2014.    else if (is_item("EX")) { makestring; checkincomm; }
  2015.    else if (is_item("SL")) { makestring; checkincomm; }
  2016.    else if (is_item("M")) { makestring; checkincomm; }
  2017.    else if (is_item("TB")) { makestring; checkincomm; }
  2018.    else if (is_item("TW")) { makestring; checkincomm; }
  2019.    else if (is_item("SC")) { makestring; checkincomm; }
  2020.    else if (is_item("RG")) { makestring; checkincomm; }
  2021.    else
  2022.       fprintf(stderr,"unknown property: %s  at>%s\n",item,buffer);
  2023. }   
  2024. if (!header)
  2025. {  printf("%% --------- end of game record ---------\n");
  2026.    i = (size - 1.9) / 1.2;
  2027.    printf("%% (%d moves)  Info\n%% %d Movelines\n",no, (kono+i-1)/i);
  2028.    printf("showpage\n");
  2029. }
  2030. }
  2031.  
  2032.  
  2033.  
  2034. check_for_prisoners(x,y)
  2035. int  x, y;
  2036. {   unsigned char  type, stone, other;
  2037.     int  i, rx, ry, sum=0;
  2038.     if ( !('W'&MARK-1) || !('B'&MARK-1) || ('W'&MARK-1)==('B'&MARK-1) )
  2039.     return(  fprintf(stderr,"Coding Error: increase MB\n"), 0 );
  2040.     type=act_board[x][y]&MASK;
  2041.     other = (type==('B'&MARK-1)?'W'&MARK-1:'B'&MARK-1);
  2042.     stno=0;
  2043.     if (x > 1 && (stone=act_board[x-1][y]&MASK) && stone==other &&
  2044.         !count_liberties(x-1,y,stone) )  sum += remove_stones();
  2045.     for (i=0;i<stno;i++)
  2046.     { rx=remove_list[i]%size + 1;
  2047.       ry=remove_list[i]/size + 1;
  2048.       act_board[rx][ry] &= ~MARK;
  2049.     }
  2050.     stno=0;
  2051.     if (x < size && (stone=act_board[x+1][y]&MASK) && stone==other &&
  2052.         !count_liberties(x+1,y,stone) )  sum += remove_stones();
  2053.     for (i=0;i<stno;i++)
  2054.     { rx=remove_list[i]%size + 1;
  2055.       ry=remove_list[i]/size + 1;
  2056.       act_board[rx][ry] &= ~MARK;
  2057.     }
  2058.     stno=0;
  2059.     if (y > 1 && (stone=act_board[x][y-1]&MASK) && stone==other &&
  2060.         !count_liberties(x,y-1,stone) )  sum += remove_stones();
  2061.     for (i=0;i<stno;i++)
  2062.     { rx=remove_list[i]%size + 1;
  2063.       ry=remove_list[i]/size + 1;
  2064.       act_board[rx][ry] &= ~MARK;
  2065.     }
  2066.     stno=0;
  2067.     if (y < size && (stone=act_board[x][y+1]&MASK) && stone==other &&
  2068.         !count_liberties(x,y+1,stone) )  sum += remove_stones();
  2069.     for (i=0;i<stno;i++)
  2070.     { rx=remove_list[i]%size + 1;
  2071.       ry=remove_list[i]/size + 1;
  2072.       act_board[rx][ry] &= ~MARK;
  2073.     }
  2074.     stno=0;
  2075.     if (!count_liberties(x,y,type) )  sum -= remove_stones();  /* sucide */
  2076.     for (i=0;i<stno;i++)
  2077.     { rx=remove_list[i]%size + 1;
  2078.       ry=remove_list[i]/size + 1;
  2079.       act_board[rx][ry] &= ~MARK;
  2080.     }
  2081.     return  sum;
  2082. }
  2083.  
  2084.  
  2085. count_liberties(x,y,type)
  2086. int  x, y;
  2087. unsigned char  type;
  2088. {   unsigned char  stone;
  2089.     act_board[x][y] |= MARK;
  2090.     remove_list[stno++] = (y-1)*size + (x-1);
  2091.     if (x > 1 && !(stone=act_board[x-1][y]&MASK))   return 1;
  2092.     if (x > 1 && stone==type && count_liberties(x-1,y,type))  return 1;
  2093.     if (x < size && !(stone=act_board[x+1][y]&MASK))  return 1;
  2094.     if (x < size && stone==type && count_liberties(x+1,y,type))  return 1;
  2095.     if (y > 1 && !(stone=act_board[x][y-1]&MASK))  return 1;
  2096.     if (y > 1 && stone==type && count_liberties(x,y-1,type))  return 1;
  2097.     if (y < size && !(stone=act_board[x][y+1]&MASK))  return 1;
  2098.     if (y < size && stone==type && count_liberties(x,y+1,type))  return 1;
  2099.     return 0;
  2100. }
  2101.  
  2102. remove_stones()
  2103. {
  2104.    int  rx, ry, i;
  2105.    for (i=0;i<stno;i++)
  2106.    { rx=remove_list[i]%size + 1;
  2107.      ry=remove_list[i]/size + 1;
  2108.      act_board[rx][ry] = 0;
  2109.      printf("%2d %2d R\n",rx,ry);
  2110.    }
  2111.    stno = 0;
  2112.    return  i;
  2113. }
  2114. @EOF
  2115.  
  2116. chmod 644 layout/smart2ps.c
  2117.  
  2118. echo x - layout/look
  2119. cat >layout/look <<'@EOF'
  2120. #!/bin/sh
  2121. # shellscript for interactive use of smart2ps & ghostscript , 27th July 92
  2122. file=$1 ; shift
  2123. viewer="gs -g739x1045"
  2124. printer=80
  2125. editor=vi
  2126. options="-rpm $@"
  2127. if [ ! -r $file.ps ]
  2128. then
  2129.    if [ ! -r $file.mgt ]
  2130.    then  echo "$file.mgt not found"; exit 1
  2131.    fi
  2132.    cp diagram.ps $file.ps
  2133.    cat $file.mgt | smart2ps $options >> $file.ps
  2134. else 
  2135.    start=`head -1 $file.ps | cut -c1-4`
  2136.    if [ "$start" != "%!PS" ]
  2137.    then  cp diagram.ps .scr.ps
  2138.          cat $file.ps >> .scr.ps ; file=.scr
  2139.    fi
  2140. fi
  2141. while : 
  2142. do
  2143. echo "view(v) , print(p), quit(q), edit(e), remove(r) , format(f) ?"
  2144. read ans
  2145.  if  [ $ans = "v" ]
  2146. then $viewer $file.ps
  2147. elif [ $ans = "p" ]
  2148. then lpr -x -P$printer $file.ps
  2149. elif [ $ans = "e" ]
  2150. then $editor $file.ps
  2151. elif [ $ans = "r" ]
  2152. then  rm -i $file.ps; exit 0
  2153. elif [ $ans = "q" ]
  2154. then  exit 0
  2155. elif [ $ans = "f" -a -r $file.mgt ]
  2156. then  echo "new options ?" ;  read opt
  2157.       cp diagram.ps $file.ps
  2158.       cat $file.mgt | smart2ps $opt >> $file.ps
  2159. elif [ $ans = "f" ]
  2160. then  echo "$file.mgt not found"
  2161. else  echo "invalid command: $ans"
  2162. fi
  2163. done
  2164. @EOF
  2165.  
  2166. chmod 755 layout/look
  2167.  
  2168. echo x - layout/example.ps
  2169. cat >layout/example.ps <<'@EOF'
  2170. % -------- begin of record ---------
  2171. 1.2 Scale
  2172. Initialize
  2173.     (No Way Out?)               Title
  2174.     (Gui-Si:)               Info
  2175.     (A life and death problem )      Info
  2176.     (from an ancient Chinese WeiQi book.)   Info
  2177. () DrawBoard
  2178. Newline Newline
  2179.     (<WeiQi.PS>)                Comment
  2180. Newline
  2181.     (A PostScript program for drawing Go game.) Comment
  2182. Newline
  2183.     (PostScript is a trade mark of )    Comment
  2184.     (Adobe System, Incorporated. )      Comment
  2185. Newline
  2186.     (Weiqi is Go in Chinese.)       Comment
  2187.     (                 Baduk is Go in Korean.)       Comment
  2188. Newline
  2189. Newline
  2190.     (Please send any comment and suggestion to )      Comment
  2191.     (achim@hrz.uni-bielefeld.de) Comment
  2192. StartGame
  2193.         % -------- Problem --------
  2194. 6 3 () B
  2195. 7 3 () B
  2196. 8 3 () B
  2197. 5 4 () B
  2198. 9 4 () B
  2199. 5 6 () B
  2200. 9 6 () B
  2201. 7 6 () B
  2202. 7 7 () B
  2203. 6 4 () W
  2204. 6 5 () W
  2205. 7 4 () W
  2206. 8 4 () W
  2207. 8 5 () W
  2208.         % -------- transformation --------
  2209. 14 17 () B
  2210. 13 17 () B
  2211. 12 17 () B
  2212. 15 16 () B
  2213. 11 16 () B
  2214. 15 14 () B
  2215. 11 14 () B
  2216. 13 14 () B
  2217. 13 13 () B
  2218. 14 16 () W
  2219. 14 15 () W
  2220. 13 16 () W
  2221. 12 16 () W
  2222. 12 15 () W
  2223. 13 18 Ko (1) W At (?) E
  2224.         % ------ solution ---------
  2225. 13 12 (1) W
  2226. 15 15 (2) B
  2227. 11 15 (3) W
  2228. 10 15 (4) B
  2229. 10 16 (5) W
  2230. 11 17 (6) B
  2231. 10 14 (7) W
  2232.  9 15 (8) B
  2233. 12 14 (9) W
  2234. 11 13 (10) B
  2235. 12 13 (11) W
  2236. 12 12 (12) B
  2237. 11 12 (13) W
  2238. showpage
  2239. % -------- end of record ---------
  2240. @EOF
  2241.  
  2242. chmod 644 layout/example.ps
  2243.  
  2244. echo x - layout/sample_old.ps
  2245. cat >layout/sample_old.ps <<'@EOF'
  2246.    1.2 Scale   -10 Yoff -80 Xoff  2 SetColumn
  2247. Initialize
  2248. 26 Size
  2249. ToggleRedraw
  2250. (PLL-Liga   Problem 10)  Title
  2251. (a middle game problem) Info
  2252. 12 Size
  2253. 0 Movelines
  2254. 13 10 5 (Problem: black to play) DrawPart
  2255. -999 SetC
  2256. StartGame
  2257.  4  4 BC
  2258.  6  4 BC
  2259.  4 10 BC
  2260.  7  3 BC
  2261.  8  4 BC
  2262.  3  6 WC
  2263.  7  4 WC
  2264.  7  5 WC
  2265.  8  3 WC
  2266. 13 10 5 (white plays for influence) DrawPart
  2267. -999 SetC
  2268. StartGame
  2269.  4  4 BC
  2270.  6  4 BC
  2271.  4 10 BC
  2272.  7  3 BC
  2273.  8  4 BC
  2274.  3  6 WC
  2275.  7  4 WC
  2276.  7  5 WC
  2277.  8  3 WC
  2278. 0 SetC
  2279.  6  5 BC
  2280.  6  3 WC
  2281.  7  2 BC
  2282.  6  2 WC
  2283.  8  2 BC
  2284.  9  3 WC
  2285.  8  5 BC
  2286.  7  6 WC
  2287.  5  3 BC
  2288.  9  6 WC
  2289.  8  6 BC
  2290.  8  7 WC
  2291.  7  7 BC
  2292.  6  6 WC
  2293.  9  7 BC
  2294.  8  8 WC
  2295.  9  5 BC
  2296. 10  6 WC
  2297. 10  5 BC
  2298. 11  5 WC
  2299. 11  6 BC
  2300. 10  7 WC
  2301. 11  4 BC
  2302. 12  5 WC
  2303. 10  4 BC
  2304.  9  2 WC
  2305.  5  2 BC
  2306.  8  1 WC
  2307.  6  1 BC
  2308.  6  3 R
  2309.  6  2 R
  2310. 12  4 WC
  2311. 11  3 BC
  2312. 11  2 WC
  2313. 12  3 BC
  2314. 13  3 WC
  2315. 12  2 BC
  2316. 13  2 WC
  2317. 10  2 BC
  2318. 12  1 WC
  2319. 11  1 BC
  2320. 11  2 R
  2321. 13  1 WC
  2322. 10  1 BC
  2323. 10  3 WC
  2324.  7  1 BC
  2325.  6  8 WC
  2326. 13 10 5 (correct: white takes the corner) DrawPart
  2327. -999 SetC
  2328. StartGame
  2329.  4  4 BC
  2330.  6  4 BC
  2331.  4 10 BC
  2332.  7  3 BC
  2333.  8  4 BC
  2334.  3  6 WC
  2335.  7  4 WC
  2336.  7  5 WC
  2337.  8  3 WC
  2338. 0 SetC
  2339.  6  5 BC
  2340.  6  3 WC
  2341.  7  2 BC
  2342.  6  2 WC
  2343.  8  2 BC
  2344.  3  3 WC
  2345.  4  3 BC
  2346.  4  2 WC
  2347.  3  2 BC
  2348.  2  2 WC
  2349.  5  2 BC
  2350.  3  1 WC
  2351.  6  1 BC
  2352. ColBreak
  2353. 13 10 5 (move 9 is blacks failure) DrawPart
  2354. -999 SetC
  2355. StartGame
  2356.  4  4 BC
  2357.  6  4 BC
  2358.  4 10 BC
  2359.  7  3 BC
  2360.  8  4 BC
  2361.  3  6 WC
  2362.  7  4 WC
  2363.  7  5 WC
  2364.  8  3 WC
  2365. 0 SetC
  2366.  6  5 BC
  2367.  6  3 WC
  2368.  7  2 BC
  2369.  6  2 WC
  2370.  8  2 BC
  2371.  3  3 WC
  2372.  4  3 BC
  2373.  4  2 WC
  2374.  5  2 BC
  2375.  5  3 WC
  2376.  3  2 BC
  2377.  5  1 WC
  2378.  3  4 BC
  2379.  2  3 WC
  2380.  2  2 BC
  2381.  5  4 WC
  2382.  5  5 BC
  2383.  2  4 WC
  2384.  2  5 BC
  2385.  4  5 WC
  2386.  3  5 BC
  2387.  4  6 WC
  2388.  2  6 (A) E
  2389.  6  6 (B) E
  2390. 13 10 5 (white resists strong) DrawPart
  2391. -999 SetC
  2392. StartGame
  2393.  4  4 BC
  2394.  6  4 BC
  2395.  4 10 BC
  2396.  7  3 BC
  2397.  8  4 BC
  2398.  3  6 WC
  2399.  7  4 WC
  2400.  7  5 WC
  2401.  8  3 WC
  2402. 0 SetC
  2403.  6  5 BC
  2404.  6  3 WC
  2405.  7  2 BC
  2406.  6  2 WC
  2407.  8  2 BC
  2408.  3  3 WC
  2409.  4  3 BC
  2410.  4  2 WC
  2411.  3  2 BC
  2412.  5  3 WC
  2413.  3  4 BC
  2414.  2  3 WC
  2415.  2  2 BC
  2416.  2  4 WC
  2417.  6  1 BC
  2418.  3  5 WC
  2419.  4  5 BC
  2420.  4  1 (A) E
  2421.  1  2 (B) E
  2422. 13 10 5 (second attempt of white) DrawPart
  2423. -999 SetC
  2424. StartGame
  2425.  4  4 BC
  2426.  6  4 BC
  2427.  4 10 BC
  2428.  7  3 BC
  2429.  8  4 BC
  2430.  3  6 WC
  2431.  7  4 WC
  2432.  7  5 WC
  2433.  8  3 WC
  2434. 0 SetC
  2435.  6  5 BC
  2436.  6  3 WC
  2437.  7  2 BC
  2438.  6  2 WC
  2439.  8  2 BC
  2440.  3  3 WC
  2441.  4  3 BC
  2442.  4  2 WC
  2443.  3  2 BC
  2444.  5  2 WC
  2445.  3  4 BC
  2446.  2  3 WC
  2447.  2  2 BC
  2448.  2  4 WC
  2449.  2  5 BC
  2450.  3  5 WC
  2451.  1  4 BC
  2452.  5  4 WC
  2453.  5  5 BC
  2454. % ---- end of game record   97 moves ---------
  2455. showpage
  2456. @EOF
  2457.  
  2458. chmod 644 layout/sample_old.ps
  2459.  
  2460. echo x - layout/sample_new.ps
  2461. cat >layout/sample_new.ps <<'@EOF'
  2462. %  0.7 Scale  -220 Yoff -60 Xoff  2 SetColumn  % 2 column output
  2463. 1.0 TopMargin
  2464. 2 0.5 0.5 0.5 SetColumns
  2465. Initialize
  2466. 1 1.0 0 Heading
  2467.  19 Size
  2468. (Problem 16 der PPL) Title
  2469. 0 Movelines
  2470.   -999  SetC
  2471. 0 13 SetCoord
  2472. 19 6 11 (Wei\373 am Zug)  DrawPart
  2473. StartGame
  2474.  4 18 () B
  2475.  6 18 () B
  2476.  6 17 () B
  2477.  7 16 () B
  2478.  7 15 () B
  2479.  8 15 () B
  2480.  9 16 () B
  2481. 10 17 () B
  2482.  9 17 () B
  2483. 11 18 () B
  2484.  7 18 () W
  2485.  8 18 () W
  2486.  8 17 () W
  2487.  8 16 () W
  2488.  9 15 () W
  2489. 10 15 () W
  2490. 11 17 () W
  2491. 12 16 () W
  2492. 14 17 () W
  2493. Newline
  2494. StartGame
  2495. 19 6 11 (Ko wenn Wei\373 alles fangen will)  DrawPart
  2496.  4 18 () B
  2497.  6 18 () B
  2498.  6 17 () B
  2499.  7 16 () B
  2500.  7 15 () B
  2501.  8 15 () B
  2502.  9 16 () B
  2503. 10 17 () B
  2504.  9 17 () B
  2505. 11 18 () B
  2506.  7 18 () W
  2507.  8 18 () W
  2508.  8 17 () W
  2509.  8 16 () W
  2510.  9 15 () W
  2511. 10 15 () W
  2512. 11 17 () W
  2513. 12 16 () W
  2514. 14 17 () W
  2515.   0  SetC
  2516. 12 18 WC
  2517.  9 18 BC
  2518.  9 19 WC
  2519. 10 19 BC
  2520.  7 19 WC
  2521.  6 19 BC
  2522. 10 16 WC
  2523.  8 19 BC
  2524. Newline
  2525. StartGame
  2526.   -999  SetC
  2527. 19 6 11 (Schwarz rettet einen Stein)  DrawPart
  2528.  4 18 () B
  2529.  6 18 () B
  2530.  6 17 () B
  2531.  7 16 () B
  2532.  7 15 () B
  2533.  8 15 () B
  2534.  9 16 () B
  2535. 10 17 () B
  2536.  9 17 () B
  2537. 11 18 () B
  2538.  7 18 () W
  2539.  8 18 () W
  2540.  8 17 () W
  2541.  8 16 () W
  2542.  9 15 () W
  2543. 10 15 () W
  2544. 11 17 () W
  2545. 12 16 () W
  2546. 14 17 () W
  2547.   0  SetC
  2548.  9 19 WC
  2549. 12 17 BC
  2550. 11 16 WC
  2551. 13 17 BC
  2552. 10 18 WC
  2553. 14 18 BC
  2554. 15 17 WC
  2555. 15 18 BC
  2556. 16 17 WC
  2557. 13 16 BC
  2558. Newline
  2559. StartGame
  2560. 19 6 11 (Schwarz rettet einen Stein)  DrawPart
  2561.   -999  SetC
  2562.  4 18 () B
  2563.  6 18 () B
  2564.  6 17 () B
  2565.  7 16 () B
  2566.  7 15 () B
  2567.  8 15 () B
  2568.  9 16 () B
  2569. 10 17 () B
  2570.  9 17 () B
  2571. 11 18 () B
  2572.  7 18 () W
  2573.  8 18 () W
  2574.  8 17 () W
  2575.  8 16 () W
  2576.  9 15 () W
  2577. 10 15 () W
  2578. 11 17 () W
  2579. 12 16 () W
  2580. 14 17 () W
  2581.   0  SetC
  2582.  9 19 WC
  2583. 12 17 BC
  2584. 11 16 WC
  2585. 13 17 BC
  2586. 10 18 WC
  2587. 12 18 BC
  2588. 14 16 WC
  2589. 14 18 BC
  2590. 15 18 WC
  2591. 13 19 BC
  2592. 15 19 WC
  2593. 14 19 BC
  2594. % --------- end of game record ---------
  2595. ColBreak
  2596. 1 1.0 0 Heading
  2597.   (Problem 17 der PPL)  Title
  2598. 1 Movelines
  2599. StartGame
  2600. 0 13 SetCoord
  2601. 19 6 11 (Wei\373 am Zug) DrawPart
  2602.   -999  SetC
  2603.  3 18 () B
  2604.  2 17 () B
  2605.  4 17 () B
  2606.  4 16 () B
  2607.  3 15 () B
  2608.  5 16 () B
  2609.  6 17 () B
  2610.  7 17 () B
  2611.  8 17 () B
  2612.  7 18 () B
  2613.  9 18 () B
  2614. 10 18 () B
  2615.  3 17 () W
  2616.  3 16 () W
  2617.  4 18 () W
  2618.  5 18 () W
  2619.  5 17 () W
  2620.  6 16 () W
  2621.  7 16 () W
  2622.  8 16 () W
  2623.  9 17 () W
  2624. 10 17 () W
  2625. 11 17 () W
  2626. 11 18 () W
  2627. Newline
  2628. StartGame
  2629. 1 Movelines
  2630.   -999  SetC
  2631. 19 6 11 (Teilerfolg von Wei\373) DrawPart
  2632.  3 18 () B
  2633.  2 17 () B
  2634.  4 17 () B
  2635.  4 16 () B
  2636.  3 15 () B
  2637.  5 16 () B
  2638.  6 17 () B
  2639.  7 17 () B
  2640.  8 17 () B
  2641.  7 18 () B
  2642.  9 18 () B
  2643. 10 18 () B
  2644.  3 17 () W
  2645.  3 16 () W
  2646.  4 18 () W
  2647.  5 18 () W
  2648.  5 17 () W
  2649.  6 16 () W
  2650.  7 16 () W
  2651.  8 16 () W
  2652.  9 17 () W
  2653. 10 17 () W
  2654. 11 17 () W
  2655. 11 18 () W
  2656. 0 SetC
  2657.  2 18 WC
  2658.  2 16 BC
  2659.  3 19 WC
  2660.  3 17 BC
  2661.  6 19 WC
  2662.  8 19 BC
  2663. 10 19 WC
  2664.  4 19 BC
  2665. 11 19 WC
  2666.  2 19 BC
  2667.  9 19 WC
  2668.  3 19 Ko BC At (2) E
  2669.  7 19 WC
  2670.  5 19 BC
  2671.  8 18 WC
  2672.  6 18 BC
  2673. Newline
  2674. StartGame
  2675. 1 Movelines
  2676.   -999  SetC
  2677. 19 6 11 (Mit Ko kann Schwarz etwas mehr haben) DrawPart
  2678.  3 18 () B
  2679.  2 17 () B
  2680.  4 17 () B
  2681.  4 16 () B
  2682.  3 15 () B
  2683.  5 16 () B
  2684.  6 17 () B
  2685.  7 17 () B
  2686.  8 17 () B
  2687.  7 18 () B
  2688.  9 18 () B
  2689. 10 18 () B
  2690.  3 17 () W
  2691.  3 16 () W
  2692.  4 18 () W
  2693.  5 18 () W
  2694.  5 17 () W
  2695.  6 16 () W
  2696.  7 16 () W
  2697.  8 16 () W
  2698.  9 17 () W
  2699. 10 17 () W
  2700. 11 17 () W
  2701. 11 18 () W
  2702. 0 SetC
  2703.  2 18 WC
  2704.  2 16 BC
  2705.  3 19 WC
  2706.  6 19 BC
  2707.  3 17 WC
  2708.  5 19 BC
  2709.  8 19 WC
  2710.  3 16 BC
  2711.  6 18 WC
  2712.  3 18 BC
  2713.  3 19 Ko WC At (X) E
  2714. % --------- end of game record ---------
  2715. showpage
  2716. @EOF
  2717.  
  2718. chmod 644 layout/sample_new.ps
  2719.  
  2720. chmod 751 layout
  2721.  
  2722. exit 0
  2723.