Note.  There are several broken dates in this file of the form ?? Sep'08, caused about 7-19 Dec.
when I messed with the add/remove line numbers under the TextWrangler editor.
----------------------------------------------------------------------------
Sept 2008, completed reformatting of awit.alg.  This involved providing a more uniform
indentation structure for BEGIN-END blocks, and positioning COMMENTs and controlling their length 
so that the total line length fitted normal page width.  Mostly a matter of eliminating all use 
of TAB characters, which lead to different indentation settings depending on the editor.

Prior to this time Corey Bloodworth had fixed a few index-error bugs via the following changes:
?? See file CB-Changes.txt ??

Notes: 9 Aug 2008
subroutine depend is called as MMTTS (ind, hist)
ind takes different values to achieve initializations.  Primarily ind = 0.
When ind = +N, then write to record N000, when ind = -N the read record N000.
ind can also take values,  -10002, -10003, -10008 and -10009
These all do close operations on the file attached to units, 2, 3, 8 and 9 respectively.
If you will, ind = -(10000+K) closes the file attached to unit K.
ind = -9999 explicitly attaches the game record file to unit 9.

hist is a 140 byte buffer that typically contains the forsythe notation of the current position, 
so that it can be used a a basis for a restart.  It contains not only the piece placements, but 
also the castling status for both side, side to move (+ or -)  and the current move number. The 
last 4 bytes of "history" might also hold the 4-byte user ID of the MTS account running the program.
Here hist is locally declared as a 35 word integer (each integer occupying 4 bytes of space).


My insubstantive changes included:
.  added to the ?8 command to provide the following command descriptions:
                  " BLITZ - reset to Blitz mode.",
                  " INTER - reset to Intermediate mode.",
                  " TOURN - reset to Tournament mode.",
                  " EXPER - reset to Experimental mode.",
                  " PLAY  - Force computer to make next move.",
                  " SWAP  - Complement side to move, so that other side can move next.",
                  " PAB   - Complement the Palphabeta Flag.",
                  " STOP  - Terminates the program.", " ") ;
                  
