INFO: Dieses Forum nutzt Cookies...
Cookies sind für den Betrieb des Forums unverzichtbar. Mit der Nutzung des Forums erklärst Du dich damit einverstanden, dass wir Cookies verwenden.

Es wird in jedem Fall ein Cookie gesetzt um diesen Hinweis nicht mehr zu erhalten. Desweiteren setzen wir Google Adsense und Google Analytics ein.

Antwort schreiben 
 
Themabewertung:
  • 1 Bewertungen - 5 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
kniffeliger Compilerfehler - ich verzweifle noch....
15.11.2014, 19:46 (Dieser Beitrag wurde zuletzt bearbeitet: 16.11.2014 21:58 von HaWe.)
Beitrag #1
kniffeliger Compilerfehler - ich verzweifle noch....
ich verzweifle noch....

der folgende Code läuft einwandfrei als Konsolenprogramm (z.B. mit devcpp):
Code:
/***************************************************************************/
/*                               micro-Max,                                */
/* A chess program smaller than 2KB (of non-blank source), by H.G. Muller  */
/***************************************************************************/
/* version 4.8.i (1953 characters) features:                                 */
/* - recursive negamax search                                              */
/* - all-capture MVV/LVA quiescence search                                 */
/* - (internal) iterative deepening                                        */
/* - best-move-first 'sorting'                                             */
/* - a hash table storing score and best move                              */
/* - futility pruning                                                      */
/* - king safety through magnetic, frozen king in middle-game              */
/* - R=2 null-move pruning                                                 */
/* - keep hash and repetition-draw detection                               */
/* - better defense against passers through gradual promotion              */
/* - extend check evasions in inner nodes                                  */
/* - reduction of all non-Pawn, non-capture moves except hash move (LMR)   */
/* - full FIDE rules (expt under-promotion) and move-legality checking     */


#define K(A,B) *(int*)(T+A+(B&8)+S*(B&7))


#define HTsize (1<<8) // (1<<24)
struct HTab {
          long K,
               V;
          int  X,
               Y,
               D;
        } HTarray[HTsize];           /* hash table, HTsize entries*/
        
        
#define MAXNODES 60000

long K,  
     Q,
     R,
     J,
     Z;
    
long N,
     I=30000;                         /* I=80000: "infinity score" */ ;                          

int M=136,                           /* M=0x88   board system    */
    S=128,                           /* dummy square 0x80, highest valid square =127    */
    turn=16;            

char L,
     pval[]={0,2,2,7,-1,8,12,23},                      /* relative piece values    */
     vector[]={-16,-15,-17,0,1,16,0,1,16,15,17,0,14,18,31,33,0, /* step-vector lists */
          7,-1,11,6,8,3,6},                          /* 1st dir. in vector[] per piece*/
    
     bsetup[]={6,3,5,7,4,5,3,6},                         /* initial piece setup      */
     board[129],                                        /* board: half of 16x8+dummy*/
     T[1035];                                        /* hash translation table   */

char psymbol[]= ".?+nkbrq?*?NKBRQ";

char mfrom, mto;    // current ply from - to
int  EPSQ,
     RemP;           // remove piece




/* recursive minimax search, turn=moving side, n=depth*/

