Author: Uri Blass
Date: 08:49:52 04/11/03
Go up one level in this thread
On April 11, 2003 at 11:09:47, Uri Blass wrote:
>only one time or not done often.
>
>I have task that I do only one time and I may do my code shorter
>by adding functions.
>
>Note that they are a small minority of the code so
>I do not expect a big reduction.
>
>Here are some examples:
>
>1)In the code that build the array of knightmoves I have
>8 similiar if.
>
>if (fil>=2&&rank>=1)
> {
> knightmove[sq][i]=index(fil-2,rank-1);
> direction[sq][knightmove[sq][i]]=dknight;
> i++;
> }
>
>Is there an advantage in changing it to something like
>
>if (fil>=2&&rank>=1)
>{
>buildknightarrays(sq,i,fil-2,rank-1);
>i++;
>}
>
>or maybe it is even better to give buildknightarrays
>a pointer to i to save the i++ that I do 8 times.
>
>
>2)In my code for setup position I have the following code
>
> case 'n':
> info[square]+=KNIGHT;
> valuepieces+=3;
> if (color(square)==LIGHT)
> valpieces[0]+=3;
> else
> valpieces[1]+=3;
> break;
>
>I can replace 3 by piece_value[KNIGHT]
>replace 0 by LIGHT and replace 1 by DARK
>
>I can also have a function
>putpiece(int square,int piece)
>{
>info[square]+=piece;
>valuepieces+=valpieces[piece];
>if (color(square)=LIGHT)
> valpieces[LIGHT]+=valpieces[piece];
>else
> valpieces[DARK]+=valpieces[piece];
>}
I see that I have some errors in the code
As usual I discover errors
I need
+=piece_value[piece];
There may be error also in the other code that I did not check.
Uri
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.