Notice:

You *must* do the ?L command for Awit to do any sort of 'look-ahead'
search.  If you don't, then it'll return an anvalid move.  In fact,
it'll return the move you just made and your piece will disapear!

After you've done the ?L command, the first move it makes may not be
searched if it didn't find an opening move in the book.  This is
because the test in 'COMPUTER' is if (movecount > 1)...



****************  Changes to the original source.


************  Porting change

In Tracer, I change the lines

          WRITE("NODES ",NOD, "TERMINAL ",TOT, "DYNAMIC ", DYN,"CAPTURE
            ",CAP) ;


to

          WRITE("NODES ",NOD, "TERMINAL ",TOT, "DYNAMIC ", DYN,
           "CAPTURE ",CAP) ;


The string was split across two lines and that shouldn't happen.


*********** Porting change

After the variable declarations and before Initiailize()
I added the following two external func declarations

Procedure Get(Integer Value N);
Fortran "get" ;

Procedure Put(Integer Value N);
Fortran "put";


*********** Porting change

The names for wo of the predefined external routines need to 
be changed.


Attention from:
FORTRAN "ATTN#   " ;
to
FORTRAN "ATTENTION" ;

because 'attn#' is an invalid C name


Dater from:
FORTRAN "TIME" ;
to
FORTRAN "DATER" ;

because 'time' would conflict with C's time function.



*********** Porting change.

Way down near the end of the program, after procedure NEWHASH
has been defined as being external, you'll see the lines:

  FLAG(1) := 1 ;
  ATTENTION(FLAG) ;
  TTYOUT := 6 ;
  GET(5) ;
  PUT(TTYOUT) ;

Put the following lines above that.  Right above the FLAG(1) line.

  *{void Init_Support(int argc,char **argv);
    Init_Support(argc,argv);
   };

This tells the Aw2c converter to put code there that calls the C
based support library.  This way we can initialize the data file,
set up the temp filenames, etc. etc. that are needed to prented
we are running on MTS.


********** Usability change

In two places, there are a couple lines like:

        WRITE("$COPY WITA:COMMANDS .......

Comment out that line and uncomment the line following it.

For the first one (that gives the history of WITA / AWIT) you'll
need to move the word program and the quote up to the end of the
line, so string wont be split across lines.


*********** Usability change.
In ReadU I added

comment convert input into uppercase ;
comment Makes input easier on modern keyboards ;
for i := 0 until charcount do
  if ((decode(buffer(i|1)) > 128) and (decode(buffer(i|1)) <= 170))
  then buffer(i|1) := code(decode(buffer(i|1)) + 64);

right before it strips the trailing blanks


************* Usability change

To handle blank lines in the opening book creation code

Add the if (len=0) line to CreateBook

so it says:

    IF (LEN < 0)
    THEN BOOK := -BOOK
    else if (len = 0) then go to readin



************ usability change

In printshortbrd I change the line:
  WRITE(DATE(0|8), "AP1.0 ", COLOR(K),"'S MOVE ", MOVECOUNT,". ") ;

to
  WRITE(DATE(0|12), "AP1.0 ", COLOR(K),"'S MOVE ", MOVECOUNT,". ") ;

so the date can be printed better.

If you make this change, in support.c, in the routine 'dater' you
can change the #if 1 to #if 0 to select the more descriptive date.



********** Bugfix

Con & Control arrays are too small.  They don't allow for 'hole'
as well as not allowing for situations where sqr+inc may be on
the border row.

These cases are reads and are probably a silent problem unless
you do array bounds checking.

Change

  INTEGER ARRAY CONTROL (11::88,-8::8) ;
  INTEGER ARRAY CON (-1::1,11::88) ;

to

  INTEGER ARRAY CONTROL (-11::109,-8::8) ;
  INTEGER ARRAY CON (-1::1,-11::109) ;


In "STARTTHISPROBLEM" before the for sq loop (that ends with 
"end forsq ;") add the following lines:

for sq := -11 until 109 do
  begin
    CON(-1,SQ) := CON(0,SQ) := CON(1,SQ) := 0 ;
    CONTROL(SQ,-1) := CONTROL(SQ,0) := CONTROL(SQ,1) := 0;
  end;


This change is easier than fixing the few problem areas that
are found and missing some that haven't shown up in testing.



**************** Bugfix
In sacrifice

Add the line:

if (i >= wqrsq) and (i <= bkrsq) then

so it says

             if (i >= wqrsq) and (i <= bkrsq) then
               IF TMP > 0 AND L ~= 0 AND ABS(ROWS(SQ)-ROWS(I))
                 = 1 AND KK*SEC(0,I-FILES(KK)) > 0
               THEN TMP := 0 ;




**************** Bugfix
There is an array bounds violation in EPScore with the array

ASQRS(ELIMIT-10::ELIMIT)

The array is 21::31 and it's being called with an index of 20.

I don't know why.  I can't trace the data back far enough to see
exactly why the lower bound is being violated.

EPScore is being called by EnPrisList, but I still don't understand
the data.

Since I had to recreate the missing data file, I thought the problem
might be incorrect data, so I played with it and I couldn't get
the error to change.  That suggests my data might not be at fault.

But it still doesn't explain why ASQRS is sometimes called with an
index of 20, which is below ELIMIT-10 (which is 21.)

Since I can't explain it and the violation is only by 1...

Change

    INTEGER ARRAY ASQRS(ELIMIT-10::ELIMIT) ;

to

    INTEGER ARRAY ASQRS(0::ELIMIT) ;


************* Bugfix

In Checker, change:

         IF (PC = -K_PAWN) OR ((PC = NIL) AND (PAWNS(SQA+2*K_FILE)
           = K_PAWN))
         THEN BEGIN
           I := I - K ;
         COMMENT note con(k,sqa) is not changed ;

to:


         IF (PC = -K_PAWN) OR ((PC = NIL) AND
                               ((sqa+2*k_file >= 11) AND (sqa+2*k_file <= 88)
                                AND (PAWNS(SQA+2*K_FILE) = K_PAWN)) )
         THEN BEGIN
           I := I - K ;
         COMMENT note con(k,sqa) is not changed ;


******* Bugfix

In HIDDEN, it's possible for it to think an 'enpris' piece is a
real piece.

change:

  WHILE (BRD(SQ) = EMPTY)

to:

  WHILE ((BRD(SQ) = EMPTY) or (abs(brd(sq)) = enpris))



****** Bugfix

In usebook change:

    IF LOOKAHEAD THEN BOOK := 0;

to:

    BOOK := 0;

Otherwise you can get some screwy behavior if there is no opening
book or you run out of moves unexpected.


******* Bugfix

At the end of the procedure Terminate (near END OF_TERMINATE)
there's a bounds violation when RefTab is done with an index of 0.

Looks like it might be a simple array bounds issue wihtout any
hidden cause.

So add the two 'if' lines to protect them so it says:


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;


****** Bugfix

The RList & TList arrays can overflow in ReMake.

This seems due to the variables REMEMBER and TERMINAL being set to
unexpected values for the situation.

MobilityScore calls TryThem to determine whether a move is legal and
to generate a score for it.

Unfortuantely, the variables REMEMBER and TERMINAL get trashed and
MakeMove's behavior is not what TryThem expects.

The best solution I've found is to add the folliwng line

terminal := remember := true ;

right before the MAKEMOVE(N,FALSE) ; line in TryThem.

[This fix corrected a problem with array overflow in RLIST and TLIST.  However, it also has the 
effect of disabling the incremental move feature (time saver) as part of the 
mobilityscore evaluation, TAM 22 sept'08]

14 Sept 2008
1) For all the arrays that were declared to MAX_PLIES, I changed that to 91.

I got a couple of bounds errors about refline.  Since it was REFLINE(Lev) I figured it wasn't 
just that one case, so I changed all the arrays that were declared to max_plies.  I figured it'd be 
safer.

I used 91 because it wasn't used anywhere else in the program.  So it can be changed back pretty 
easily if needed.


2) I put the changes in SACRIFICE back to the way it was in changes.txt

This can be redone later, but I needed it 'fixed' so I could run my tests.


3) I put a call to INIT_TREE in HUB, and in INIT_TREE, I'm clearing a bunch of vars.

I originally was just clearing STATES(), but I got one error that I used to get in my version.  
When I cleared all the vars in my version, the error never showed up again.  So I did that in yours 
too.

[The extra initializations in INIT_TREE are excessive and invalidate the necessary draw detection 
mechanism that is used during tree search to provide a correct score for draw by repetition. 
TAM 22 Sep'08]