long Minimax(long q, long l, long score, long EPC, long prev, long hashkey)        
                       /* (q,l)=window, score, EnPass_sqr.*/
                       /* prev=prev.dest; J,Z=hashkeys; return score*/
{
   long j,
        r,
        m,
        v,
        d,
        h,
        i,
        F,
        G,
        V,
        P,
        f=J,
        g=Z,
        C,
        s;
   char t,
        p,
        upiece,
        x,
        y,
        X,
        Y,
        H,
        B;
  
   struct HTab *a = HTarray + (J + turn * EPC & HTsize-1);   /* lookup pos. in hash table*/





   q--;                                          /* adj. window: delay bonus */
   turn^=24;                                        /* change sides             */
   d=a->D;
   m=a->V;
   X=a->X;
   Y=a->Y;                  /* resume at stored depth   */
  
   if(a->K-Z|prev|                                  /* miss: other pos. or empty*/
      !(m<=q | X&8&&m>=l | X&S))                   /*   or window incompatible */
      { d=Y=0; }                                /* start iter. from scratch */
  
   X&=~M;                                        /* start at best-move hint  */

   while( d++ < hashkey || d<3                   /* iterative deepening loop */
     || prev&K == I
       && ( N<60000 & d<98                        /* root: deepen upto time   */
          || (K=X, L=Y&~M, d=3)
       )
     )                                          /* time's up: go do best    */
   {
      x=B=X;                                       /* start scan at prev. best */
      h=Y&S;                                       /* request try noncastl. 1st*/
      P=d<3 ? I : Minimax(-l,1-l,-score,S,0,d-3);               /* Search null move         */
      m = (-P<l | R>35) ? ( d>2 ? -I : score ) : -P;            /* Prune or stand-pat       */
      N++;                                         /* node count (for timing)  */
      do
      {
         upiece=board[x];                                   /* scan board looking for   */
         if(upiece & turn)                                  /*  own piece (inefficient!)*/
         {
            r = p = upiece&7;                               /* p = piece type (set r>0) */
            j = vector[p+16];                                 /* first step vector f.piece*/
            while(r = p>2 & r<0 ? -r : -vector[++j] )       /* loop over directions vector[] */
            {
labelA:                                        /* resume normal after best */
               y=x;                            /* (x,y)=move         */
               F=G=S;                          /* (F,G)=castl.R      */
              
               do
               {                                       /* y traverses ray, or:     */
                  H=y=h?Y^h:y+r;                           /* sneak in prev. best move */
                
                  if(y&M)break;                            /* board edge hit           */
                
                  m= EPC-S&board[EPC]&&y-EPC<2&EPC-y<2?I:m;      /* bad castling             */
                
                  if(p<3&y==EPC)H^=16;                           /* shift capt.sqr. H if e.p.*/
                
                  t=board[H];
                
                  if(t&turn|p<3&!(y-x&7)-!t)break;            /* capt. own, bad pawn mode */
                  i=37*pval[t&7]+(t&192);                     /* value of capt. piece t   */
                  m=i<0?I:m;                                  /* K capture                */
                
                  if(m>=l&d>1) goto labelC;                     /* abort on fail high       */
          
                  v=d-1?score:i-p;                             /* MVV/LVA scoring          */
                
                  if(d-!t>1)                               /* remaining depth          */
                  {
                     v=p<6?board[x+8]-board[y+8]:0;                  /* center positional pts.   */
                     board[G]=board[H]=board[x]=0;board[y]=upiece|32;             /* do move, set non-virgin  */
                     if(!(G&M))board[F]=turn+6,v+=50;               /* castling: put R & score  */
                     v-=p-4|R>29?0:20;                              /* penalize mid-game K move */
                    
                     if(p<3)                                        /* pawns:                   */
                     {
                        v-=9*((x-2&M||board[x-2]-upiece)+              /* structure, undefended    */
                               (x+2&M||board[x+2]-upiece)-1            /*        squares plus bias */
                              +(board[x^16]==turn+36))                 /* kling to non-virgin King */
                              -(R>>2);                                 /* end-game Pawn-push bonus */
                         V=y+r+1&S?647-p:2*(upiece&y+16&32);           /* promotion or 6/7th bonus */
                         board[y]+=V;
                         i+=V;                                         /* change piece, add score  */
                     }
                    
                     v+= score+i;
                     V=m>q ? m : q;                           /* new eval and alpha       */
                     J+=K(y+0,board[y])-K(x+0,upiece)-K(H+0,t);
                     Z+=K(y+8,board[y])-K(x+8,upiece)-K(H+8,t)+G -S;  /* update hash key          */
                     C=d-1-(d>5&p>2&!t&!h);
                     C=R>29|d<3|P-I?C:d;                     /* extend 1 ply if in check */
                     do {
                        s=C>2|v>V?-Minimax(-l,-V,-v,         /* recursive eval. of reply */
                                            F,0,C):v;        /* or fail low if futile    */
                     } while( s>q & ++C<d );
                  
                     v=s;
                     if(prev&&K-I&&v+I&&x==K&y==L)              /* move pending & in root:  */
                     {
                        Q=-score-i; EPSQ=F;                            /*   exit if legal & found  */
                        a->D=99;a->V=0;                        /* lock game in hash as draw*/
                        R+=i>>7;
                        return l;                            /* captured non-P material  */
                     }
                     J=f;
                     Z=g;                                    /* restore hash key         */
                     board[G]=turn+6;
                     board[F]=board[y]=0;
                     board[x]=upiece;
                     board[H]=t;                             /* undo move,G can be dummy */
                  }
                  if(v>m)                                  /* new best, update max,best*/
                  {
                     m=v,X=x,Y=y|S&F;                      /* mark double move with S  */
                  }                      
                  if(h)
                  {
                     h=0;
                     goto labelA;                           /* redo after doing old best*/
                  }                
                  if (
                    x+r-y|upiece&32|                             /* not 1st step,moved before*/
                    p>2 & (
                      p-4|j-7||                             /* no P & no lateral K move,*/
                      board[G=x+3^r>>1&7]-turn-6            /* no virgin R in corner G, */
                      || board[G^1] | board[G^2] )          /* no 2 empty sq. next to R */
                    )
                  {
                     t+=p<5;
                  }                                        /* fake capt. for nonsliding*/
                  else F=y;                                /* enable e.p.              */
                
               } while(!t);                               /* if not capt. continue ray*/
        
            }
         }  // (upiece & turn)
    
      } while((x=x+9&~M)-B);                       /* next sqr. of board, wrap */
  
labelC:
      if (m>I-M|m<M-I) d=98;                       /* mate holds to any depth  */
      m= m+I|P==I ? m : 0;                         /* best loses K: (stale)mate*/
    
      if(a->D<99) {                                /* protect game history     */
         a->K=Z;
         a->V=m;
         a->D=d;                       /* always store in hash tab */
         a->X=X|8*(m>q)|S*(m<l);
         a->Y=Y;                       /* move, type (bound/exact),*/
      }
      /* uncomment for Kibitz */
      if(!((N-S)%987)) printf("searched: %d\r",N-S);
      /*
      if(prev){
           printf("%2d ply, %9d searched, score=%6d by %c%c%c%c\n", d-1, N-S, m,
                   'a'+(X&7),'8'-(X>>4),'a'+(Y&7),'8'-(Y>>4&7));       /*    encoded in X S,8 bits  
      }  
      */
   }  // while (iterative deepening loop)                                          

   turn^=24;                                        /* change sides back        */
   mfrom=K; mto=L;
   return m+= m<score;                                  /* delayed-loss bonus       */
}







