Compiling Sjeng 7.0-11.2

Discussion of chess software programming and technical issues.

Moderator: Ras

Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Compiling Sjeng 7.0-11.2

Post by Gerd Isenberg »

outAtime wrote:Here are the relavant source lines:

[compile text]
eval.c:254: error: initializer element is not constant
eval.c:254: error: <near initialization for 'ksafety_scaled[0][0]'>
etc.., "" same error lines 255,256,257,258,259,etc..to line 269
D:\cygwin\bin\make.exe[2]: *** [eval.o] Error 1

Code: Select all


252 int ksafety_scaled[15][9] =
253 { 
254    (  -5,   5,  10,  15,  50,  80, 150, 150, 150 ),   /* nothing */
255    (  -5,  15,  20,  25,  70, 150, 200, 200, 200 ),   /* 1 pawns */
256    (  -5,  15,  30,  30, 100, 200, 300, 300, 300 ),   /* 2 pawns */
257    ( -10,  20,  40,  40, 100, 200, 300, 300, 400 ),   /* 1 minor piece */
258    ( -10,  30,  50,  80, 150, 300, 400, 400, 500 ),   /* 1 minor piece +  pawn */
259    ( -10,  35,  60, 100, 200, 250, 400, 400, 500 ),   /* queen */
260    ( -10,  40,  70, 110, 210, 300, 500, 500, 600 ),   /* queen + pawn */
261    ( -10,  45,  75, 125, 215, 300, 500, 600, 700 ),   /* queen + 2 pawn */
262    ( -10,  60,  90, 130, 240, 350, 500, 600, 700 ),   /* queen + piece */
263    ( -15,  60,  95, 145, 260, 350, 500, 600, 700 ),   /* queen + piece + pawn */
264    ( -15,  60, 100, 150, 270, 350, 500, 600, 700 ),   /* 2 queen */
265    ( -15,  60, 110, 160, 280, 400, 600, 700, 800 ),
266    ( -20,  70, 115, 165, 290, 400, 600, 700, 800 ),
267    ( -20,  80, 120, 170, 300, 450, 700, 800, 900 ),
268    ( -20,  80, 125, 175, 310, 450, 700, 800, 900 )
269 };
270
271 void initialize_eval(void)

that is it note for note, I added only the line numbers for reference as they appear in the source.
seems curly braces are necessary for the inner initializations.
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Compiling Sjeng 7.0-11.2

Post by outAtime »

Where in the link is that?
Dont forget, the same code compiles in other versions which leads me to
believe it may not be the code, otherwise why not the same bug in all
versions? Strange.

eval.c:254: error: initializer element is not constant
eval.c:254: error: <near initialization for 'ksafety_scaled[0][0]'>

then the same error on each line with the [][]' changing so:

eval.c:255: error: initializer element is not constant
eval.c:255: error: <near initialization for 'ksafety_scaled[0][1]'>
256..."" [0][2]'
etc...
262..""[0][8]'
263.""[0]'
264..""[1][1]'
265..""[1][2]'
etc..
268..""[1][5]'
269..""[1]'

I still dont know why this happens in 10 and not in another version with same section. I cant find the "curly" code from the homepage.
There may be a related section to this code in another .h or .c , Ive
looked but so far nothing. Everything looks normal.
outAtime
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Compiling Sjeng 7.0-11.2

Post by Gerd Isenberg »

outAtime wrote:Where in the link is that?
Dont forget, the same code compiles in other versions which leads me to
believe it may not be the code, otherwise why not the same bug in all
versions? Strange.
Sorry about the confusion with my default CPW-link.

Seems your compiler is more strict now with constructor semantics of parenthesis. The correct syntax to initialize that array is - and that should work with all compilers:

Code: Select all

