For Jim: Interested in a bugfix in TSCP?

Discussions about Winboard/Xboard. News about engines or programs to use with these GUIs (e.g. tournament managers or adapters) belong in this sub forum.

Moderator: Andres Valverde

For Jim: Interested in a bugfix in TSCP?

Postby Guenther Simon » 12 Dec 2006, 11:05

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
User avatar
Guenther Simon
 
Posts: 794
Joined: 26 Sep 2004, 19:49
Location: Regensburg, Germany

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

Postby Jim Ablett » 12 Dec 2006, 14:24

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.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

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

Postby Tony Thomas » 13 Dec 2006, 05:39

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:
Tony Thomas
 
Posts: 232
Joined: 14 May 2006, 19:13
Location: Atlanta, Ga

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

Postby Jim Ablett » 13 Dec 2006, 07:57

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.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

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

Postby Tony Thomas » 13 Dec 2006, 14:38

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?
Tony Thomas
 
Posts: 232
Joined: 14 May 2006, 19:13
Location: Atlanta, Ga

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

Postby Dann Corbit » 14 Dec 2006, 02:08

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;
}
Dann Corbit
 

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

Postby Jim Ablett » 16 Dec 2006, 10:40

Hello Dann,

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

Jim.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

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

Postby Jim Ablett » 16 Dec 2006, 11:00

___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

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

Postby Pedro Castro » 17 Dec 2006, 02:30

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;
      }
   }
}
Best wishes,

Pedro Castro
User avatar
Pedro Castro
 
Posts: 180
Joined: 28 Jan 2005, 01:09
Location: Pays Basque (Spain)

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

Postby Jim Ablett » 18 Dec 2006, 11:05

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.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England

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

Postby Pedro Castro » 18 Dec 2006, 15:16

Hello Jim,

I send the changes to your e-mail.
Best wishes,

Pedro Castro
User avatar
Pedro Castro
 
Posts: 180
Joined: 28 Jan 2005, 01:09
Location: Pays Basque (Spain)

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

Postby Jim Ablett » 19 Dec 2006, 00:09

Intel compiler 9.1 PGO with Pedro's fixes.

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

Thanks Pedro.

Jim.
___________________________
http://jimablett.net63.net/
Jim Ablett
 
Posts: 721
Joined: 27 Sep 2004, 10:39
Location: Essex, England


Return to Winboard and related Topics

Who is online

Users browsing this forum: No registered users and 28 guests