. Another insubstantive change was to re-arrange some commented-out code which now becomes:
,8657c8690,8696
<            THEN IF (POS(KSQ) = 0) OR (ABS(CON(-K,EPSQ)) = 1) 
<                    AND (CONTROL(EPSQ,-K) = KSQ) AND ((CAPT > 0) 
<                    OR (POS(KSQ) = 1)) OR GIVINGCH AND (POS(KSQ) <= 1) 
<                    AND (CON(-K,KINGATTACKER) = 0 OR (CONTROL(KINGATTACKER,-K) = KSQ 
<                    AND K*SEC(0,KINGATTACKER) >= 0) OR ~SACRIFICE(KINGATTACKER, FALSE))
---
>            THEN IF (POS(KSQ) = 0) OR (POS(KSQ) = 1)) 
>                    OR (ABS(CON(-K,EPSQ)) = 1) 
>                       AND (CONTROL(EPSQ,-K) = KSQ) AND ((CAPT > 0)     
>                    OR GIVINGCH AND (POS(KSQ) <= 1) AND (CON(-K,KINGATTACKER) = 0 
>                              OR (CONTROL(KINGATTACKER,-K) = KSQ 
>                        AND K*SEC(0,KINGATTACKER) >= 0)
>                    OR ~SACRIFICE(KINGATTACKER, FALSE))

?? Sept 08
Have looked at the 1983 listing.  There I see *g instead of g*.  Still makes no sense, so have 
changed the comment to read:
                    COMMENT have experienced severe problems with use of ?g. Need
                            to restore the window array, try. As a result parts
                            of the movelist are overlayed, but cannot guarantee 
                            that the moves in the window overlay themselves exactly;
This at least rings a bell from times past.  Given that ? and * are miles apart on the keyboard
don't understand how such a typo could arise.

Have also started looking in the note books.   
On 4 Feb 1982 the version was DE4.4 and I see from 
my notes that every time I recompiled awit I incremented the version by 0.1  
On reaching DE9.9 on 
April 1982, the version number changed to AP1.0
The change was physically made in procedure printshortbrd each time (I think, since it appears in 
the printouts).
All this would have been great, had I included a year in there.  Something like 82AP1.0 
  
By 30 May 1982 was at MA1.0, 
on 30 Oct 1983 went OC1.0, 
July 1984 went to JU1.0, 
April 1985 back to AP1.0, 
by 15 June 1986 we are at AP9.5 and that was the version used in the Koln WCCC.  
Those games are the last entry in the notebook, and the last notebook of the set.

I have now returned the 1986 compiler listing but recall it was dated 26 May 1986.  The last code 
change is dated in the book is 12 June 1986 and is version AP9.5  
At first glance, this rather begs the question of exactly which version of AWIT we have, since our 
printshortbrd says AP1.0 and  the May 1986 compiler listing also showed AP1.0 (I am pretty sure). 

Changed Printshortbrd 'AP1.0" now reads "86-Ap9.5"

?? Sept. 2008

changed iocontrol(3) to iocontro(2) in GameRecord(false) so that no page eject with ?s.

?? Sept. 2008
Implemented a FLIP command to make it easier to invert positions.  The FLIP command invokes:

--    procedure flipper;
3-    begin
--      integer i, j, pc;
--      j := wqrsq + 7*brdwidth;
--      for i := wqrsq until bkrsq - 4*brdwidth
4-      do begin
--         if BRD(i) ~= EDGE 
5-         then begin
--           pc := BRD(j);
--           BRD(j) := -BRD(i);
--           BRD(i) := -pc;
-5         end;
--           if (i rem 10) = 0
--           then j := j - 20;
--           j := j + 1;
-4      end;
--      K := -K;
--      PRINTSHORTBRD(K);
-3    end offlipper;
  
  usage in opponent is:
      END ELSE IF BUFFER(0|4) = "PLAY"
             THEN NULLMOVE := TRUE
             ELSE IF BUFFER(0|3) = "PAB"
                  THEN BEGIN
                    PAB := ~PAB ;
                    WRITE("Palphabeta", PAB) ;
                    GOTO LOOP ;
-5      END ELSE if buffer(0|4) = "FLIP"
5-              then begin
--                flipper ;
--                TRACER(2, "?ZK") ;
--                goto loop ;
-5              end else
5-      BEGIN
  
?? Sept 08
Fixed bug in sacrifice pertaining to opponent passed pawn detection with:
          WHILE (ABS(BRD(I)) ~= PAWN AND pawns(I) ~= 0)
          DO I := I + FILES(KK) ;
          
?? Sept. 08
In SACRIFICE changed opponent passed pawn creation to read:
          if (brd(i) ~= edge)
          then begin
            TMP := TMP + (IF BRD(I) = -KK*PAWN
                          THEN PASSEDPAWN(I,-KK)
                          ELSE 0) ;
            IF TMP > 0 AND L ~= 0 AND ABS(ROWS(SQ)-ROWS(I)) = 1
                       AND KK*SEC(0,I-FILES(KK)) > 0
            THEN TMP := 0 ;
          end;
          
?? Sept. 08
Am looking at the discovered check reduction code in SELECTRTMV:
      IF ~CAPTURE_TREE OR LEVEL > 2
      THEN IF (TEMP < EPSILON) AND (TEMP > DELTA)
           THEN IF Y > X AND (Y < DISCHECK OR Y >= TWOCHECK)
           THEN BEGIN
write("Disc. ch. reduce", X, Y, pres, past, i, try(i-1), try(i),
reward(pres), score(past));
                        COMMENT if too many disc. ch., don't re-order ;
             TRY(I-1) := PRES ;
             TRY(I) := PAST ;
             IF I = 2 THEN SCORE(PRES) := SCORE(PAST);
             IF I = 2 THEN REWARD(PRES) := -ABS(REWARD(PRES));
             PRES := PAST ;
             Y := X ;
      END ;
      
?? Sept'08
In SELECTRTMV am concerned about the incrementing of NN, without any check that it might 
reach WSIZE.   Have inserted an exploratory test.

--      IF SCORE(TRY(NN-1)) <= MINSCR
--      THEN SCORE(TRY(NN-1)) := SCORE(TRY(NN)) ;
--      if nn < wsize
--      then TRY(WSIZE) := NN 		comment reset try(wsize);
5-      else begin
--        TRY(WSIZE) := try(0) ;		comment reset try(wsize);
--        write("Select-rtmv clobber of try(wsize) avoided");
-5      end;

?? Sept'08
This code looks suspect.  What if max_wid < 12?
--    SAVE_WIDTH := WIDTH;
--    IF PRINCVAR AND LEVEL = 2 AND PATH > 1 AND LENGTH = 5
--        AND WIDTH < MAX_WID
--    THEN LIMIT := WIDTH := 12;
--                        COMMENT width may have been narrowed at previous iteration;
--    IF LEVEL = 2 AND PRINCVAR AND PATH > 1 AND LENGTH = 5
--    THEN WRITE("ITER WIDE", LIMIT, TRY(WSIZE), WIDTH);

?? Sept'08
The code:
--    IF OLD OR FINAL = 5 OR SIDE = 1 OR INCREASE > 0 OR ((MAXL >= POINT)
--      AND (FORCED AND (LEVEL > 2))) OR ((MAXL - POINT >= EST)
--      AND ((IP <= MIN) OR (BEST <= EXPECT+EPSILON) OR LEVEL = 1
--      AND BEST < SCR) OR GIVINGCH)
6-    THEN BEGIN

might be more clearly written:
  IF GIVINGCH OR OLD OR FINAL = 5 OR SIDE = 1 OR INCREASE > 0
    OR ((MAXL >= POINT) AND (FORCED AND (LEVEL > 2)))     
    OR (MAXL - POINT >= EST)        
       AND ((IP <= MIN) OR (BEST <= EXPECT+EPSILON) OR LEVEL = 1 AND BEST < SCR)   
  THEN BEGIN
  

?? Sept'08
Modified ?O command to make it easier to recognize which flags are changing.  It reads:
        BEGIN
          WRITE ("?C-coko=", COKO, "?1-dumpp=", DUMPP, "?2-ws=", WS, "?45= ",
                            IF CBOTH
                            THEN "BOTH"
                            ELSE IF BOTH
                                 THEN "USER"
                                 ELSE "EACH",
                 "  ", "?L-lookahead=", LOOKAHEAD, "?M-MONITOR=", MONITOR) ;
          WRITE("?7-test=", TEST, "?Q-quick=", QUICK, "?T-tournament=", TOURNAMENT,
                "?E-examine=", EXAMINE, "?V-debug=", DEBUG, "ENDGAME=", ENDGAME)
            ;
          WRITE("?J-CAPTURE=", CAPTURE_TREE, "OPENING=", OPEN(-1), OPEN(1))
            ;
        END ;
                                                      COMMENT     "o" ;
                                                      
?? Sept'08
removed the extra call to init_tree from HUB, to re-establish the ?G command:
    LEVEL := 1 ;
    comment init_tree;
    IF (WHO)
    THEN COMPUTER
    ELSE OPPONENT ;

?? Sept'08
Consider when BUILD_SACR_TREE is called.  "Potential"
Consider when SACR_TREE called.   "setting width"
only when CAPTURE_TREE is set true.

?? Sept'08
Have both a procedure called lookahead and a logical variable of the same name.  Undersirable.
Changed Procedure lookahead to procedure LOOKingAHEAD

?? Sept'08
Suitable parameters for Awit are:
?6
600 7 0 19
NO
?51LJO           . kind of tournament mode   Qd1+ test
K5PPP2B24Q32B5885R28-88884P33Q2PPPP1B41K1R4-
play
?1G1

?6
600 7 0 19
NO
?5LJO           . kind of tournament mode.   Stalemate test
P4P2K4PR5P8+888882R58K7+                                                 TFFFFFT    ....                 (17)
play
?1G1

?G               . to see tree built during last iteration.

?? Sept'08
Have replaced in Mate_soln
--              IF KEEP = 0 AND DIR ~= 0
--              THEN WHILE KEEP = 0 AND (JJ <= 1)
--                         and sq >= wqrsq and sq < bkrsq
10-                  DO BEGIN
--                               COMMENT block the attack path;
--                     IF BRD(SQ) ~= 0
--                     THEN JJ := JJ +1 ;
--                     IF SQ = MVT
--                     THEN KEEP := 4
--                     ELSE SQ := SQ + DIR ;
-10             END ;
with:
            IF KEEP = 0 AND DIR ~= 0            
            THEN WHILE KEEP = 0 AND (JJ <= 1)                 
                 DO BEGIN                             
                    COMMENT block the attack path;                   
                    IF BRD(SQ) ~= 0                   
                    THEN JJ := JJ +1 ;                   
                    IF SQ = MVT                   
                    THEN KEEP := 4                   
                    ELSE if sq = sqf                        
                         then jj := 2                        
                         else begin                          
                           SQ := SQ + DIR ;                          
                           if brd(sq) = edge                          
                           then begin                            
                             write("MATE_SOLN index error avoided ", "DIR=", DIR,                               "SQ=", SQ, "PC=", PC);                            WRITE("Mater ", "sqf", SQF, offset(sqf), "sqt", SQT, 
                                   offt, "mvf/mvt", mvf, mvt, "j, k, l jj", j, k, l, jj);
                             tracer(2, "?PZ");
                             JJ := 2;
                           end;
                    end;
            END;
which reduces to:
            IF KEEP = 0 AND DIR ~= 0            
            THEN WHILE KEEP = 0 AND (JJ <= 1)                 
                 DO BEGIN                             
                    COMMENT block the attack path;                   
                    IF BRD(SQ) ~= 0                   
                    THEN JJ := JJ +1 ;                   
                    IF SQ = MVT                   
                    THEN KEEP := 4                   
                    ELSE if sq = sqf
                         then jj := 2
                         else SQ := SQ + DIR ;                          
            END;
            
?? Sept'08
Replacing:
--        I := NN+1 ;
--  FOUND:
--        COMMENT IF (NN < WID) THEN NN := NN+1 ;
--        IF (NN < MAX_WID)
--        THEN NN := NN + 1        comment ensure NN < wsize;
6-        else begin
--  comment  write("found: selectrtmv", n, nn, max_wid, wid, "I", i, "<", wsize);
--  comment  printline(n,0);
-6        end;
--  if false and i >= wsize then
--  write("About to clobber try(wsize)", i, nn, n)
--  else
--        TRY(I) := N ;		comment could clobber try(wsize), but OK;

with:
      I := NN+1 ;
FOUND:
      COMMENT IF (NN < WID) THEN NN := NN+1 ;
      IF (NN < MAX_WID)
      THEN NN := NN + 1 ;      comment ensure NN < wsize;
if i >= wsize then
  write("About to clobber try(wsize)", try(wsize), i, nn, n, number(k))
else
      TRY(I) := N ;             comment could clobber try(wsize), but OK;
      
?? Sept'08
Am looking at:
       ELSE IF MAXL = 0
            THEN BEGIN
              NOD := NODETO(ORIGIN,1) ;
              IF NOD = ROOTNODE((DEPTH+1000) DIV 1000)
              THEN BEGIN
                MAXL := 0 ;
                WRITE("SERIOUS", LEVEL, DEPTH, EST, NOD) ;
                FOR LX := 1 UNTIL LEVEL
                DO WRITEON(ROOTNODE(LX)) ;
                FOR I := 1 UNTIL NODETO(NOD,0)
                DO IF NODETO(NOD,I) = ROOTNODE((DEPTH+2000) DIV 1000)
                   THEN MAKE_SPACE(NOD, 1, I, DEPTH+1000, EST) ;
       END ;
and at:
    IF PARTIAL AND IP < LIMIT AND SCORE(TRY(IP+1)) < BETA AND IP > 0
    THEN BEGIN
                          COMMENT for some reason the beta bound has increased,
                                  so a full evaluation is not required;
      WRITE("EMERGENCY ", IP, SCORE(TRY(IP+1)), BETA) ;
      IP := 0 ;
      UPPER := EIGHTS ;
      PARTIAL := FALSE ;
      PART := PLEX := 0 ;
      LISTLEGALMOVES(FALSE) ;
      HASH := T_HASH;
      SAVESTATE(ROOT) ;
    END ;
    
?? Sept'08
    Have introduced w_size and set it equal to wsize-1, and used it to ensure
    (a) try(wsize) and try(w_size) are not clobbered, and also to limit the width of search to 
    w_size-1 instead of wsize-1.  This change is probably not important.
    
?? Oct08
Look again at the "move insertion code":
    if nn < wsize
    then TRY(WSIZE) := NN               comment reset try(wsize);
    else begin
      TRY(WSIZE) := try(0) ;            comment reset try(wsize);
      write("Select-rtmv clobber of try(wsize) avoided");
    end;
                           COMMENT IF TEST AND ALTERNATIVE THEN PRINTMOVES(K) ;
  END ;
END OFSELECTRTMV ;

?? Oct08
Also in SHIFT
--      NOTE := IF F = 1
--              THEN "MOVED"
--              ELSE "SHIFT" ;
--      LX := TRY(IP) ;
--      LAST := NODETO(ROOT, IP) ;
--      FOR I := IP-1 STEP -1 UNTIL F
7-      DO BEGIN
--        TRY(I+1) := TRY(I) ;
--        NODETO(ROOT, I+1) := NODETO(ROOT, I) ;
-7      END ;
--      TRY(F) := LX ;
--      NODETO(ROOT, F) := LAST ;

and in MATE_SOLN
--                IF M <= MAX_WID THEN M := M + 1 ;
--                TRY(M) := J ;
--                FOR I := M STEP -1 UNTIL 2
--                DO IF SCORE(J) > SCORE(TRY(I))
11-                  THEN BEGIN
--                     TRY(I+1) := TRY(I) ;
--                     TRY(I) := J ;
-11               END ;

is try(wsize) clobbered?
cleaning up mate_soln

?? Oct08
Gane back to version awit-8.alg
introduced w_size = WSIZE-1 and trying to get full 19 move width.  Some changes still needed to
selectrtmv
>                               COMMENT Have just dynamically reordered to 
>                                       consider an effective killer move sooner;
< write("About to clobber try(wsize)", try(wsize), i, nn, n, number(k))

?? Oct'08

Want to replace this "fix"
    if (Path+level-2 >= 1) then
      REFTAB(PATH+LEVEL-2,LEVEL) := REFTAB(PATH+LEVEL-1,LEVEL);
    if (Path+level-2 >= 1) then
      IF LEVEL < MAX_PLIES
        THEN REFTAB(PATH+LEVEL-2,LEVEL+1) := -1;
by making the lower bound on REFTAB as 0 instead of 1.
and thus restore the code in TERMINATE to its original of

      REFTAB(PATH+LEVEL-2,LEVEL) := REFTAB(PATH+LEVEL-1,LEVEL);

      IF LEVEL < MAX_PLIES
        THEN REFTAB(PATH+LEVEL-2,LEVEL+1) := -1;
        
?? Oct'08
Want to restore
comment    THEN IF Y > X AND (Y < DISCHECK OR Y >= TWOCHECK)  ; 
           then if y > x and (y >= discheck and y < twocheck)           
                THEN BEGIN
                  if monitor 
                  then begin
                    if try(wsize) <= 0 
                    then write ("Discover check issue");  
                    tracer(1,"?P"); comment try(wsize) must be valid for ?D to work;  
                    printline(try(i),0);  
                    printline(try(j),0);  
                    write("Disc. ch. reduce", X, Y, pres, past, "i=", i, try(i-1), try(i));  
                    write("level=", level, epsilon, "temp=", temp, delta, "j=", j);  
                    write("C_tree", capture_tree, "R(pres)", reward(pres), reward(past),        
                    "S(pres)", score(pres), score(past)); 
                  end;
           
to its original of
           THEN IF Y > X AND (Y < DISCHECK OR Y >= TWOCHECK)           
                THEN BEGIN
                
and see what changes.

Seems to lead to much smaller trees.  Will run whole B-Kopec test and see what happens.

awit.a:10419:24: array subscript error: subscript 1 of 'try' = -1, outside the range (0::21)
Failed on Board T.

Restored the discovered check revision above in SELECTRTMV.  Made no difference.  Exactly the same 
error.

Will now restore the patch in TERMINATE.  Problem gone away.   How on earth does this change affect
an index error in try?

With SELCTRTMV I reset the code to the 1986 version and again get the index error:
awit.a:10420:24: array subscript error: subscript 1 of 'try' = -1, outside the range (0::21)
with following in SELECTRTMV
           THEN IF Y > X AND (Y < DISCHECK OR Y >= TWOCHECK)
           comment THEN IF Y > X AND (y >= DISCHECK and  y < TWOCHECK) ;
           THEN BEGIN
try again with
           comment THEN IF Y > X AND (Y < DISCHECK OR Y >= TWOCHECK) ;
           THEN IF Y > X AND (y >= DISCHECK and  y < TWOCHECK) 
           THEN BEGIN
all OK on position T, output is:
 -14 -169 :  -73 -105 -254  -40  -72 -116 -366  -90 -195  -85 -181  -88  -14 -422 -207 -437 -148 -286 -275
-99999 99999 : a2a3 d1d3 e2h5 g3g4 e2b5 e2e3 e2g2 a2a4 d1d2 e2d3 c3a4 e2d2 e2f3 h2h4 b2b3 c3b5 h2h3 e2f2 e2f1
SCORED 7017 /7768 POSNS.  13 /  19  DEPTH =   7   38   47

??. a3                      
CPU ELAPSE ELA/MOVE LEFT LIMBS/SEC
?? 51    2   89   16 6265
  
  This might suggest there is some kind of error within the section:
        IF ~CAPTURE_TREE OR LEVEL > 2
        THEN IF (TEMP < EPSILON) AND (TEMP > DELTA)
           comment THEN IF Y > X AND (Y < DISCHECK OR Y >= TWOCHECK) ;
           THEN IF Y > X AND (y >= DISCHECK and y < TWOCHECK)
           THEN BEGIN
                        COMMENT if too many disc. ch., don't re-order ;
             TRY(I-1) := PRES ;
             TRY(I) := PAST ;
             IF I = 2 THEN SCORE(PRES) := SCORE(PAST);
             IF I = 2 THEN REWARD(PRES) := -ABS(REWARD(PRES));
             PRES := PAST ;
             Y := X ;
      END ;
      
Restored to the original the patch in TERMINATE, so now reads:
    comment if (Path+level-2 >= 1) then ;
      REFTAB(PATH+LEVEL-2,LEVEL) := REFTAB(PATH+LEVEL-1,LEVEL);
    comment if (Path+level-2 >= 1) then ;
      IF LEVEL < MAX_PLIES
        THEN REFTAB(PATH+LEVEL-2,LEVEL+1) := -1;
        
position T does not fail.

?? Oct'08
Study of B-K.7plyB.txt file
Error message				Board
DISASTER					Q
SERIOUS						H, I, L
PRUNE						B, E, I, K, S, W
CHECK CAPT.					C, L, R
INCONSISTENT				E, J, K, Q, S, U

?? Nov'08
After returning from England made only (but numerous) cosmetic changes to the file.  Preparing to 
explore the "INCONSISTENT" warning message.  Am also separating the function of the 
MONITOR and TEST flags.  Note: use of MONITOR causes TEST output to Awit_Debug.txt

?? Nov'08
Have made several cosmetic changes (matching procedure name to END OF_procedurename, for example)
to make the code more consistent and readable

?? Nov'08
In procedure SHIFT have added a variable u"update" to clarify when "ptr" is updated.

PROCEDURE SHIFT (INTEGER VALUE IP, F, ROOT) ;
BEGIN
  INTEGER LX, LAST, ptr ;
  logical update;
  STRING(5) NOTE ;
  IF IP > F
  THEN BEGIN
    NOTE := IF F = 1
            THEN "MOVE "
            ELSE "SHIFT" ;
    LX := TRY(IP) ;
    LAST := NODETO(ROOT, IP) ;
    ptr := nodeto(root,0) ;
    FOR I := IP-1 STEP -1 UNTIL F
    DO BEGIN
      TRY(I+1) := TRY(I) ;
      NODETO(ROOT, I+1) := NODETO(ROOT, I) ;
    END ;
    update := F <= ptr and ptr < IP ;
    if update and IP <= MAX_WID
    then ptr := ptr + 1;
    nodeto(root,0) := ptr ;
    TRY(F) := LX ;
    NODETO(ROOT, F) := LAST ;
    SAVE(ROOT) ;
    IF (TEST or update)
    THEN begin
      WRITE(NOTE, LEVEL, F, ptr, IP, update, ROOT) ;
      for i := f step 1 until ptr
      do writeon(nodeto(root,i)) ;
    end;
  END ;
END OF_SHIFT ;
               
This change seems to ease the "INCONSISTENT" error message problem, but does not solve it.
There is considerable difficulty in generating a repeatable position that exhibits the problem, 
becuase in SPEED mode the selected move is randomized over a range of approximately equal moves.

After the 9 Nov'08 changes, the incidence of warning messages (as noted on 6 Oct 08) is reduced to:
DISASTER		two: N, R
SERIOUS			one: M
PRUNE			none: 
CHECK CAPT		three: D, M, S
INONSISTENT		none:
The above supports the view that there is a lack of repeatability with Awit's results, although the
B-K test score remains stable.

?? Nov'08
Added a check on the max size of MAXTREE near the start of the MAIN program.

  MAXTREE := CONVERTS(U,INERR) ;
  if maxtree > 1000 then begin
    maxtree := 1000;
    write ("MAXTREE restricted to 1000 nodes.") ;       
    write ("Conflict with packing/unpacking of moves") ;
  end;
  
  and changed the size of the packing/unpacking constant from 1000 to 10000 everywhere.
  This change particularly affects array STATES and PARENT and procedure MARKTREE. The 1986
  version AP9.6 is in awit-10.alw 
  
?? Nov'08
  Re-established debug mode in which maxtree is 10 and width is 3 (expands to 5).  This is an 
  attempt to increase the number of warning errors.
  
  In MAIN added:
    if maxtree = 10 then width := 3;
  and also changed
    MAXTREE := IF (MAXTREE < 10)
             THEN 600
             ELSE IF MAXTREE < 100 and maxtree > 10
                  THEN 100
                  ELSE MAXTREE ;
  also had to fix array overflow on getnode by reducing output of getnode to 10 elements:
              IF TEST THEN WRITE("DEAD ") ;
            IF TEST
                    THEN FOR I := 1 UNTIL 10 DO WRITEON(GETNODE(I)) ;
END OF_DEADTREE ; comment deadtree collection ;
That is, reduce getnode output to 10 from 15.
Finally make it possible for MODE to be 1:
  MODE := IF (MAXTREE = 10)
           THEN 1
           ELSE IF (LENGTH > 7) AND (MAXTREE >= 600)
                THEN 6
                ELSE IF LENGTH > 5
                     THEN 5
                     ELSE IF (LENGTH > 3)
                          THEN 4
                          ELSE IF ~CAPTURE_TREE
                               THEN 2
                               ELSE 3 ;
  SKILL := CASE MODE OF ("   DEBUG", "   SPEED", "  BEGINNER",
    "INTERMEDIATE", "TOURNAMENT", "EXPERIMENTAL") ;

get error:
awit.a:9020:12: array subscript error: subscript 2 of 'nodeto' = 4, outside the range (0::3)

The reduction of width to 3 in DEBUG mode found the above subscript error.
Suggests "sabotage or booby trap error" found.  Replaced "nodeto" with "states", making restorestate 
consistent with savestate.

PROCEDURE RESTORESTATE (INTEGER VALUE NODE) ;
BEGIN
  INTEGER J, J1 ;
  K := STATES(NODE,1) ;
  PLEX := STATES(NODE,2) ;
  CAPT_T := STATES(NODE,3) ;
  TOT_S := states(node,4) ; comment was TOT_S := NODETO(NODE,4) ;
  PART := STATES(NODE,5) ;
  A_SCR := STATES(NODE,6) ;
  UPPER := STATES(NODE,7) ;
  HASH := STATES(NODE,T_SIZE) ;
  RESTORE(NODE) ;
END OF_RESTORESTATES ;

------------------------------------up to this point have version 86AP9.6--------------------

Seem to have eliminatged the "INCONSISTENT error message (at least is infrequent)
Have also re-introduced "DEBUG" mode where it is possible to restrict the node/position 
worksapce to 10 nodes, and the width of search to 3 moves and depth of search to 3 ply.
Seems to work, but now have one sequence that generates an infinite loop (one and only one thus far).
The input sequence is:
?f6
10 3 0 3
yes
?f5
Nf3
d5
b3
bg4
e3
e5
be2
Nc6
o-o
e4
Nf3-d4
.            The subsedquent move sequence is:
.            NF3-D4           1B=E    ( 6) Bxe2             0B*E
.            Qxe2             12-E    ( 7) Nc6xd4           13=E
.            e3xd4            13=E    ( 8) Bd6              13-E
.            Rf1-e1           23+O    ( 9) Nf6              23=O
.            Nc3              13=O    (10) O-O              13=O
?lj44o
play
?spzo
yes
.          <an infinite loops occurs at move 11>
-------------------------------------changed version number to 08AP9.7-----------------------

Want to work on the above infinite loop.
Have introduced variable "packer" which is initializable to 1000 or 10000
It is used to pack the level and node number into one cell.  Thus node 99 at level 3
will now be recorded at 30099, instead of 3099.  The purpose of this change is to allow node 
storage space greater than 1000 (as at present in version AP9.6), but only up to 9999 
nodes/positions.  The less restricting code is:

  packer := 10000 ;
  GO TO ENTER ;
ENTRY:
  WRITE("Enter MAXTREE, MAXLEV, TOTAL, WIDTH") ;
  WRITE("If zeros then defaults of 600, 7, 80 and 9 are used") ;
  WHILE READU
  DO ;
  MAXTREE := CONVERTS(U,INERR) ;
  if maxtree > packer then begin
    maxtree := packer ;
    write ("MAXTREE restricted to ", packer, " nodes.") ;
    write ("Conflict with packing/unpacking of moves") ;
  end ;
------------------------------------------------------------------------------------------  
?? Nov'08
While tracking down a difference between version 9.6 and 9.7 (use of packer instead of 1000 or 10000)
added a write statement in EXPAND as follows:
      IF FIRST
      THEN begin
        if test then write("first use ", LEVEL, POINT, REUSE, MAXL, NODE,
                               AA, SCR, BB, CREDIT(LEVEL), DEBIT(LEVEL-1)) ;
      end
      else IF PLY > 1 OR SCR > AA AND SCR < BB
                      OR INCHECK AND SCR > AA
                      
to replace:
--        IF ~FIRST
--        THEN IF PLY > 1 OR SCR > AA AND SCR < BB
--                        OR INCHECK AND SCR > AA
------------------------------------------------------------------------------------------
?? Nov'08
The infinite loop problem seems to be affected by and AND/OR error in procedure TERMINATE
the lines:
--          IF PRINCVAR AND SCR > BEST OR VAR_TIME -T_TIME < M_TIMES(0)
8-          THEN BEGIN
should be
--          IF PRINCVAR AND SCR > BEST and VAR_TIME -T_TIME < M_TIMES(0)
8-          THEN BEGIN
So that excessive time is not spent on one variation.  That said, some control, other than time,
is essential in this case.  That is, the above change hides the problem, does not really solve the
problem.  Nevertheless, should install this patch in version 86AP9.6 since it stops an infinite loop.

?? Nov'08
The prevalent Warning message is now:
c3c4 g8f7 d5a5 f5f4  335  741
QUESTION DEPTH   1    3    4    3    0  FALSE    0
QUESTION DEPTH   1    3    4    3    0  FALSE    0
QUESTION DEPTH   1    3    4    3    0  FALSE    0
QUESTION DEPTH   1    3    4    3    0  FALSE    0
QUESTION DEPTH   1    3    4    3    0  FALSE    0
QUESTION DEPTH   1    3    4    3    0  FALSE    0
QUESTION DEPTH   1    3    4    3    0  FALSE    0
Reducing the "QUESTION DEPTH" frequency seems like a worthwhile exercise.
---------------------------------------------------------------------------------
Nov'08
Am now testng with PAB set false.  Quickly obtained the following subscript error:

??.   ... Nb4-c2 +                
e1f2 f6e4 c3e4 -2478  746
?? -2178 :  746
?? -2478 -1878 : e1f2
SCORED    9 /  10 POSNS.   1 /   1  DEPTH =   3   37    0
   Kf2          0  746    5    3    4 10005    3
     Nf6xe4 +   -41 -746    4    3    2 20004    1
       Ne4          3  746    2    1
during ?g action (print game tree)
awit.a:9266:11: array subscript error: subscript 1 of 'parent' = -1, outside the range (0::11)
the following sequence produces the error
?f6
10 3 0 3
y
?flj5
PAB
f4                      
Ng8-f6                  
Ng1-f3                  
d5                      
d4                      
Nb8-c6                  
c4                      
d5xc4                   
Nb1-c3                  
Be6                     
e4                      
Bg4                     
?44
play

After making the following changes to the INVALIDATE procedure the subscript error is avoided.
The problem only seems to arise when PAB is FALSE

  IF NODE > 0 AND NODE <= MAXTREE
  THEN BEGIN
    FOR I := 1 UNTIL NODETO(NODE,0)
    DO begin
       if (nodeto(node,i) <= 0)
       then write("INVALIDATE error ", node, nodeto(node,0), i, nodeto(node,i))
       else
       IF PARENT(NODETO(NODE,I)) DIV packer = NODE
       THEN INVALIDATE(NODETO(NODE,I)) ;
    STATES(NODE,2) := 0 ;
    end ;
  END ;
   
   after inserting a write statement in "INVALIDATE" to bypass the problem I get:
   
Nb4-c2 +                
e1f2 f6e4 c3e4 -2478  746
-2178 :  746
-2478 -1878 : e1f2
SCORED    9 /  10 POSNS.   1 /   1  DEPTH =   3   37    0
   Kf2          0  746    5    3    4 10005    3
     Nf6xe4 +   -41 -746    4    3    2 20004    1
       Ne4          3  746    2    1
INVALIDATE error    5    3    2   -1
INVALIDATE error    5    3    3   -1
e1f2 f6e4 c3e4 c7c6 d5c6  745  746
e1d2 c2d4 f3f2  746 1995
?? 705 :  746  624 1995
?? 1046 : e1d2 e1f2 e1e2
SCORED   16 /  26 POSNS.   3 /   3  DEPTH =   3   35    0
   Kd2          0 1995    5    3   10 10005    3
     Nc2-d4       0 -1995   10    3    8 20010    1
       Qf2         -2 1995    8    1
e1d2 c2d4 f3f2 1994 1995
?? 1578 : 1995  746  602
?? 2295 : e1d2 e1f2 e1e2
SCORED    7 /  33 POSNS.   1 /   3  DEPTH =   3   30    0

?? . Kd2    
---------------------------------------------------------------------------------------  
It is fairly clear from DEBUG mode (10 nodes/move and width of 3 and deply of 3 ply) that there is
a serious problem with self-play games.  Here is an example:

If zeros then defaults of 600, 7, 80 and 9 are used
10 3 0 3
  max_plies=   5 max_wid=   9 maxtree=  10 t_size=   8 width=   3
  wsize=  21 rlimit=  15 maxply=   2 depth_limit=   5
  quick-?Q=  TRUE Tournament-?T= FALSE lookahead-?L= FALSE dumpp-?1= FALSE ws-?2=  TRUE
  test-?7= FALSE monitor-?M= FALSE capture_tree-?J= FALSE examine-?E= FALSE
Nov 24 2008
Awit, a chess program,
Enter ?8 for control options, STOP to terminate.
New game? (YES or NO)
no
Enter the board (in quasi Forsythe notation)
PP5K283P42B53P2BQ8-82Q588P1B56P14PP23K1R2-                                  FFFFFFFKf3              13<E    (35)
    ::    Kb    Rb    ::
 ::    :: Pw Pb Pb Bw QW
    :: Bw ::    :: Pb ::
 Pb    Bb Pw ::    ::
    ::    ::    ::    ::
 ::    ::    :: KW ::
    :: Qb ::    :: Pw Pw
 ::    ::    ::    ::
Nov 24 2008 08-AP9.7 BLACK'S MOVE 35.    DEBUG     mode
Enter your move or type PLAY
BLACK'S MOVE   35 
Use ?Y to update internal clock and move count
?lj
CONTINUE (Tracer ?LJ   exit):
pab
Palphabeta FALSE
play
c2f2 f3g4 f2g2 2826 3080
?? 2916 : 3080 2543 3028
?? 3426 : c2f2 c2d3 c2d1
SCORED    9 /  10 POSNS.   1 /   3  DEPTH =   3   25    0

35.   ... Qf2 +                   

?? Nov'08
A study of the above position and the sequence
........Qf2+
Kg4     Qf5+
Kh4     Bf2++    led to the discovery of improper pawn blocking capability. This has resulted in the 
following changes to "CHECKER" (mate avoidance detection).  A pawn forward 2 block was not handled 
correctly, and the resulting pawn blocking move was not credited with stopping mate.  The code:

--                     COMMENT is there an interposing pawn move? ;
--      SQA := SQA + SAVE_D ;
--      I := CON(-K,SQA) ;
--      PC := BRD(SQA+K_FILE) ;
--      IF (PC = -K_PAWN) OR ( (PC = NIL) and (sqa >= 41 and sqa <= 58)
--          AND (PAWNS(SQA + 2*K_FILE) = K_PAWN) ) 
6-      THEN BEGIN
--        I := I - K ;
--                        COMMENT note con(k,sqa) is not changed ;
--        CONTROL(SQA,I) := SQA + K_FILE*(IF (PC = NIL)
--                                        THEN 2
--                                        ELSE 1) ;
-6      END ;

becomes, and even this is not exactly right, since Black is concerned about row 4 (squares 41 to 48)
and white is affected by row 5 (squares 51 to 58) for the Pawn forward 2 block:

                   COMMENT is there an interposing pawn move? ;
    SQA := SQA + SAVE_D ;
if sqa ~= ksq then begin
    I := CON(-K,SQA) ;
    PC := BRD(SQA + K_FILE) ;
    IF (PC = -K_PAWN) OR ( (PC = NIL) and (sqa >= 41 and sqa <= 58)
        AND (brd(SQA + 2*K_FILE) = -K_PAWN) )
    THEN BEGIN
      I := I - K ;
                      COMMENT note con(k,sqa) is not changed ;
      CONTROL(SQA,I) := SQA + K_FILE*(IF (PC = NIL)
                                      THEN 2
                                      ELSE 1) ;
      mate := false ;
    END ;
end ;
--------------------------------------------------------------------------------------
Three problems with debug mode (maxtree = 10, max width and depth = 3) remain.
.  An infintie loop that generates the message before timing out and recovering:
PAB infinite error-loop in EXPAND3945 3755 99999 3755 2875   TRUE    3   30  FALSE   TRUE    3    3    0
 
.  The "INCONSISTENT node count message (although occurrence is much reduced)
SCORED  175 / 180 POSNS.   2 /   3  DEPTH =   3   26    0

INCONSISTENT    5    9   10

.  A Make_Space message that is related to point 2 above;
INCONSISTENT    5    9   10
??. Ne2                     
MAKE_SPACE no nodes    2    3 20000    1    4    1    3    2 nodes    5    4    5

I suspect that the latter is caused by the removal of a node (by setting it to zero), but by not 
reducing the number of pointers appropriately.
-----------------------------------------------------------------------------------

Reduced frequency of "INCONSISTENT" message by trying to flagging only when the lost node count 
changes.  See  INIT_TREE patch:

    NODECOUNT := NODECOUNT + MAXL ;
    new_count := MAXTREE - NODECOUNT ;
comment    IF NODECOUNT < MAXTREE THEN BEGIN ;
    IF new_count > 0 then
    if new_count ~= old_count
    THEN BEGIN
      WRITE("INCONSISTENT ", MAXL, NODECOUNT, MAXTREE, new_count, old_count) ;
      old_count := new_count ;
------------------------------------------------------------------------------------

?? December'08
Suspect a problem with draw by repetition detection when checks or discovered check is made.
Look into the setting of REVERSIBLE in MAKEMOVE, and its use thereafter.

the problem was pin pointed by the sequence:
?6
10 3 0 3
no
R2Q1K26BP6P14P1PN8888-8Q1R1N3882P1N33P2P1P3PP1P6K1-                           TFFFFFTKf1              13-M    (25)
?lj15
qc4
rxa7
nc3
kg1
ne2
kf1
nc3 was not scored as a draw because its static score was greater than 600 (draw score)

A patch was made in procedure TRYTHEM.  It becomes:
      IF REVERSIBLE
      THEN IF INCHECK OR GIVINGCH OR ENDGAME AND (PIECES(0) < 12)
           THEN BEGIN
             HASH := -NEWHASH(BRD, K, KEY) ;
             TMP := 0 ;
             FOR J := 1 UNTIL ENDPLAY
             DO IF (HASH = REPEATS(J))
                THEN TMP := TMP + 1 ;
             FOR J := 1 UNTIL LEVEL-1
             DO IF HASH = STACK_HASH(J)
                THEN TMP := TMP + 1 ;
             comment IF TMP > 1 OR TMP = 1 AND MV < DRAW ;
             IF TMP >= 1
             THEN MV := DRAW ;
             IF TEST AND MV = DRAW THEN BEGIN 
               WRITE("CYCLE ", TMP, endplay, level, mv, hash, k, ":" ) ;
               FOR I := 1 UNTIL ENDPLAY
               DO WRITEON(REPEATS(I)) ;
               FOR I := 1 UNTIL LEVEL-1
               DO WRITEON(STACK_HASH(I)) ;
             END ;
      END ;
----------------------------------------------------------------------------------
?? Dec'08
From starting Position
10 3 0 3

Dec 03 2008
Awit, a chess program,
Enter ?8 for control options, STOP to terminate.
New game? (YES or NO)
no
Enter the board (in quasi Forsythe notation)
P5K283P42B53P2BQ8-8888P1B3Q16P14PP23K1R2-                                   FFFFFFFKf3         DRAW 13=E    (44)
    ::    Kb    Rb    ::
 ::    :: Pw Pb Pb Bw QW
    :: Bw ::    :: Pb ::
 Pb    Bb Pw ::    Qb
    ::    ::    ::    ::
 ::    ::    :: KW ::
    ::    ::    ::    Pw
 ::    ::    ::    ::
Dec 03 2008 08-AP9.7 BLACK'S MOVE 44.
Entering INIT_TREE    DEBUG     mode
Enter your move or type PLAY
BLACK'S MOVE   44 
?lj4
CONTINUE (Tracer ?LJ4  exit):
pab
Palphabeta FALSE

entered infinite loop after Black's Qf5+ when output became:

-950 32967 : -950 99999 -1165
-446 -145 : f3e2 f3g2 f3g3
SCORED    4 /  58 POSNS.   2 /   3  DEPTH =   3   19    0
   Ke2         -2 99999    4    3    5 10004    3
     Qe4 +      -40 -99999    5    3    3 30003    3
        e2-d2      -2 99999    3    3    3 30003    3
          e2-d2      -2 99999    3    3    3 30003    3
          
This shows that the parent of node 3 is given as 30003 when is should be 20005
also node = 3 and root = 3

Put the following patch into GAMETREE:

      IF (NODE >= 1) AND (NODE <= MAXTREE)
      THEN BEGIN
        IF (ROOT ~= PARENT(NODE) REM packer)
           AND PARENT(NODE) <= PARENT(ROOT)
        THEN WRITEON("DUPLICATE", NODE) ;
        WRITEON(NODE, PARENT(NODE), NODETO(NODE,0)) ;
        if root ~= node and parent(node) = packer*level+root
        then
        GAMETREE(NODE, LEVEL+1, WIDTH) 
        else write("Infinite loop avoided ", root,"=", node, "or", 
                     parent(node), "~=", packer*level+root) ;
        RESTORESTATE(ROOT) ;
      END ;


and an approopriate move was generated after the following output:
-950 32967 : -950 99999 -1165
-446 -145 : f3e2 f3g2 f3g3
SCORED    4 /  58 POSNS.   2 /   3  DEPTH =   3   19    0
   Ke2         -2 99999    4    3    5 10004    3
     Qe4 +      -40 -99999    5    3    3 30003    3 
Infinite loop avoided    5  =  3 or 30003  ~= 20005
MAKE_SPACE no nodes    2    3 20000    1    2    1    4    5 nodes   10    4   10
MAKE_SPACE no nodes    2    4 30000    1   10    3    4    5 nodes    8    5    8
MAKE_SPACE no nodes    2    5 40000    1    8    1    4    5 nodes    0    6    0
No point in going further    8    1    0 ####   2 40000    1    1    1   -5    0    0    0    0 nodes    9    5    8 nodes    1    5
####   2 30000    1    1    1   -5    0    0    0    0 ####   2 20000    1    1    1   -5    0    0    0    0
f3e2 f5g4 e2d3 g4f5 d3c4 -1250  662


The above has led to excessive messages about "Infinite Loop Avoided" so the code is relaxed to:

      IF (NODE >= 1) AND (NODE <= MAXTREE)
      THEN BEGIN
        IF (ROOT ~= PARENT(NODE) REM packer)
           AND PARENT(NODE) <= PARENT(ROOT)
        THEN WRITEON("DUPLICATE", NODE) ;
        WRITEON(NODE, PARENT(NODE), NODETO(NODE,0)) ;
        if root ~= node 
        then
        GAMETREE(NODE, LEVEL+1, WIDTH)
        else write("Infinite loop avoided ", root,"=", node, "or ",
                     parent(node), "~=", packer*level+root) ;
        RESTORESTATE(ROOT) ;
      END ;
---------------------------------------------------------------------------------------
?? Dec'08
A PAB infinite loop error:  Previously relied on a time-out in TERMINATE to limit this loop.
This modification to EXPAND is more efficient, but rejects the new PV.  Note the problem is more
common when PAB is TRUE than when PAB is FALSE.

?6
10 3 0 3
no
Enter the board (in quasi Forsythe notation)
R4R1K2PPQPPNBPN1P3P77P888-8884P3P1PP43B1P22PBN1PP1R1Q1RK1-                    TFFFFFTh5               23=O  1 (16)
    Rb    Qb    Rb Kb ::
 ::    Pb Bb Nb    Pb Pb
    ::    Bb    Pb    ::
 Pb    Pb Pb ::    :: Pw
 Pw ::    :: Pb ::    ::
 Bw Pw Nw    Pw    ::
    :: Pw Pw QW Pw Pw Nw
 Rw    ::    :: Rw :: KW
Dec 04 2008 08-AP9.7 BLACK'S MOVE 16.
Entering INIT_TREE    DEBUG     mode
Enter your move or type PLAY
BLACK'S MOVE   16 
?lj 
CONTINUE (Tracer ?LJ   exit):
play
Entering INIT_TREE
d8e8 f1g1 e8f7 a1b1 e7f5 -99999  617
567 :  617  579  367
-99999 99999 : d8e8 b8b6 b8b7
SCORED   36 /  37 POSNS.   1 /   3  DEPTH =   3   38    0

16.   ... Qe8                     
WHITE'S MOVE   17 
START MIDDLE GAME WHITE
play
START MIDDLE GAME BLACK
f1g1 e8f7 a1b1 b8b6 g2g4 -99999   64
New candidate PV   0    2   64  325  325
g2g4 g8f7 e2a6   63  325
PAB InfiniteError-loop in EXPAND   63 -177 99999 -177 -198   TRUE    2    1  FALSE   TRUE    3    3    0
PAB InfiniteError-loop in EXPAND   63 -177 99999 -177 -198   TRUE    2    2  FALSE   TRUE    3    3    0
PAB InfiniteError-loop in EXPAND   63 -177 99999 -177 -198   TRUE    2    3  FALSE   TRUE    3    3    0
PAB InfiniteError-loop in EXPAND   63 -177 99999 -177 -198   TRUE    2    4  FALSE   TRUE    3    3    0
PAB InfiniteError-loop in EXPAND   63 -177 99999 -177 -198   TRUE    2    5  FALSE   TRUE    3    3    0
g2g4 g8f7 h1g2   63  278
248 :   64  278  215
-99999 99999 : g2g4 f1g1 f1e1
SCORED   64 /  65 POSNS.   2 /   3  DEPTH =   3   38    0

17. g4                 

In procedure EXPAND add "and cnt < 2"  (probably could be cnt < 1 but want errors for now)
        IF PRINCVAR AND IP > 1
        THEN IF ~AGAIN OR T_SCR > HIGHER OR T_SCR < LOWER and cnt < 2
             THEN BEGIN
               IF LEVEL = 1 or display
               THEN WRITE("New candidate PV", FIRSTONE, IP, L_SCR,
                          B_SCR, T_SCR) ;
               IOCONTROL(2) ;
               IF FIRSTONE = 0 AND LEVEL = 1
               THEN FIRSTONE := IP ;
               FULLWIN := AGAIN := TRUE ;
               HIGHER := EIGHTS ;
               LOWER := L_SCR - 1 ;
               IP := IP - 1 ;
             END ELSE AGAIN := FALSE ;
 ----------------------------------------------------------------------------------
?? Dec'08
The following is a reapeatable error.  The previous code prevented the infint loop better and yields:
Dec08
New game? (YES or NO)
no
Enter the board (in quasi Forsythe notation)
KB1P6PQ7888-81Q6884P36P11P3N1P5K2-                                         TFFFFFTKf3              33-E    (45)
START MIDDLE GAME WHITE
START MIDDLE GAME BLACK
    ::    ::    Kb    ::
 :: Pb ::    :: Nb :: Pb
    ::    ::    :: Pb ::
 QW    ::    Pb    ::
 Pw ::    ::    ::    Pw
 ::    ::    :: KW Bw
    Qb    ::    ::    ::
 ::    ::    ::    ::
Dec 12 2008 08-AP9.7 BLACK'S MOVE 45.
Entering INIT_TREE    DEBUG     mode
Enter your move or type PLAY
BLACK'S MOVE   45 
?o
?C-coko= FALSE ?1-dumpp= FALSE ?2-ws=  TRUE ?45= EACH  ?L-lookahead=  TRUE
?M-MONITOR= FALSE ?7-test= FALSE ?Q-quick=  TRUE
?T-tournament= FALSE ?E-examine= FALSE ?V-debug= FALSE
ENDGAME=  TRUE ?J-CAPTURE=  TRUE PAB=  TRUE
CONTINUE (Tracer ?O    exit):
play
Entering INIT_TREE
MAKE_SPACE no nodes    2    3 20000    1   10    3    1    2
h7h5 a5e1 b2a3 -99999 3354
2823 : 3354 2712 2761
-99999 99999 : h7h5 b2b3 b2a3
SCORED   44 /  45 POSNS.   1 /   3  DEPTH =   3   23    0

45.   ... h5                      

Awit =    0  MIN.  USER =    0  MIN.

WHITE'S MOVE   46 
play

Awit =    0  MIN.  USER =    0  MIN.

f3e4 b2g2 e4e3 g2g3 e3e2 -99999 -6174
New candidate PV   0    2 -6174 -2372 -2372
a5c5 f8g7 c5a5 -6175 -2372
a5c5 f8g7 c5e7 -6175 -2060
New candidate PV   2    3 -2060 -1956 -1956
a5a8 f8e7 a4a5 -2061 -1956
PAB InfiniteError-loop in EXPAND -2061 -2572 99999 -2572 -2783   TRUE    2    1  FALSE   TRUE    3    3    0
 Qc5 +       40 -2060
 Bxe5         1 -111
#Ke3          0 -149
a5c5 f8g7 c5e7 -2060 -2060
New candidate PV   2    3 -2060 -2042 -2042
f3e3 f8g7 a5d5 -2061 -2042
PAB InfiniteError-loop in EXPAND -2061 -2412 99999 -2412 -4456   TRUE    2    1  FALSE   TRUE    3    3    0
-2060 -2512 : -2060 -2476 -2412
-99999 99999 : a5c5 f3e3 g3e5
SCORED  113 / 114 POSNS.   1 /   3  DEPTH =   3   14    0

46. Qc5 +  
  
Modifying EXPAND slightly to read:

        IF PRINCVAR AND IP > 1 and cnt < 2
        THEN IF ~AGAIN OR T_SCR > HIGHER OR T_SCR < LOWER
             THEN BEGIN
               IF LEVEL = 1
               THEN WRITE("New candidate PV", FIRSTONE, IP, L_SCR,
                          B_SCR, T_SCR) ;

that is, moving the test "and cnt < 2"

yields:
Dec 14 2008
Awit, a chess program,
Enter ?8 for control options, STOP to terminate.
New game? (YES or NO)
?6
Enter MAXTREE, MAXLEV, TOTAL, WIDTH
If zeros then defaults of 600, 7, 80 and 9 are used
10 3 0 3
  max_plies=   5 max_wid=   9 maxtree=  10 t_size=   8 width=   3
  wsize=  21 rlimit=  15 maxply=   2 depth_limit=   5
  quick-?Q=  TRUE Tournament-?T= FALSE lookahead-?L= FALSE dumpp-?1= FALSE ws-?2=  TRUE
  test-?7= FALSE monitor-?M= FALSE capture_tree-?J= FALSE examine-?E= FALSE
Dec 14 2008
Awit, a chess program,
Enter ?8 for control options, STOP to terminate.
New game? (YES or NO)
no
Enter the board (in quasi Forsythe notation)
?lj
CONTINUE (Tracer ?LJ   exit):
KB1P6PQ7888-81Q6884P36P11P3N1P5K2-                                         TFFFFFTKf3              33-E    (45)
    ::    ::    Kb    ::
 :: Pb ::    :: Nb :: Pb
    ::    ::    :: Pb ::
 QW    ::    Pb    ::
 Pw ::    ::    ::    Pw
 ::    ::    :: KW Bw
    Qb    ::    ::    ::
 ::    ::    ::    ::
Dec 14 2008 08-AP9.7 BLACK'S MOVE 45.
Entering INIT_TREE    DEBUG     mode
Enter your move or type PLAY
BLACK'S MOVE   45 
play
Entering INIT_TREE
MAKE_SPACE no nodes    2    3 20000    1   10    3    1    2
h7h5 a5e1 b2a3 -99999 3354
2823 : 3354 2712 2761
-99999 99999 : h7h5 b2b3 b2a3
SCORED   44 /  45 POSNS.   1 /   3  DEPTH =   3   23    0

45.   ... h5                      

Awit =    0  MIN.  USER =    0  MIN.

WHITE'S MOVE   46 
play

Awit =    0  MIN.  USER =    0  MIN.

f3e4 b2g2 e4e3 g2g3 e3e2 -99999 -6174
New candidate PV   0    2 -6174 -2372 -2372
a5c5 f8g7 c5a5 -6175 -2372
a5c5 f8g7 c5e7 -6175 -2060
New candidate PV   2    3 -2060 -1956 -1956
a5a8 f8e7 a4a5 -2061 -1956
PAB InfiniteError-loop in EXPAND -2061 -2572 99999 -2572 -2783   TRUE    2    1  FALSE   TRUE    3    3    0
a5a8 f8e7 a4a5 -2061 -1956
-1956 -3000 : -6174 -2060 -1956
-99999 99999 : a5a8 a5c5 f3e4
SCORED   71 /  72 POSNS.   3 /   3  DEPTH =   3   13    0

46. Qa8 +                   
BLACK'S MOVE   46 

The generation of 45 .... h5
seems identical, but now Qa8+ is prefered over Qc5+, and one fewer PAB InfiniteError-loop messages
appears, and a significantly lsmaller tree is searched.

---------------------------------------------------------------------
20 Dec'08
Received the error message:
ENPRIS LIST ERROR  57   66   14   10   17   13   15   23   26   32   34   45   48   57   66   45   57    0   54   82   24   55   36
  75   68   77   63   48   45   34   32   26   23   15   13   23
2R1R1K12P2P2PP1P4N3P1PP85Q288+83Q45P283PB32P4RP1P1N1PP1R4K1+                  TFFFFFTQg5              29=M  2 (24)
problem attributed to:
IF T - TOP < 5
  THEN BEGIN
    WRITE("ENPRIS LIST ERROR", BASE, SQ, T, TOP, LOSS(ELIMIT)) ;
in procedure ENPRISLIST

Solution: reduce value 5 to 4 (and wait for the next occurrence).  Cannot go below 1.
Also, see below, changed sizes of SQAXSTQ and SQTXSAQA, to make full space available.
-----------------------------------------------------------------------


20 Dec'08
Hard to tell the difference between procedure epscore and the local variable within epscore of 
the same name.   Perhaps change to procedure EP_SCORE

Done.

-----------------------------------------------------------------
20 Dec'08
Turned DEBUG flag on and obtained the follwing error message from ANALYSE:

COST   6   57   57    0   26  -51  FALSE  FALSE   31   31   17  -51  -51   TRUE 
 FALSE    1  FALSE  FALSE  FALSE   31   31
awit.a:7689:10: array subscript error: subscript 1 of 'sqaxsqt' = 19, outside the range (20::30)
DEBUG error in ANALYSE   19    1    0    5

It seems to me that the arrays SQTxSQA and SQAxSQT are too small.
Don't normally use debug mode.  But the position:

2R1R1K12P2P2PP1P4N3P1PP4B2Q888-83Q45P283P42PB1R2P1P1N1PP1R4K1-                TFFFFFTBXE5              R M 11 (23)
 seems to cause problems.
 
Changed the array bounds for SQAXSQT and SQTXSQA and added a warning message to ANALYSE:
  INTEGER ARRAY SQAXSQT(16::ELIMIT-1, 1::15) ;
  INTEGER ARRAY SQTXSQA(1::15, 16::ELIMIT-1) ;
 
     PCA := PCASAVE ;
    VALSQA := VALUES(PCA) ;
if debug and (i < 20 or i > 30 or jj < 1 or jj > 10) then
write("DEBUG error in ANALYSE ", i, jj, eplist(i), eplist(jj)) ;
    IF DEBUG
    THEN SQAXSQT(I,JJ) := +99 ;
    IF DEBUG
    THEN SQTXSQA(JJ,I) := -99 ;
    
------------------------------------------------------------------------
21 Dec'08 Archived version AP9.7, created version AP9.8
Am worried about a statement in ENPRISLIST
  EPLIST(1) := TOP ;
comment above looks odd ;
  T := LOSS(ELIMIT) ;

 Qg5          0 -66666
ENPRISLIST square(0:31)  10   13   15   23   26   31   32   34   45   55   58   48   57    0    0   32   31   23   26   41   58   68
  77   82   24   75   68   77   78   64   54   27
ENPRISLIST loss(0:31)  12  -27  -27  -51  -49    0  -24  -51    0    0   27    0 -88888    0    0    0    0    0    0 -88888 -88888 -88888
-88888 -88888   57  -39  -27    7 -88888    0    0   23
ENPRISLIST eplist(0:31)  11   12    9    8    5   11    6    2    1    4    7    3   12    0    0    0    0    0    0    0    0   28
  25   28   23   25   26   30   29   27   24   23
  
Made some changes (not recorded) and now the same output from ENPRISLIST is:

 Qg5          0 -66666
ENPRISLIST square(0:31)   4   54   64   66   78   57   82   82   24   82    0    0    0    0    0   13   55   47   58   47   48   58
  13   15   23   26   31   32   34   45   55   22
ENPRISLIST loss(0:31)   5    0    0   12  -51   57 -88888 -88888 -88888 -88906    0    0    0    0    0    0    0    0    0  -51  -51    0
 -27 -88888 -88888 -88888    6  -24 -88888    0   18   19
ENPRISLIST eplist(0:31)   5    5    3    2    1    4    6    9    0    0    0    0    0    0    0    0    0    0    0   28   25   24
  23   20   19   22   27   29   21   26   30   19

---------------------------------------------
27 Dec'08

Changes were not made in ENPRISLIST   
Have compared version AP9.7 and AP9.8 and cannot see anything that would account for this difference.
Have made a close review of ENPRISLIST and believe it to be OK.  That is, it receives moves ordered
with captures and checks first.  The routine finds the value of the best next exchange after the
supplied move is tried, so that the "score" of that move can be more accurately estimated.

The sequence being tried here is
Rh6
with response
Qg5  (as above)

    Rb    ::    :: Kb ::
 Pb    Pb    Nb    Pb Pb
    :: Pb Bb    Rb    ::
 ::    :: Pb Bw    :: QW
 Nw ::    :: Pw :: Pw Pw
 Pw Pw :: Pw :: Pb ::
    :: Pw Qb    Pw    ::
 ::    Rw    Rw    KW
Dec 21 2008 08-AP9.8 BLACK'S MOVE 23.
------------------------------------------------------------------------
27 Dec'08
Reduced the frequency of the "CHECK CAPT" message by qualifying the test in DECOYED to read:
      IF TMP > 0 AND CHEC(TMP, PCA) and brd(sqt) ~= 0
      THEN BEGIN
                  COMMENT if PCA is a Q, R or B and capture of SQT yields
                          a check, then set NORMAL false and SEC <= 0 ;
                          
-----------------------------------------------------
2 Jan 2009
Introduced logical procedure valid_command and used it to unify the two places where input can be 
provided.  This change does not affect the play.
(a) In OPPONENT, where a move is expected.  The change there is:
LOOP:
    IF (BOOK < 1)
    THEN WHILE READU
    DO TRACER(CHARCOUNT, BUFFER(0|20)) ;
    IF THINKING AND BUFFER(0|2) = "OK"
    THEN GOTO THINK ELSE
    if valid_command
    then goto loop
    ELSE IF BUFFER(0|4) = "PLAY"
         THEN NULLMOVE := TRUE
    else BEGIN
      IF ~GETMOVE(U)
      THEN BEGIN

(b) In HUB, where in self-play mode the question about continuation is asked.  Change is:
        WRITE("SHALL I CONTINUE (Yes or No)?") ;
loop:
        WHILE READU
        DO TRACER(CHARCOUNT, BUFFER(0|20)) ;
        if valid_command
        then goto loop
        else
        IF (U(0) = "N") 
        THEN BOTH := WHO := CBOTH := FALSE ;

The new procedure is:

logical procedure valid_command ;
begin
    IF BUFFER(0|5) = "BLITZ"
    THEN BEGIN
      BLITZ ;
      true
    END ELSE IF BUFFER(0|5) = "INTER"
             THEN BEGIN
               INTERMEDIATE ;
               true
    END ELSE IF BUFFER(0|5) = "EXPER"
             THEN BEGIN
               EXPERIMENTAL ;
               true
    END ELSE IF BUFFER(0|5) = "TOURN"
             THEN BEGIN
               TOURNAMENTS ;
               true
    END ELSE IF BUFFER(0|4) = "SWAP"
             THEN BEGIN
               K := -K ;
               WRITE("SIDES SWAPPED. CONTINUE.") ;
               IOCONTROL(2) ;
               true
    end ELSE IF BUFFER(0|3) = "PAB"
             THEN BEGIN
               PAB := ~PAB ;
               WRITE("Palphabeta", PAB) ;
               true
    END ELSE if buffer(0|4) = "FLIP"
             then begin
               flipper ;
               TRACER(2, "?ZK") ;
               true
    end else false
end of_valid_command ;

------------------------------------------------
3 Jan'08
Decided to unify the default and explict (?6) entry points, by moving the summary print statements
and controlling their production by a new logical global variable named "default", as follows:
from:
  packer := 10000 ;
  GO TO ENTER ;
ENTRY:
  WRITE("Enter MAXTREE, MAXLEV, TOTAL, WIDTH") ;

to:
  packer := 10000 ;
  default := true ;
  GO TO ENTER ;
ENTRY:
  default := false ;
  WRITE("Enter MAXTREE, MAXLEV, TOTAL, WIDTH") ;

and from:
  WIDTH := IF (WIDTH <= 0)
           THEN 9
           ELSE IF WIDTH < 5
                THEN 5
                ELSE if width >= w_size
                     then w_size
                     else WIDTH ;
  if maxtree = 10 and width > 3
  then width := 3 ;  comment for DEBUG mode only ;
  WRITE ("  max_plies=", MAX_PLIES, "max_wid=", MAX_WID, "maxtree=", MAXTREE,
        "t_size=", T_SIZE, "width=", WIDTH) ;
  WRITE("  wsize=", WSIZE, "rlimit=", RLIMIT, "maxply=", MAXPLY,
        "depth_limit=", DEPTH_LIMIT) ;
  WRITE("  quick-?Q=", QUICK, "Tournament-?T=", TOURNAMENT,
           "lookahead-?L=", LOOKAHEAD, "dumpp-?1=", DUMPP, "ws-?2=", WS) ;
  WRITE("  test-?7=", TEST, "monitor-?M=", MONITOR,
           "capture_tree-?J=", CAPTURE_TREE, "examine-?E=", EXAMINE) ;
ENTER:
  DEPTH_LIMIT := MAX_PLIES := MAXLEV + MAXPLY ;
  T_SIZE := 8 ;
  S_SIZE := 20 + 2*RLIMIT ;
  TSIZE := S_SIZE + 83 + 2 + 2*ELIMIT ;
  CAPT_WID := 14 ;
  WIDTH_LIMIT := MAX_WID := WIDTH ;
  W_LIM := 4*(CAPT_WID) ;
  INITIALIZE ;

to:			(note also change of w_size to w_size - 1 to eliminate SELECTRTMV conflict)

  WIDTH := IF (WIDTH <= 0)
           THEN 9
           ELSE IF WIDTH < 5
                THEN 5
                ELSE if width >= w_size
                     then w_size - 1
                     else WIDTH ;
  if maxtree = 10 and width > 3
  then width := 3 ;  comment for DEBUG mode only ;
ENTER:
  DEPTH_LIMIT := MAX_PLIES := MAXLEV + MAXPLY ;
  T_SIZE := 8 ;
  S_SIZE := 20 + 2*RLIMIT ;
  TSIZE := S_SIZE + 83 + 2 + 2*ELIMIT ;
  CAPT_WID := 14 ;
  WIDTH_LIMIT := MAX_WID := WIDTH ;
  W_LIM := 4*(CAPT_WID) ;
  if ~ default then begin
    WRITE ("  max_plies=", MAX_PLIES, "max_wid=", MAX_WID, "maxtree=", MAXTREE,
          "t_size=", T_SIZE, "width=", WIDTH) ;
    WRITE("  wsize=", WSIZE, "rlimit=", RLIMIT, "maxply=", MAXPLY,
          "depth_limit=", DEPTH_LIMIT) ;
    WRITE("  quick-?Q=", QUICK, "Tournament-?T=", TOURNAMENT,
             "lookahead-?L=", LOOKAHEAD, "dumpp-?1=", DUMPP, "ws-?2=", WS) ;
    WRITE("  test-?7=", TEST, "monitor-?M=", MONITOR,
             "capture_tree-?J=", CAPTURE_TREE, "examine-?E=", EXAMINE) ;
  end ;
  INITIALIZE ;
  
  --------------------------------------------------------