main()
{
   long score;
   char sbuf[50], sbuf2[50];
   char oboard[129];
   char oldto, oldEPSQ;
   int  *key;
   int  cstring[20];
  
   K=8;
   while(K--)
   {
      board[K]=(board[K+112]=bsetup[K]+8)+8;
      board[K+16]=18;
      board[K+96]=9;                               /* initial board setup*/
      L=8;
      while(L--)board[16*L+K+8]=(K-4)*(K-4)+(L-3.5)*(L-3.5);     /* center-pts table   */
   }                                                             /*(in unused half board[])*/
   N=1035;
   while(N-->M)T[N]=rand()>>9;
  
                                                                /* play loop          */
   while(1)                                              
   {
     N=-1;
    
     printf("\n");
     while(++N<121) {                                            /* print board */
        sprintf(sbuf," %c", N&8 && (N+=7) ? 10 : psymbol[board[N]&15]);
        printf(sbuf);
     }
    
     if(turn==16) sprintf(sbuf,"\n>  WHITE: ");  else sprintf(sbuf,"\n>   BLACK:  ");  
     printf(sbuf);
    
     key=cstring;    
     while( (*key++ =getchar() ) > 10 );                 /* read input line    */
     K=I;                                                /* invalid move       */
    
     if(*cstring-10) {                                   /* parse entered move */
       K= (char)cstring[0]-16*cstring[1]+799;
       L= (char)cstring[2]-16*cstring[3]+799;
     }
    
     memcpy(oboard, board, sizeof(board));
     oldto=mto;
     oldEPSQ=EPSQ;
     score=Minimax(-I, I, Q, EPSQ, 1, 3);           /* think or check & do*/    
     printf("\nscore="); printf("%d \n",score);
    // if(score!=15) {                    
        RemP=S;  
        if(oboard[mto])   RemP=mto;
        if(mto==oldEPSQ)  RemP=oldto;
                                      
        sprintf(sbuf,"\n\nmoved: >> %c%c", 'a'+(mfrom&7),'8'-(mfrom>>4) );
      
        if(oboard[mto]) strcat(sbuf," X ");
        else strcat(sbuf,"-");
      
        sprintf(sbuf2,"%c%c ", 'a'+(mto&7),'8'-(mto>>4&7));
        strcat(sbuf, sbuf2);
        printf(sbuf);
    
        sprintf(sbuf, " (square %d to %d ) \n", mfrom, mto);
        printf("\n\nDEBUG:\n");
        sprintf(sbuf2,"  EPsq: %c%c (%d)\n  RemP: %c%c (%d)",
                         'a'+(EPSQ&7), '8'-(EPSQ>>4&7), EPSQ,
                         'a'+(RemP&7), '8'-(RemP>>4&7), RemP);
        strcat(sbuf, sbuf2);
        printf(sbuf);
        printf("\n\n");
   //  }
    // else printf("\n\nILLEGAL!\n");

   }
}

