node count change, please help

Discussion of chess software programming and technical issues.

Moderator: Ras

Tony

Re: node count change, please help

Post by Tony »

PK wrote:hi,

I have noticed similar node count changes in two more places, both unrelated to hash tables or evaluation. Again, changes appear only under my "release" configuration, which is optimized for speed. This time one of the modifications was simply moving a one-line conditional instruction into a separate function and I cannot possibly imagin what could have been wrong with that.

It looks like we ought to change the name of the thread to something like: problem with Visual C++ Express Edition.

Pedro, thanks for Your observation about badCaptures(), I messed something up because of misguided pretty-printing a couple of weeks ago. The function with a single "=" simply did not work. Still, I am not sure if this should be included in a simple, didactic program. Any opinions?
A lot of people blame the compiler, but I'm pretty sure the problem mostly is the programmer.
I've had problems like this too, and only once I could (slightly) blame the compiler because it didn't behave like expected ( though correct)

There are some things that help.

Use Asserts for sanity checks. ( or let your code crash on wrong input)
If you know a parameter to a function should never be <0 then you can put code like: if (param<0) param=0;
But since param should never be<0 it can bever behave the way you want. Using Assert(param>=0) ( or raise an exception) shows the problem, rather than hiding it.

Solve your warnings. The fact that the "=" and "==" could be missed means you either have the wrong warning level, or you don't read them.
Good code compiles without warnings. ( if you select a normal warninglevel that is)

Another one is : If you're not sure in wich order something is evaluated, use ().
fe if ( condA || condB) can give problems depending on the conditions A and B,
if ((condA) || (condB)) is a lot less likely to be unclear.

Tony
PK
Posts: 912
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: node count change, please help

Post by PK »

I wish to thank all of You for Your input. Redefining integer types by Edmond Moshammer solved the issue, and I was wrong to blame the compiler.

the corrected source code will be released in about a week (there are some timing bugs and I must test lazy eval vs evaluation cache, as they are similar timewise).
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: node count change, please help

Post by bob »

Ditto for macros. Each parameter should be enclosed in parens () to avoid this problem which can suddenly be very difficult to see.

A & B is pretty clear, until A is passed as X | Y, and B is passed as P ^ Q.

The substitution produces X | Y & P ^ Q which is almost guaranteed to not be exactly what was intended, and since it is hidden in the macro substitution, it can be very difficult to find such.