1 gogame: G: GOGAME: proc;
  2 
  3 /* Main control program and command interface for go playing programs.
  4    This program has nothing to do with asigning values to moves, except
  5    to verify that they are legal and do not leave the group to
  6    which a stone is added in atari.
  7    Coded by THVV and REM Sep 72
  8    code to validate moves added by REM Mar 73
  9    */
 10 
 11 dcl  gostat_$version char (8) ext;
 12 dcl  gostat_$debug fixed bin (35) ext;
 13 
 14 %include godata;
 15 
 16 dcl (x, y) fixed bin;
 17 dcl (binf, winf, loose) fixed bin;
 18 dcl  color fixed bin, opcode char (8), (i, j, k) fixed bin;
 19 dcl  h_total fixed bin;
 20 dcl  OUT char (32) int static options (constant) init ("GOGAME.dump");
 21 dcl  maxv fixed bin init (0);
 22 dcl (bi, bj) fixed bin;
 23 dcl (wi, wj) fixed bin;
 24 dcl  influence entry ((19, 19) fixed bin, (19, 19) fixed bin, fixed bin, fixed bin, fixed bin, fixed bin);
 25 dcl  handy_man entry (ptr, fixed bin, fixed bin);
 26 dcl  cap entry (ptr);
 27 dcl (id, iid, jjd) fixed bin;
 28 dcl  tdead fixed bin;
 29 dcl  loud bit (1) init ("0"b);
 30 dcl  xymode bit (1) init ("1"b);
 31 dcl  brief bit (1) init ("0"b);
 32 dcl  auto bit (1) init ("0"b);
 33 dcl  autocount fixed bin;
 34 dcl  every_sw bit (1) init ("0"b);
 35 dcl (every_x, every_n) fixed bin;
 36 dcl  every_com char (100);
 37 
 38 dcl  select_move entry (fixed bin, entry (ptr), ptr, fixed bin, fixed bin);
 39 dcl  go_b entry (ptr);
 40 dcl  go_w entry (ptr);
 41 dcl  cu_$cp entry (ptr, fixed bin, fixed bin (35));
 42 dcl  get_group_id_ entry () returns (char (32));
 43 dcl  ask_$ask_line entry options (variable);
 44 dcl  ask_$ask_cline entry options (variable);
 45 dcl  line char (120);
 46 
 47 dcl  program_interrupt condition;
 48 dcl  cleanup condition;
 49 dcl  ioa_ entry options (variable);
 50 dcl  ioa_$nnl entry options (variable);
 51 dcl  ioa_$rsnnl entry options (variable);
 52 dcl  ioa_$ioa_stream entry options (variable);
 53 dcl  ios_$attach entry (char (*), char (*), char (*), char (*), bit (72));
 54 dcl  ios_$detach entry (char (*), char (*), char (*), bit (72));
 55 dcl  ioa_$ioa_stream_nnl entry options (variable);
 56 dcl  ask_$ask_clr entry;
 57 dcl  ask_ entry options (variable);
 58 dcl  ask_$ask_int entry options (variable);
 59 dcl  cu_$arg_ptr entry (fixed bin, ptr, fixed bin, fixed bin (35));
 60 dcl  cv_dec_check_ entry (char (*), fixed bin (35)) returns (fixed bin);
 61 dcl  ap ptr, al fixed bin;
 62 dcl  bchr char (al) based (ap);
 63 dcl  ec fixed bin (35);
 64 dcl  status bit (72);
 65 dcl  savedir char (168);
 66 dcl  savepath char (168);
 67 dcl  savee char (32);
 68 dcl  savep ptr;
 69 dcl  expand_path_ entry (ptr, fixed bin, ptr, ptr, fixed bin (35));
 70 dcl  hcs_$delentry_seg entry (ptr, fixed bin (35));
 71 dcl  hcs_$truncate_seg entry (ptr, fixed bin, fixed bin (35));
 72 dcl  hcs_$make_seg entry (char (*), char (*), char (*),
 73      fixed bin (5), ptr, fixed bin (35));
 74 dcl  hcs_$initiate entry (char (*), char (*), char (*),
 75      fixed bin (1), fixed bin (2), ptr, fixed bin (35));
 76 dcl  hcs_$terminate_noname entry (ptr, fixed bin (35));
 77 dcl  com_err_ entry options (variable);
 78 dcl  clock_ entry () returns (fixed bin (71));
 79 dcl  date_time_ entry (fixed bin (71), char (*));
 80 
 81 dcl  SAVEVERSION fixed bin int static options (constant) init (2);
 82 dcl 1 save based (savep) aligned,                           /* When we save a game here is what it looks like. */
 83     2 saver char (32),                                      /* pgid of saving process */
 84     2 comment char (64),                                    /* remarks. */
 85     2 version fixed bin,                                    /* version no. of structure. */
 86     2 tbdead fixed bin,                                     /* total kill */
 87     2 twdead fixed bin,
 88     2 tbstones fixed bin,
 89     2 twstones fixed bin,
 90     2 board (19, 19) fixed bin,
 91     2 i_ko fixed bin,
 92     2 j_ko fixed bin,
 93     2 who_moves fixed bin,
 94     2 pass_count fixed bin,
 95     2 timesaved fixed bin (71),
 96     2 handy_num fixed bin,
 97     2 n_moves fixed bin;
 98 
 99 dcl  letters char (38) int static options (constant) init