so, jetzt der angepasste Code für Sketch (Mega oder Due):
Code:
/***************************************************************************/
/*                               micro-Max,                                */
/* A chess program smaller than 2KB (of non-blank source), by H.G. Muller  */
/***************************************************************************/
/* version 4.8.i (1953 characters) features:                                 */
/* - recursive negamax search                                              */
/* - all-capture MVV/LVA quiescence search                                 */
/* - (internal) iterative deepening                                        */
/* - best-move-first 'sorting'                                             */
/* - a hash table storing score and best move                              */
/* - futility pruning                                                      */
/* - king safety through magnetic, frozen king in middle-game              */
/* - R=2 null-move pruning                                                 */
/* - keep hash and repetition-draw detection                               */
/* - better defense against passers through gradual promotion              */
/* - extend check evasions in inner nodes                                  */
/* - reduction of all non-Pawn, non-capture moves except hash move (LMR)   */
/* - full FIDE rules (expt under-promotion) and move-legality checking     */


#define K(A,B) *(int*)(T+A+(B&8)+S*(B&7))


#define HTsize (1<<8) // (1<<24)
struct HTab {
          int  K,
               V;
          int  X,
               Y,
               D;
        } HTarray[HTsize];           /* hash table, HTsize entries*/
        
        
#define MAXNODES 60000

int  K,  
     Q,
     R,
     J,
     Z;
    
long N,
     I=30000;                         /* I=80000: "infinity score" */ ;                          

int
    M=136,                           /* M=0x88   board system    */
    S=128,                           /* dummy square 0x80, highest valid square =127    */
    turn=16;            

char L,
     pval[]={0,2,2,7,-1,8,12,23},                      /* relative piece values    */
     vector[]={-16,-15,-17,0,1,16,0,1,16,15,17,0,14,18,31,33,0, /* step-vector lists */
          7,-1,11,6,8,3,6},                          /* 1st dir. in vector[] per piece*/
    
     bsetup[]={6,3,5,7,4,5,3,6},                         /* initial piece setup      */
     board[129],                                        /* board: half of 16x8+dummy*/
     T[1035];                                        /* hash translation table   */

char psymbol[]= ".?+nkbrq?*?NKBRQ";

