eval pieces

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

spambanane
Posts: 22
Joined: Sun Jun 17, 2012 9:45 am

Re: eval pieces

Post by spambanane »

As for C++, the availability of classes to allow for abstraction, encapsulation, and inheritance -- none really available in C -- make major multi-coder projects feasible. C++ operator overloading for user defined classes like bitboards, hashes. and moves helps make code legible.
you shouldn't believe everything the oop industry is telling you.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: eval pieces

Post by sje »

bob wrote:As far as the good of various C++ things, there are also the ugly things. Operator overloading? :) I have seen more bugs caused by using that than I would have imagined. Just use the wrong type argument and you use the wrong function, without noticing.
I really haven't seen this particular problem. In Symbolic, there are multiple operator overloads, used mostly for bitboard and hash signatures. In particular, Symbolic's bitboard operators have the same semantics as Pascal set operators. The idea is to carefully define the overloads so that they do the intuitive thing -- as if the custom type was included in the language specification. It's probably a good idea to avoid overloads for binary operators when the two operands are not of the same type.

----

One nasty C++ hazard is the use of static class instances where the class requires some initialization, even if the initialization is done implicitly at start-up time. Since there's no guarantee of the order of start-up time initialization, you can see how there can be some very difficult to track bugs.