100     ("abcdefghjklmnopqrstABCDEFGHJKLMNOPQRST");
101 
102 dcl  title1 char (120) int static options (constant) init
103     ("^/^6xA^3xB^3xC^3xD^3xE^3xF^3xG^3xH^3xJ^3xK^3xL^3xM^3xN^3xO^3xP^3xQ^3xR^3xS^3xT^/");
104 dcl  title2 char (120) int static options (constant) init
105     ("^/^6x1^3x2^3x3^3x4^3x5^3x6^3x7^3x8^3x9  10  11  12  13  14  15  16  17  18  19^/");
106 
107 dcl (null, substr, index, max, min, addr) builtin;
108 
109 /* ======================================================= */
110 
111           call ask_$ask_clr;                                /* Clear internal line buffer */
112           savepath = "";
113           call hcs_$make_seg ("", "", "", 1011b, godatap, ec);
114           call hcs_$truncate_seg (godatap, 0, ec);
115           godata.n_moves = 1;
116           bi, bj = 0;
117           wi, wj = 0;
118           godata.debugging, godata.endgame = "0"b;          /* Reset flags. */
119           i = 1;
120           godata.handy_num = -100;
121 arglp:    call cu_$arg_ptr (i, ap, al, ec);                 /* See if any argument. */
122           if ec ^= 0 then do;                               /* No arguments. Tell how to get info. */
123                if i = 1 then
124                     call ioa_ ("type ""E help gogame"" for instructions.");
125           end;
126           else do;                                          /* Argument specified. */
127                if bchr = "-bf" then brief = "1"b;
128                else if bchr = "-brief" then brief = "1"b;
129                else if bchr = "-lg" then loud = "1"b;
130                else if bchr = "-long" then loud = "1"b;
131                else if bchr = "-auto" then do;
132                     auto = "1"b;
133                     autocount = 500;
134                end;
135                else if bchr = "-debug" then debugging = "1"b;
136                else do;
137                     godata.handy_num = cv_dec_check_ (bchr, ec);
138                     if ec ^= 0 then do;
139                          godata.handy_num = -100;
140                          savepath = bchr;
141                          call load_board (ec);
142                          if ec ^= 0 then savepath = "";
143                     end;
144                end;
145                i = i + 1;
146                go to arglp;
147           end;
148 
149           if ^brief then call ioa_ ("GOGAME, version ^a", gostat_$version);
150           on condition (program_interrupt) begin;
151                auto = "0"b;
152                go to command;
153           end;
154           on condition (cleanup) begin;
155                call hcs_$delentry_seg (godatap, ec);
156           end;
157 
158           if savepath ^= "" then do;                        /* did we laod the board? */
159                if bi = WHITE then go to command;
160                else go to loop;
161           end;
162 
163           if godata.handy_num = -100 then                   /* Unless given on command line, ask */
164 handi:         call ask_$ask_int ("how many handicap stones will you give me?  ", godata.handy_num);
165           if godata.handy_num = 0 then go to loop;
166           if godata.handy_num = 1 then go to loop;
167           if godata.handy_num = -1 then go to command;
168           else if godata.handy_num < 0 then do;
169                h_total = - godata.handy_num;
170                color = WHITE;
171           end;
172           else do;
173                h_total = godata.handy_num;
174                color = BLACK;
175           end;
176           if h_total > 17 then go to handi;
177           call handy_man (godatap, color, h_total);
178           if color = BLACK then go to command;
179 
180 loop:     call select_move (BLACK, go_b, godatap, bi, bj);
181           if bi = 0 then do;
182                if ^brief then call ioa_ ("   Black passes.");
183                godata.pass_count = godata.pass_count + 1;
184                if godata.pass_count = 2 then go to game_ends;
185                go to command;
186           end;
187           godata.pass_count, godata.i_ko, godata.j_ko = 0;
188 
189           call influence (godata.inf, godata.suminf, bi, bj, 1, 1);
190           if ^brief then
191                if debugging then
192                     call write_long ("black", bi, bj);
193                else call ioa_ ("my move is ^9a", locn (bi, bj));
194           godata.n_moves = godata.n_moves + 1;              /* Count black's move */
195 
196           if godata.dead (WHITE, 0) ^= 0 then do;
197                if ^brief then call ioa_ ("Capturing White's:");
198                godata.twdead = godata.twdead + godata.dead (WHITE, 0);
199                tdead = godata.dead (WHITE, 0);
200                do i = 1 to 19 while (tdead > 0);
201                     do j = 1 to 19 while (tdead > 0);
202                          if godata.board (i, j) = WHITE then
203                               if godata.dame (0, grpno (i, j)) = 0 then do;
204                                    if ^brief then call ioa_ ("^-^9a", locn (i, j));
205                                    godata.board (i, j) = 0;
206                                    tdead = tdead - 1;
207                                    call influence (godata.inf, godata.suminf, bi, bj, -1, -1);
208                                    if godata.dead (WHITE, 0) = 1 then do;
209                                         godata.i_ko = i;
210                                         godata.j_ko = j;
211                                    end;
212                               end;
213 
214                     end;
215                end;
216                call cap (godatap);
217           end;
218 
219 command:
220           if every_sw then
221                if godata.n_moves >= every_x then do;
222                     every_x = godata.n_moves + every_n;
223                     opcode = every_com;
224                     go to exec;
225                end;
226           if auto then do;
227                autocount = autocount - 1;
228                if autocount = 0 then auto = "0"b;
229                call select_move (WHITE, go_w, godatap, wi, wj);
230                if wi = 0 then do;
231                     if ^brief then call ioa_ ("   White passes");
232                     go to wpass;
233                end;
234                if ^brief then
235                     if debugging then
236                          call write_long ("white", wi, wj);
237                     else call ioa_ ("^3d) white ^9a", godata.n_moves, locn (wi, wj));
238                i = wi; j = wj;
239                godata.n_moves = godata.n_moves + 1;
240                go to checkmove;
241           end;
242 command1:
243           call ask_ ("^d) ", opcode, godata.n_moves);
244 exec:     if opcode = "w" then do;
245                godata.n_moves = godata.n_moves + 1;
246                color = WHITE;
247 getmove:       call getij;
248                if color = WHITE then do;
249                     wi = i;
250                     wj = j;
251                end;
252                if godata.board (i, j) ^= 0 then do;
253                     call ioa_ ("point occupied by ^a stone -- reenter", COLOR (godata.board (i, j)));
254                     call ask_$ask_clr;
255                     go to command1;
256                end;
257 
258                godata.board (i, j) = color;
259                if (opcode = "bb"|opcode = "ww") then do;
260                     call influence (godata.inf, godata.suminf, i, j, color, 1);
261                     go to command;
262                end;
263 checkmove:     call cap (godatap);
264 
265                if godata.dead (BLACK, 0) = 0 then
266                     if godata.dead (WHITE, 0) > 0 then do;
267                          call ioa_ ("move would kill your own group -- reenter");
268 UNDO_WHITE:              godata.board (i, j) = 0;
269                          call ask_$ask_clr;
270                          go to command1;
271                     end;
272 
273                if godata.dead (BLACK, 0) = 1 then
274                     if i = godata.i_ko then
275                          if j = godata.j_ko then do;
276                               call ioa_ ("point taken in ko last move -- reenter");
277                               go to UNDO_WHITE;
278                          end;
279 
280                call influence (godata.inf, godata.suminf, i, j, -1, 1);
281                godata.i_ko, godata.j_ko, godata.pass_count = 0;
282 
283                if godata.dead (BLACK, 0) ^= 0 then do;
284                     if ^brief then call ioa_ ("Capturing black's:");
285                     godata.tbdead = godata.tbdead + godata.dead (BLACK, 0);
286                     tdead = godata.dead (BLACK, 0);
287                     do i = 1 to 19 while (tdead > 0);
288                          do j = 1 to 19 while (tdead > 0);
289                               if godata.board (i, j) = BLACK then
290                                    if godata.dame (0, grpno (i, j)) = 0 then do;
291                                         if ^brief then call ioa_ ("^-^9a", locn (i, j));
292                                         godata.board (i, j) = 0;
293                                         tdead = tdead - 1;
294                                         call influence (godata.inf, godata.suminf, i, j, 1, -1);
295                                         if godata.dead (BLACK, 0) = 1 then do;
296                                              godata.i_ko = i;
297                                              godata.j_ko = j;
298                                         end;
299                                    end;
300                          end;
301                     end;
302                end;
303                call cap (godatap);
304           end;
305           else if opcode = "E" then do;
306                call ask_$ask_line ("command ", line);
307                call cu_$cp (addr (line), 120, ec);
308                go to command;
309           end;
310           else if opcode = "p" then do;
311                if godata.debugging then call score ();
312                else call ioa_ ("^/Move ^d^/", godata.n_moves);
313                if loud then if xymode then call ioa_ (title2);
314                     else call ioa_ (title1);
315                do i = 1 to 19;
316                     if loud then if xymode then call ioa_$nnl ("^2d^2x", i);
317                          else call ioa_$nnl ("^2d^2x", 20-i);
318                     do j = 1 to 19;
319                          if godata.board (i, j) = BLACK then call ioa_$nnl (" (B)");
320                          else if godata.board (i, j) = WHITE then call ioa_$nnl (" (W)");
321                          else if debugging then call ioa_$nnl ("^4d", godata.mv (i, j));
322                          else call ioa_$nnl ("  + ");
323                     end;
324                     call ioa_ ("^/");
325                end;
326                go to command;
327           end;
328           else if opcode = "what" then do;
329                call ioa_ ("Last move by black: ^9a", locn (bi, bj));
330                call ioa_ ("Last move by white: ^9a", locn (wi, wj));
331                go to command;
332           end;
333           else if opcode = "quit" then do;
334                call hcs_$delentry_seg (godatap, ec);
335                return;
336           end;
337           else if opcode = "save" then do;
338 baden:         call ask_ ("pathname ", savepath);
339                call expand_path_ (addr (savepath), index (savepath, " "), addr (savedir), addr (savee), ec);
340                if ec ^= 0 then go to baden;
341                if index (savee, ".go ") = 0 then do;
342                     i = index (savee, " ");
343                     substr (savee, i, 3) = ".go";
344                end;
345                call hcs_$make_seg (savedir, savee, "", 1011b, savep, ec);
346                if savep = null then do;
347                     call com_err_ (ec, "GOGAME", "^a", savee);
348                     go to command;
349                end;
350                call ask_$ask_cline (save.comment, i);
351                if i = 0 then save.comment = "";
352                save.saver = get_group_id_ ();
353                save.version = SAVEVERSION;
354                do i = 1 to 19; do j = 1 to 19;
355                          save.board (i, j) = godata.board (i, j);
356                end; end;
357                save.i_ko = godata.i_ko;
358                save.j_ko = godata.j_ko;
359                save.who_moves = WHITE;
360                save.pass_count = godata.pass_count;
361                save.handy_num = godata.handy_num;
362                save.tbdead = godata.tbdead;
363                save.twdead = godata.twdead;
364                save.n_moves = godata.n_moves;
365                save.timesaved = clock_ ();
366                call hcs_$terminate_noname (savep, ec);
367                go to command;
368           end;
369           else if opcode = "load" then do;
370                call ask_ ("pathname ", savepath);
371                call load_board (ec);
372                if ec ^= 0 then go to command;
373                if bi = WHITE then go to command;            /* If white's move. */
374                else go to loop;                             /* .. black's move */
375           end;
376           else if opcode = "pass" then do;
377 wpass:         godata.pass_count = godata.pass_count + 1;
378                if godata.pass_count = 2 then go to game_ends;
379           end;
380           else if opcode = "godb" & gostat_$debug = 1 then do;
381                debugging = "1"b;
382                call ioa_ ("^28xMV^11xinf  VM  V3  V2  VS  VI  VC  VT  VN");
383                go to command;
384           end;
385           else if opcode = "nodb" then do;
386                debugging = "0"b;
387                go to command;
388           end;
389           else if opcode = "help" then do;
390                call ioa_ ("requests are w, pass, p, quit.");
391                go to command;
392           end;
393           else if opcode = "score" then do;
394                call score ();
395                go to command;
396           end;
397           else if opcode = "c" & debugging then do;
398                call getij;
399                if godata.board (i, j) = 0 then do;
400                     call ioa_ ("point empty");
401                     go to command;
402                end;
403                color = godata.board (i, j);
404                godata.board (i, j) = 0;
405                call influence (godata.inf, godata.suminf, i, j, color, -1);
406                go to command;
407           end;
408           else if opcode = "dump" & debugging then do;
409                call ask_ ("pathname ", savedir);
410                call expand_path_ (addr (savedir), index (savedir, " "), addr (savepath), null, ec);
411                call ios_$attach (OUT, "file_", savepath, "", status);
412                call date_time_ ((clock_ ()), savee);
413                call ioa_$ioa_stream (OUT, "^a - handicap ^d - move ^d",
414                     savee, godata.handy_num, godata.n_moves);
415                call ioa_$ioa_stream (OUT, "^-KO ^d ^d; BDEAD ^d WDEAD ^d",
416                     godata.i_ko, godata.j_ko, godata.tbdead, godata.twdead);
417                call ioa_$ioa_stream (OUT, "^-last move was ^d, ^d^/", bi, bj);
418                call ioa_$ioa_stream (OUT, "^-^-BOARD^/");
419                call printarray (godata.board);
420                call ioa_$ioa_stream (OUT, "^|^-^-MV^/");
421                call printarray (godata.mv);
422                call ioa_$ioa_stream (OUT, "^|^-^-INF^/");
423                call printarray (godata.inf);
424                call ioa_$ioa_stream (OUT, "^|^-^-VM^/");
425                call printarray (godata.vm);
426                call ioa_$ioa_stream (OUT, "^|^-^-V3^/");
427                call printarray (godata.v3);
428                call ioa_$ioa_stream (OUT, "^|^-^-V2^/");
429                call printarray (godata.v2);
430                call ioa_$ioa_stream (OUT, "^|^-^-VS^/");
431                call printarray (godata.vs);
432                call ioa_$ioa_stream (OUT, "^|^-^-VI^/");
433                call printarray (godata.vi);
434                call ioa_$ioa_stream (OUT, "^|^-^-VC^/");
435                call printarray (godata.vc);
436                call ioa_$ioa_stream (OUT, "^|^-^-SUMINF^/");
437                call printarray (godata.suminf);
438                call ioa_$ioa_stream (OUT, "^|^-^-VOTES^/");
439                call printarray (godata.votes);
440                call ioa_$ioa_stream (OUT, "^|^-^-NEARBY^/");
441                call printarray (godata.nearby);
442                call ioa_$ioa_stream (OUT, "^|^-^-GRPNO^/");
443                call printarray (godata.grpno);
444                call ioa_$ioa_stream (OUT, "^|^d groups, BEYE ^d, WEYE ^d",
445                     godata.ngrp, godata.tbeye, godata.tweye);
446                call ioa_$ioa_stream (OUT, "^/Grp        loc        dame");
447                call ioa_$ioa_stream (OUT, "num Color  i  j    W   -   B   NP   ATTR^/");
448                do i = 1 to godata.ngrp;
449                     if godata.gp_color (i) ^= -2 then
450                          call ioa_$ioa_stream (OUT, "^3d ^5a ^2d ^2d  ^3d ^3d ^3d  ^3d  ^a",
451                          i, COLOR (godata.gp_color (i)),
452                          godata.gp_loc (i, 1), godata.gp_loc (i, 2),
453                          godata.dame (-1, i), godata.dame (0, i), godata.dame (1, i),
454                          godata.np (i),
455                          grp_att (i));
456                end;
457                call ios_$detach (OUT, "", "", status);
458                go to command;
459           end;
460           else if opcode = "auto" & debugging then do;
461                auto = "1"b;
462                call ask_$ask_int ("count ", autocount);
463                go to command;
464           end;
465           else if opcode = "every" & debugging then do;
466                every_sw = "1"b;
467                call ask_$ask_int ("every ", every_n);
468                if every_n <= 0 then every_sw = "0"b;
469                else call ask_$ask_line ("command ", every_com);
470                if every_n > 0 then every_x = godata.n_moves + every_n;
471                go to command;
472           end;
473           else if opcode = "mode" then do;
474                call ask_ ("mode ", savee);
475                if savee = "brief" then brief = "1"b;
476                else if savee = "long" then loud = "1"b;
477                else if savee = "^long" then loud = "0"b;
478                else if savee = "^brief" then brief = "0"b;
479                else call ioa_ ("^a?", savee);
480                go to command;
481           end;
482           else if opcode = "?" & debugging then do;
483                call getij;
484                maxv = godata.mv (i, j);
485                do i = 1 to 19;
486                     do j = 1 to 19;
487                          if godata.mv (i, j) >= maxv then
488                               if godata.board (i, j) = 0 then
489                                    call write_long ("", i, j);
490                     end;
491                end;
492                go to command;
493           end;
494           else if opcode = "s" & debugging then do;
495                call getij;
496                if godata.board (i, j) ^= 0 then
497                     call ioa_ ("point occupied by ^a", COLOR (godata.board (i, j)));
498                call write_long ("", i, j);
499                k = grpno (i, j);
500                call ioa_ ("  group is ^d points, (^d,^d,^d) ^a",
501                     godata.np (k), godata.dame (-1, k), godata.dame (0, k), godata.dame (1, k),
502                     grp_att (k));
503                go to command;
504           end;
505           else if opcode = "bb" & debugging then do;
506                color = BLACK;
507                go to getmove;
508           end;
509           else if opcode = "ww" & debugging then do;
510                color = WHITE;
511                go to getmove;
512           end;
513           else do;
514                call ioa_ ("unknown command ""^a""", opcode);
515                call ask_$ask_clr;
516                go to command;
517           end;
518           go to loop;
519 
520 game_ends: call ioa_ ("^/^/Two passes in a row. Game ends.");
521           auto = "0"b;
522           call ioa_ ("Total captures: black stones ^d, white stones ^d", godata.tbdead, godata.twdead);
523           call ioa_ ("Type ""p"" to print board, or ""quit"" to exit from GOGAME");
524           go to command;
525 
526 getij:    proc;
527 
528 dcl (ctmp, ctmp1) char (8);
529 dcl  k fixed bin, ec fixed bin (35);
530 
531 badi:          call ask_ ("location ", ctmp);
532                i = cv_dec_check_ (ctmp, ec);
533                if ec ^= 0 then do;
534                     j = index (letters, substr (ctmp, 1, 1));
535                     if j = 0 then go to badi;
536                     if j > 19 then j = j - 19;
537                     if substr (ctmp, 2) = "" then do;
538 aski:                    call ask_ (" -and ", ctmp);
539                          go to geti;
540                     end;
541                     else if substr (ctmp, 2, 1) = "-" then ctmp1 = substr (ctmp, 3);
542                     else ctmp1 = substr (ctmp, 2);
543                     ctmp = ctmp1;
544 geti:               i = 20 - cv_dec_check_ (ctmp, ec);
545                     if ec ^= 0 then go to aski;
546                     if i < 1 then go to aski;
547                     else if i > 19 then go to aski;
548                     return;
549                end;
550                if i < 1 then go to badi;
551                else if i > 19 then go to badi;
552 badj:          call ask_ (" -and ", ctmp);
553                j = cv_dec_check_ (ctmp, ec);
554                if ec ^= 0 then go to badj;
555                if j < 1 then go to badj;
556                else if j > 19 then go to badj;
557 
558           end getij;
559 
560 printarray: proc (z);
561 
562 dcl  z (19, 19) fixed bin;
563 
564 dcl (i, j) fixed bin;
565 
566                call ioa_$ioa_stream (OUT, title2);
567 
568                do i = 1 to 19;
569                     call ioa_$ioa_stream_nnl (OUT, "^2d^2x", i);
570                     do j = 1 to 19;
571                          call ioa_$ioa_stream_nnl (OUT, "^4d", z (i, j));
572                     end;
573                     call ioa_$ioa_stream (OUT, "^/");
574                end;
575 
576           end printarray;
577 
578 locn:     proc (i, j) returns (char (9));
579 
580 dcl (i, j) fixed bin;
581 dcl  rv char (9);
582 dcl  junk fixed bin;
583 
584                if xymode then call ioa_$rsnnl ("(^3d,^3d)", rv, junk, i, j);
585                else call ioa_$rsnnl ("^a-^d", rv, junk, substr (letters, 19+j, 1), 20-i);
586                return (rv);
587 
588           end locn;
589 
590 /* Internal procedure to print debugging move */
591 
592 write_long: proc (text, x, y);
593 
594 dcl  text char (*);
595 dcl (x, y) fixed bin;
596 
597                call ioa_ ("^3d) ^6a^9a: value^3d, influence^3d,^3d,^3d,^3d,^3d,^3d,^3d,^3d,^3d",
598                     godata.n_moves, text,
599                     locn (x, y),
600                     godata.mv (x, y),
601                     godata.inf (x, y),
602                     godata.vm (x, y),
603                     godata.v3 (x, y),
604                     godata.v2 (x, y),
605                     godata.vs (x, y),
606                     godata.vi (x, y),
607                     godata.vc (x, y),
608                     godata.votes (x, y),
609                     godata.nearby (x, y));
610 
611           end write_long;
612 
613 grp_att:  proc (x) returns (char (32) var);
614 
615 dcl  x fixed bin;
616 dcl  vs char (32) var;
617 
618                vs = "";
619                if gp_attr (x).eye then vs = vs || "eye ";
620                if gp_attr (x).double_eye then vs = vs || "double_eye ";
621                if gp_attr (x).dead then vs = vs || "dead ";
622                if gp_attr (x).surround (-1) then vs = vs || "Wsurr ";
623                if gp_attr (x).surround (1) then vs = vs || "Bsurr ";
624                if gp_attr (x).feye then vs = vs || "feye ";
625 
626                return (vs);
627 
628           end grp_att;
629 
630 score:    proc;
631 
632                binf, winf, loose = 0;
633                do i = 1 to 19;
634                     do j = 1 to 19;
635                          if godata.board (i, j) = 0 then
636                               if godata.inf (i, j) > 4 then binf = binf + 1;
637                               else if godata.inf (i, j) < -4 then winf = winf + 1;
638                               else loose = loose + 1;
639                     end;
640                end;
641                call ioa_ ("^/Move ^3d^8xWhite Black^/", godata.n_moves);
642                call ioa_ ("influence:^6x^5d ^5d ^5d", winf, binf, loose);
643                call ioa_ ("captures:^7x^5d ^5d", godata.twdead, godata.tbdead);
644                call ioa_ ("score:^10x^5d ^5d", winf - godata.twdead, binf - godata.tbdead);
645                call ioa_ ("points in eye:  ^5d ^5d", godata.tweye, godata.tbeye);
646                call ioa_ ("contact plays:  ^5d ^5d", contact_plays (-1), contact_plays (1));
647                call ioa_ ("ataris:^9x^5d ^5d", ataris (-1), ataris (1));
648                call ioa_ ("rejected moves: ^5d ^5d", rejected_moves (-1), rejected_moves (1));
649                call ioa_ ("");
650 
651           end score;
652 
653 
654 load_board: proc (ec);
655 
656 dcl  ec fixed bin (35);
657 
658                call expand_path_ (addr (savepath), index (savepath, " "), addr (savedir), addr (savee), ec);
659                if ec ^= 0 then do;
660                     call com_err_ (ec, "GOGAME", "^a", savepath);
661                     return;
662                end;
663                if index (savee, ".go ") = 0 then savee = rtrim (savee) || ".go";
664                call hcs_$initiate (savedir, savee, "", 0, 1, savep, ec);
665                if savep = null then do;
666                     call com_err_ (ec, "GOGAME", "^a", savee);
667                     return;
668                end;
669                if save.version ^= SAVEVERSION then do;
670                     call com_err_ (0, "GOGAME", "Incorrect save file format.");
671                     ec = -1;
672                     return;
673                end;
674                do i = 1 to 19; do j = 1 to 19;
675                          godata.inf (i, j), godata.suminf (i, j) = 0;
676                end; end;
677                do i = 1 to 19; do j = 1 to 19;
678                          godata.board (i, j) = save.board (i, j);
679                          if godata.board (i, j) ^= 0 then
680                               call influence (godata.inf, godata.suminf, i, j, godata.board (i, j), 1);
681                end; end;
682                godata.i_ko = save.i_ko;
683                godata.j_ko = save.j_ko;
684                godata.pass_count = save.pass_count;
685                call date_time_ (save.timesaved, savee);
686                godata.handy_num = save.handy_num;
687                godata.n_moves = save.n_moves;
688                godata.handy_num = save.handy_num;
689                godata.tbdead = save.tbdead;
690                godata.twdead = save.twdead;
691                godata.tbstones = save.tbstones;
692                godata.twstones = save.twstones;
693                call ioa_ ("^a saved ^a by ^a - handicap ^d", save.comment, savee, save.saver, save.handy_num);
694                call cap (godatap);
695                if debugging then call go_w (godatap);       /* Only chance to see tables from white's eye */
696                bi = save.who_moves;
697                call hcs_$terminate_noname (savep, (0));
698 
699                ec = 0;
700 
701           end load_board;
702 
703      end GOGAME;