char mfrom, mto;    // current ply from - to
int  EPSQ,
     RemP;           // remove piece




/* recursive minimax search, turn=moving side, n=depth*/

int  Minimax(int  q, int  l, int  score, int  EPC, int  prev, int  hashkey)        
                       /* (q,l)=window, score, EnPass_sqr.*/
                       /* prev=prev.dest; J,Z=hashkeys; return score*/
{
   int  j,
        r,
        m,
        v,
        d,
        h,
        i,
        F,
        G,
        V,
        P,
        f=J,
        g=Z,
        C,
        s;
   char t,
        p,
        upiece,
        x,
        y,
        X,
        Y,
        H,
        B;
  
   struct HTab *a = HTarray + (J + turn * EPC & HTsize-1);   /* lookup pos. in hash table*/

   char sbuf[50];



   q--;                                          /* adj. window: delay bonus */
   turn^=24;                                        /* change sides             */
   d=a->D;
   m=a->V;
   X=a->X;
   Y=a->Y;                  /* resume at stored depth   */
  
   if(a->K-Z|prev|                                  /* miss: other pos. or empty*/
      !(m<=q | X&8&&m>=l | X&S))                   /*   or window incompatible */
      { d=Y=0; }                                /* start iter. from scratch */
  
   X&=~M;                                        /* start at best-move hint  */

   while( d++ < hashkey || d<3                   /* iterative deepening loop */
     || prev&K == I
       && ( N<60000 & d<98                        /* root: deepen upto time   */
          || (K=X, L=Y&~M, d=3)
       )
     )                                          /* time's up: go do best    */
   {
      x=B=X;                                       /* start scan at prev. best */
      h=Y&S;                                       /* request try noncastl. 1st*/
      P=d<3 ? I : Minimax(-l,1-l,-score,S,0,d-3);               /* Search null move         */
      m = (-P<l | R>35) ? ( d>2 ? -I : score ) : -P;            /* Prune or stand-pat       */
      N++;                                         /* node count (for timing)  */
      do
      {
         upiece=board[x];                                   /* scan board looking for   */
         if(upiece & turn)                                  /*  own piece (inefficient!)*/
         {
            r = p = upiece&7;                               /* p = piece type (set r>0) */
            j = vector[p+16];                                 /* first step vector f.piece*/
            while(r = p>2 & r<0 ? -r : -vector[++j] )       /* loop over directions vector[] */
            {
labelA:                                        /* resume normal after best */
               y=x;                            /* (x,y)=move         */
               F=G=S;                          /* (F,G)=castl.R      */
              
               do
               {                                       /* y traverses ray, or:     */
                  H=y=h?Y^h:y+r;                           /* sneak in prev. best move */
                
                  if(y&M)break;                            /* board edge hit           */
                
                  m= EPC-S&board[EPC]&&y-EPC<2&EPC-y<2?I:m;      /* bad castling             */
                
                  if(p<3&y==EPC)H^=16;                           /* shift capt.sqr. H if e.p.*/
                
                  t=board[H];
                
                  if(t&turn|p<3&!(y-x&7)-!t)break;            /* capt. own, bad pawn mode */
                  i=37*pval[t&7]+(t&192);                     /* value of capt. piece t   */
                  m=i<0?I:m;                                  /* K capture                */
                
                  if(m>=l&d>1) goto labelC;                     /* abort on fail high       */
          
                  v=d-1?score:i-p;                             /* MVV/LVA scoring          */
                
                  if(d-!t>1)                               /* remaining depth          */
                  {
                     v=p<6?board[x+8]-board[y+8]:0;                  /* center positional pts.   */
                     board[G]=board[H]=board[x]=0;board[y]=upiece|32;             /* do move, set non-virgin  */
                     if(!(G&M))board[F]=turn+6,v+=50;               /* castling: put R & score  */
                     v-=p-4|R>29?0:20;                              /* penalize mid-game K move */
                    
                     if(p<3)                                        /* pawns:                   */
                     {
                        v-=9*((x-2&M||board[x-2]-upiece)+              /* structure, undefended    */
                               (x+2&M||board[x+2]-upiece)-1            /*        squares plus bias */
                              +(board[x^16]==turn+36))                 /* kling to non-virgin King */
                              -(R>>2);                                 /* end-game Pawn-push bonus */
                         V=y+r+1&S?647-p:2*(upiece&y+16&32);           /* promotion or 6/7th bonus */
                         board[y]+=V;
                         i+=V;                                         /* change piece, add score  */
                     }
                    
                     v+= score+i;
                     V=m>q ? m : q;                           /* new eval and alpha       */
                     J+=K(y+0,board[y])-K(x+0,upiece)-K(H+0,t);
                     Z+=K(y+8,board[y])-K(x+8,upiece)-K(H+8,t)+G -S;  /* update hash key          */
                     C=d-1-(d>5&p>2&!t&!h);
                     C=R>29|d<3|P-I?C:d;                     /* extend 1 ply if in check */
                     do {
                        s=C>2|v>V?-Minimax(-l,-V,-v,         /* recursive eval. of reply */
                                            F,0,C):v;        /* or fail low if futile    */
                     } while( s>q & ++C<d );
                  
                     v=s;
                     if(prev&&K-I&&v+I&&x==K&y==L)              /* move pending & in root:  */
                     {
                        Q=-score-i; EPSQ=F;                            /*   exit if legal & found  */
                        a->D=99;a->V=0;                        /* lock game in hash as draw*/
                        R+=i>>7;
                        return l;                            /* captured non-P material  */
                     }
                     J=f;
                     Z=g;                                    /* restore hash key         */
                     board[G]=turn+6;
                     board[F]=board[y]=0;
                     board[x]=upiece;
                     board[H]=t;                             /* undo move,G can be dummy */
                  }
                  if(v>m)                                  /* new best, update max,best*/
                  {
                     m=v,X=x,Y=y|S&F;                      /* mark double move with S  */
                  }                      
                  if(h)
                  {
                     h=0;
                     goto labelA;                           /* redo after doing old best*/
                  }                
                  if (
                    x+r-y|upiece&32|                             /* not 1st step,moved before*/
                    p>2 & (
                      p-4|j-7||                             /* no P & no lateral K move,*/
                      board[G=x+3^r>>1&7]-turn-6            /* no virgin R in corner G, */
                      || board[G^1] | board[G^2] )          /* no 2 empty sq. next to R */
                    )
                  {
                     t+=p<5;
                  }                                        /* fake capt. for nonsliding*/
                  else F=y;                                /* enable e.p.              */
                
               } while(!t);                               /* if not capt. continue ray*/
        
            }
         }  // (upiece & turn)
    
      } while((x=x+9&~M)-B);                       /* next sqr. of board, wrap */
  
labelC:
      if (m>I-M|m<M-I) d=98;                       /* mate holds to any depth  */
      m= m+I|P==I ? m : 0;                         /* best loses K: (stale)mate*/
    
      if(a->D<99) {                                /* protect game history     */
         a->K=Z;
         a->V=m;
         a->D=d;                       /* always store in hash tab */
         a->X=X|8*(m>q)|S*(m<l);
         a->Y=Y;                       /* move, type (bound/exact),*/
      }
      /* uncomment for Kibitz */
      if(!((N-S)%987)) {        
        sprintf(sbuf, "searched: %d\r",N-S);
        Serial.println(sbuf);
      }
      
   }  // while (iterative deepening loop)                                          

   turn^=24;                                        /* change sides back        */
   mfrom=K; mto=L;
   return m+= m<score;                                  /* delayed-loss bonus       */
}





