Author: Pat King
Date: 12:38:50 09/23/03
Go up one level in this thread
On September 22, 2003 at 17:51:21, Daniel Clausen wrote: [snip] >One area where polymorphism might be useful is with hashtables. You could have >an abstract hashtable and derived classes for the pawn and the normal hashtable. I tried this, for normal and opening book hash tables, using templates rather than direct inheritance. It was useful, in that I only had to debug one set of hash code, but the resulting structures wasted some space,and the calling syntax was somewhat akward, so I went back to totally seperate tables. >I'm not convinced that polymorhism helps a lot when it comes to the chess >pieces, especially not with my other data structures, but there was poster some >days ago who described that he's doing that in his engine. That was me. My piece classes came first, so there is no conflict with other structures. I've found it useful for debugging, and a lot of the 'if's and 'switch'es you'd find in C are swallowed up by the inheritance heirarchy. My testing has shown a virtual method call to be no worse than an 'if' or 'switch' (YMMV). > >Another CCC-member posted more than a year ago, that in his engine, he has an >evaluator object which is an observer of a board object. So whenever something >happens on the board, the corresponding evaluator object is notified and can do >the needed updates. Depending on the "granularity" of the changes of the >board-object, this can be rather efficient and very robust. The notification process strikes me as being slow, but I'll reserve judgement, not having seen it. My piece heirarchy does maintain a primitive running eval, which the conventional eval function merely adds to. > >In summary, I think that there's no speed penalty if you use C++ just as a >better C. There's a speed penalty when you really use some OO-design, but it >doesn't have to be completely slow, depending on how clever you do things. Wow. Somebody almost called me clever :) > >Sargon Pat
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.