Page 1 of 1

For Jim: Interested in a bugfix in TSCP?

PostPosted: 12 Dec 2006, 11:05
by Guenther Simon
Hi Jim,

In CCC a little thread about weaker engines somehow
evolved into an underpromotion problem in TSCP and
an easy fix in the source. As I have no good compiler
handy at home I thought I let you know ;-)

Best regards,
Guenther

It is easy to fix the underpromotion problem

you only need to change N B and R to small letters in the following code from tscp

Code:
Code: Select all
int parse_move(char *s)
{
   int from, to, i;

   /* make sure the string looks like a move */
   if (s[0] < 'a' || s[0] > 'h' ||
         s[1] < '0' || s[1] > '9' ||
         s[2] < 'a' || s[2] > 'h' ||
         s[3] < '0' || s[3] > '9')
      return -1;

   from = s[0] - 'a';
   from += 8 * (8 - (s[1] - '0'));
   to = s[2] - 'a';
   to += 8 * (8 - (s[3] - '0'));

   for (i = 0; i < first_move[1]; ++i)
      if (gen_dat[i].m.b.from == from && gen_dat[i].m.b.to == to) {

         /* if the move is a promotion, handle the promotion piece;
            assume that the promotion moves occur consecutively in
            gen_dat. */
         if (gen_dat[i].m.b.bits & 32)
            switch (s[4]) {
               case 'N':
                  return i;
               case 'B':
                  return i + 1;
               case 'R':
                  return i + 2;
               default:  /* assume it's a queen */
                  return i + 3;
            }
         return i;
      }

   /* didn't find the move */
   return -1;
}




Back to top

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 12 Dec 2006, 14:24
by Jim Ablett
Hi Guenther,

Yes, very interested :D

http://www.mydatabus.com/public/deckard/z/tscp181a_bugfix__intel.zip

Updated in a little bit while I was at it.

Winboard protocol 2, ping command and a few ICS commands.

Intel compiler 9.1 PGO build.

Regards,
Jim.

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 13 Dec 2006, 05:39
by Tony Thomas
Jim Ablett wrote:Hi Guenther,

Yes, very interested :D

http://www.mydatabus.com/public/deckard/z/tscp181a_bugfix__intel.zip

Updated in a little bit while I was at it.

Winboard protocol 2, ping command and a few ICS commands.

Intel compiler 9.1 PGO build.

Regards,
Jim.


May be you should call yourself Speedy Jim. :mrgreen:

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 13 Dec 2006, 07:57
by Jim Ablett
Hi Tony,

May be you should call yourself Speedy Jim.


You wouldn't say that if you knew how long it takes me to get up in the morning! :D

Regards,
Jim.

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 13 Dec 2006, 14:38
by Tony Thomas
Jim Ablett wrote:Hi Tony,

May be you should call yourself Speedy Jim.


You wouldn't say that if you knew how long it takes me to get up in the morning! :D

Regards,
Jim.


There's gotta be something that annoys you even when you are sleeping. I wouldnt wake up even if there is a rock music party inside my house but I would wake up if someone were to walk in to my room without making much noise. Isnt that weird?

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 14 Dec 2006, 02:08
by Dann Corbit
How about:
Code: Select all

/* parse the move s (in coordinate notation) and return the move's
   index in gen_dat, or -1 if the move is illegal */

int             parse_move(char *s)
{
    int             from,
                    to,
                    i;

    /* make sure the string looks like a move */
    if (s[0] < 'a' || s[0] > 'h' ||
        s[1] < '0' || s[1] > '9' ||
        s[2] < 'a' || s[2] > 'h' ||
        s[3] < '0' || s[3] > '9')
        return -1;

    from = s[0] - 'a';
    from += 8 * (8 - (s[1] - '0'));
    to = s[2] - 'a';
    to += 8 * (8 - (s[3] - '0'));

    for (i = 0; i < first_move[1]; ++i)
        if (gen_dat[i].m.b.from == from && gen_dat[i].m.b.to == to) {

            /* if the move is a promotion, handle the promotion piece; assume
             * that the promotion moves occur consecutively in gen_dat. */
            if (gen_dat[i].m.b.bits & 32)
                switch (s[4]) {
                case 'N':
                case 'n':
                    return i;
                case 'B':
                case 'b':
                    return i + 1;
                case 'R':
                case 'r':
                    return i + 2;
                default:        /* assume it's a queen */
                    return i + 3;
                }
            return i;
        }
    /* didn't find the move */
    return -1;
}

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 16 Dec 2006, 10:40
by Jim Ablett
Hello Dann,