void chess()
{
   int  score, i;
   char sbuf[50], sbuf2[50];
   char oboard[129];
   char oldto, oldEPSQ;
   char cstring[20];
  
   K=8;
   while(K--)
   {
      board[K]=(board[K+112]=bsetup[K]+8)+8;
      board[K+16]=18;
      board[K+96]=9;                               /* initial board setup*/
      L=8;
      while(L--)board[16*L+K+8]=(K-4)*(K-4)+(L-3.5)*(L-3.5);     /* center-pts table   */
   }                                                             /*(in unused half board[])*/
   N=1035;
   while(N-->M)T[N]=rand()>>9;
  
                                                                /* play loop          */
   while(1)                                              
   {
     N=-1;
    
     Serial.print("\n");
     while(++N<121) {                                            /* print board */
         sprintf(sbuf," %c", N&8 && (N+=7) ? 10 : psymbol[board[N]&15]);
         Serial.print(sbuf);
     }
    
     if(turn==16) sprintf(sbuf,"\n>  WHITE: ");  else sprintf(sbuf,"\n>   BLACK:  ");  
     Serial.print(sbuf);
    
     i = 0;        
     strcpy(cstring,"");
     do   {
       while (Serial.available()==0);      
       cstring[i] = Serial.read();    
       if(cstring[i]==13) {
         cstring[i]=0;
         break;
       }
       else i++;
     } while(i < 10);
    
     K=I;
    
     if(cstring[0]!=0) {                                   /* parse entered move */
       K= cstring[0]-16*cstring[1]+799;
       L= cstring[2]-16*cstring[3]+799;
     }    
     Serial.println();  Serial.println(cstring);  Serial.println();
    
     memcpy(oboard, board, sizeof(board));
     oldto=mto;
     oldEPSQ=EPSQ;
    
     score=Minimax(-I, I, Q, EPSQ, 1, 3);                              /* think or check & do*/    
     Serial.print("\nscore=");  Serial.println(score);  Serial.println();
    
    // if(ack!=15) {                    
        RemP=S;  
        if(oboard[mto])   RemP=mto;
        if(mto==oldEPSQ)  RemP=oldto;
                                      
        sprintf(sbuf,"\n\nmoved: >> %c%c", 'a'+(mfrom&7),'8'-(mfrom>>4) );
      
        if(oboard[mto]) strcat(sbuf," X ");
        else strcat(sbuf,"-");
      
        sprintf(sbuf2,"%c%c ", 'a'+(mto&7),'8'-(mto>>4&7));
        strcat(sbuf, sbuf2);
        Serial.print(sbuf);
    
        sprintf(sbuf, " (square %d to %d ) \n", mfrom, mto);
        Serial.print("\n\nDEBUG:\n");
        sprintf(sbuf2,"  EPsq: %c%c (%d)\n  RemP: %c%c (%d)",
                         'a'+(EPSQ&7), '8'-(EPSQ>>4&7), EPSQ,
                         'a'+(RemP&7), '8'-(RemP>>4&7), RemP);
        strcat(sbuf, sbuf2);
        Serial.print(sbuf);
        Serial.print("\n\n");
    //  }
    // else printf("\n\nILLEGAL!\n");

   }
}