int ksafety_scaled[15][9] =
{
   {  -5,   5,  10,  15,  50,  80, 150, 150, 150 },   /* nothing */
   {  -5,  15,  20,  25,  70, 150, 200, 200, 200 },   /* 1 pawns */
   {  -5,  15,  30,  30, 100, 200, 300, 300, 300 },   /* 2 pawns */
   { -10,  20,  40,  40, 100, 200, 300, 300, 400 },   /* 1 minor piece */
   { -10,  30,  50,  80, 150, 300, 400, 400, 500 },   /* 1 minor piece +  pawn */
   { -10,  35,  60, 100, 200, 250, 400, 400, 500 },   /* queen */
   { -10,  40,  70, 110, 210, 300, 500, 500, 600 },   /* queen + pawn */
   { -10,  45,  75, 125, 215, 300, 500, 600, 700 },   /* queen + 2 pawn */
   { -10,  60,  90, 130, 240, 350, 500, 600, 700 },   /* queen + piece */
   { -15,  60,  95, 145, 260, 350, 500, 600, 700 },   /* queen + piece + pawn */
   { -15,  60, 100, 150, 270, 350, 500, 600, 700 },   /* 2 queen */
   { -15,  60, 110, 160, 280, 400, 600, 700, 800 },
   { -20,  70, 115, 165, 290, 400, 600, 700, 800 },
   { -20,  80, 120, 170, 300, 450, 700, 800, 900 },
   { -20,  80, 125, 175, 310, 450, 700, 800, 900 }
};
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Compiling Sjeng 7.0-11.2

Post by outAtime »

Your solution is correct! Of course I went back to look at 10
and 11.2, both of which use { not ( I also decided to look at some source from Jim Ablett's site which removes the parenthesis completely.

Code: Select all

int ksafety_scaled[15][9] =
{ 
     -5,   5,  10,  15,  50,  80, 150, 150, 150 ,   // nothing 
     -5,  15,  20,  25,  70, 150, 200, 200, 200 ,   // 1 pawns 
     -5,  15,  30,  30, 100, 200, 300, 300, 300 ,   // 2 pawns 
    -10,  20,  40,  40, 100, 200, 300, 300, 400 ,   // 1 minor piece 
    -10,  30,  50,  80, 150, 300, 400, 400, 500 ,   // 1 minor piece + pawn 
    -10,  35,  60, 100, 200, 250, 400, 400, 500 ,   // queen 
    -10,  40,  70, 110, 210, 300, 500, 500, 600 ,   // queen + pawn 
    -10,  45,  75, 125, 215, 300, 500, 600, 700 ,   // queen + 2 pawn 
    -10,  60,  90, 130, 240, 350, 500, 600, 700 ,   // queen + piece 
    -15,  60,  95, 145, 260, 350, 500, 600, 700 ,   // queen + piece + pawn 
    -15,  60, 100, 150, 270, 350, 500, 600, 700 ,   // 2 queen 
    -15,  60, 110, 160, 280, 400, 600, 700, 800 ,
    -20,  70, 115, 165, 290, 400, 600, 700, 800 ,
    -20,  80, 120, 170, 300, 450, 700, 800, 900 ,
    -20,  80, 125, 175, 310, 450, 700, 800, 900 
};
I was suprised to see this and tempted to re-compile 8.0 this way to see if it worked; then passed on the notion. { compares to 10 and 11.2 now.

Thanks very much for your help! I really appreciate it :)
Now all versions are running except 10.0.

10.0 gives a make error:

make <e=87>: The parameter is incorrect.
D:\cygwin\bin\make.exe[2]: *** [sjeng] Error 87
D:\cygwin\bin\make.exe[2]: Leaving directory 'D:/cygwin/
home/Owner/Sjeng-old/Sjeng-10.0
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory 'D:/cygwin/
home/Owner/Sjeng-old/Sjeng-10.0
D:\cywin\bin\make.exe: *** [all-recursive-am] Error 2

Is this related to maximum string size?
outAtime
outAtime
Posts: 226
Joined: Sun Mar 08, 2009 3:08 pm
Location: Canada

Re: Compiling Sjeng 7.0-11.2

Post by outAtime »

Got the make error figured and out now everything is running. Again, much appreciated advice from all, thanks.
outAtime