Yes, still needs to be able recognize the caps promote letters.

Jim.

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 16 Dec 2006, 11:00
by Jim Ablett

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 17 Dec 2006, 02:30
by Pedro Castro
Hi Jim,

In TSCP the function print_result is has an error in the repetitions. When rep () == 3 the position already has played 4 times. It would have to be:

Code: Select all
   else if (rep() == 2)
      printf("1/2-1/2 {Draw by repetition}\n");


I was proving TSCP to play on winboard, I played vs TSCP. I am surprised that if you made a move illegal, TSCP continued playing, I believe that modifying a little the function parse_move could be avoided this.

Sorry, the code is the DanaSah in Spanish.

Code: Select all
void Comprobar_Movimiento(char *s)       //comprueba si llega un movimiento del usuario
{
   int de, a, tipo, i;
   int contar;
    movimiento   lista[218];

   //comprueba si estamos recibiendo un movimiento
   if (s[0] < 'a' || s[0] > 'h' ||
      s[1] < '0' || s[1] > '9' ||
      s[2] < 'a' || s[2] > 'h' ||
      s[3] < '0' || s[3] > '9') {
      printf("Error (unknown command): %s\n", s);
      return;
      }

   de = s[0] - 'a';
    de += 8 * (8 - (s[1] - '0'));
    a = s[2] - 'a';
    a += 8 * (8 - (s[3] - '0'));
   tipo = NORMAL;

   //comprueba si es correcto realizar una promociĆ³n
   if (pieza[de] == PEON && (a < 8 || a > 55)) {
      if (s[4] == 'q' || s[4] =='Q')
         tipo = PROMOCION_A_DAMA;
      else if (s[4] == 'r' || s[4] == 'R')
         tipo = PROMOCION_A_TORRE;
      else if (s[4] == 'b' || s[4] == 'B')
         tipo = PROMOCION_A_ALFIL;
      else if (s[4] == 'n' || s[4] == 'N')
         tipo = PROMOCION_A_CABALLO;
   }

   if (Comprobar_Tipo_Movimiento(de, a, s) != NINGUNO)
      tipo = Comprobar_Tipo_Movimiento(de, a, s);

   ply = 0;

    contar = Generar(turno, lista);
    /* recorre todos los movimientos para ver si es legal */
   for (i = 0; i < contar; i++) {
      if (lista[i].de == de && lista[i].a == a && lista[i].tipo == tipo) {
         if (Hacer_Movimiento(lista[i]))
            return;
         else {
            Deshacer();
            continue;
         }
      }
   }
   printf("Illegal move: %s\n", s);
   return;
}


Code: Select all
...
      if (strcmp(comando, "resume") == 0) {
         continue;
      }
      Comprobar_Movimiento(comando);      //comprueba si llega un movimiento del usuario y es legal
      contar = Generar(turno, lista);      //comprueba si tenemos movimientos para hacer
      imprime_resultado(contar, lista);   //si es final imprime un resultado en pantalla
      if (salir == VERDADERO){         //si es final de partida el motor deja de jugar
         motor = VACIO;
         njugadas=0;
         continue;
      }
   }
}

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 18 Dec 2006, 11:05
by Jim Ablett
Hello Pedro,

Thanks for bug reports and fixes. I never noticed these
bugs before (I used TSCP a lot), but thats because I also
use Arena a lot and that handles these things itself.

It would be nice if you could add these fixes and maybe
send me the modified source for compiling. (My Spanish is
terrible) :?

Regards,
Jim.

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 18 Dec 2006, 15:16
by Pedro Castro
Hello Jim,

I send the changes to your e-mail.

Re: For Jim: Interested in a bugfix in TSCP?

PostPosted: 19 Dec 2006, 00:09
by Jim Ablett
Intel compiler 9.1 PGO with Pedro's fixes.

http://www.eggdisk.com/files/141477_piurv/tscp181c%28bugfix%29.zip

Thanks Pedro.

Jim.