void setup() {
   Serial.begin(9600);    
}



void loop() {    
   chess();
  
   while(1);  
}

wenn ich jetzt in beiden Programmen als Zug
d2d4
eingebe, klappt alles wunderbar. (in beiden Fällen score=30000 = default)

wenn ich einen Leerstring eingebe, auch (dann rechnet er automatisch einen Zug aus).

wenn ich aber dann, wenn Schwarz zieht,
bei devcpp z.B. a7a6 eingebe,
klappt es (wieder score=30000 = default)

bei Sketch meldet er einen falschen Zug (score == 0x0f == 15)
und weigert sich, ihn auszuführen!!
und zwar NUR bei schwarz!!
bei Weiß geht wieder alles !!

ich kapiers nicht.
ich bin schier am verzweifeln!

Angry

es ist übrigens wirklich der gleiche Code, nur die printf sind gegen Serial.print ausgetauscht,
ich habe schon zig-mal den cpp-Code nach Sketch 1:1 rüberkopiert und wieder nur die prints ausgetauscht-
es bleibt bei dem beknackten Fehler!
Angry

ich glaube, ich bin betriebsblind - oder Sketch spinnt.
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.11.2014, 20:16
Beitrag #2
RE: Kniffelaufgabe - ich verzweifle noch....
Hammerhart,
das Teil :-)
Chess auf einem Arduino.
Dennoch befürchte ich, das der Speicher nicht ausreichen könnte.
Wieviel Speicher wird denn belegt?

Ansonsten kann ich Dir sicher nicht helfen.
Wer sowas reparieren will, der wäre auch fähig, so ein Programm selbst zu schreiben, oder?
Ich kann sowas leider nicht.

Gruß Joe

Meine Vision Rolleyes http://global-science-circle.org
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.11.2014, 20:33 (Dieser Beitrag wurde zuletzt bearbeitet: 15.11.2014 21:32 von HaWe.)
Beitrag #3
RE: Kniffelaufgabe - ich verzweifle noch....
der Speicher reicht, auch auf dem Mega!


gerade festgestellt:
der Fehler tritt nur auf dem Due auf, der Mega arbeitet es einwandfrei ab (nur langsamer).

edit: nochmal in den Codes oben was geändert, Fehler bleibt aber auf dem Due...)

[Bild: 2162.gif]

update:
Sketch 1.5.8 installiert (vorher 1.5.6) - selber Fehler beim Due,
Mega immer noch ok!

MIST!

Kann bitte mal jemand den Code auf einem eigenen Due mal ausprobieren?
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.11.2014, 21:36
Beitrag #4
RE: Kniffelaufgabe - ich verzweifle noch....
...ich vermute mal das da zu viele Argumente in den printf Anweisungen drin sind...da ist meiner Erfahrung nach einiges nicht im Arduino Umfeld implementiert was in C üblich ist...so meine Erfahrung...
lg
bk

1+1 = 10 Angel ...und ich bin hier nicht der Suchmaschinen-Ersatz Dodgy...nur mal so als genereller Tipp..
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.11.2014, 21:43 (Dieser Beitrag wurde zuletzt bearbeitet: 16.11.2014 21:59 von HaWe.)
Beitrag #5
RE: kniffeliger Compilerfehler - ich verzweifle noch....
kann nicht der Grund sein -
der Fehler passiert ja bei der Übergabe des manuellen Zuges, das hat mit sprintf nichts zu tun,
und außrerdem rechnet ja der Mega richtig !!

es müsste mal bitte jemand den Code auf seinem eigenen Due austesten!
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.11.2014, 23:13 (Dieser Beitrag wurde zuletzt bearbeitet: 15.11.2014 23:13 von tito-t.)
Beitrag #6
RE: Kniffelaufgabe - ich verzweifle noch....
interessant...
ich warte schon ewig auf meinen Due aus China - werde mich sofort dransetzten, sobald er da ist.
Wäre auch an Tests anderer leute interessiert, vielleicht ist es ja irgendwie Bauart-abhängig.
Ist deiner ein originaler aus Italy oder auch ein Klon?
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
15.11.2014, 23:24 (Dieser Beitrag wurde zuletzt bearbeitet: 16.11.2014 21:58 von HaWe.)
Beitrag #7
RE: kniffeliger Compilerfehler - ich verzweifle noch....
ich habe auch einen China-Klon
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
16.11.2014, 21:58
Beitrag #8
RE: kniffeliger Compilerfehler - ich verzweifle noch....
hat hier keiner einen Arduino Due zum austesten?
Alle Beiträge dieses Benutzers finden
Diese Nachricht in einer Antwort zitieren
Antwort schreiben 


Möglicherweise verwandte Themen...
Thema: Verfasser Antworten: Ansichten: Letzter Beitrag
  Wo kann ich hier noch Code spahren? (SPI-,Ethernet-,SD-,GSM-Library) avoid 4 377 05.06.2016 14:16
Letzter Beitrag: avoid
  Compilerfehler mit PROGMEM?!?! Wampo 4 605 15.10.2015 23:50
Letzter Beitrag: Wampo

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste