Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Problem with Object Oriented Design (programming issue)

Author: Pat King

Date: 12:19:04 09/23/03

Go up one level in this thread


On September 22, 2003 at 12:12:19, Robert Hyatt wrote:

>On September 22, 2003 at 08:39:49, Vincent Diepeveen wrote:
>
>>On September 21, 2003 at 21:15:06, Robert Hyatt wrote:
>>
>>>On September 21, 2003 at 20:07:11, Vincent Diepeveen wrote:
>>>
>>>>On September 20, 2003 at 15:58:03, Dave Gomboc wrote:
>>>>
>>>>>On September 15, 2003 at 19:28:39, Mathieu Pagé wrote:
>>>>>
>>>>>>In fact I have not yet implementing dynamic allocation.
>>>>>>
>>>>>>I'm pretty sure it's about too much constructor executing.
>>>>>>
>>>>>>I'd like to know if someone had ever experiments which overhead (%) should I
>>>>>>expect when porting non-OO chess engine to OO ?
>>>>>>
>>>>>>Thanks for your help, i'will give a try to your idea when implementing dynamic
>>>>>>allocation.
>>>>>>
>>>>>>Mathieu Pagé
>>>>>
>>>>>I'd expect zero overhead.
>>>>
>>>>then he's not using real OO features.
>>>>
>>>>As soon as you start using advanced stuff from object oriented programming, then
>>>>overhead is *huge*.
>>>>
>>>>Let's assume for example a neat OO program that's allocating and deallocating
>>>>objects of course. That's real neat OO programming.

Yes. But SMART OO programmers are careful about WHEN the allocating and
deallocating occur. The only time it occurs in the search in my program is
during pawn promotion. Admittedly, my setboard function is VERY expensive, but
who cares?

>>>>
>>>>What junior team and others do in c++ is by no means what i call the real OO
>>>>features.
>>>>
>>>>The real OO features are dead slow for chess :)
>>>>
>>>>>Dave
>>>
>>>
>>>Not necessarily..  A chess board is a good example of an object.  There is
>>>no need to create a bunch of them, one is enough.  I've personally seen more
>>>than one _really_ elegant OO (C++) chess program that was just as fast as
>>>mine (it was a bitboard program also).
>>
>>In fact i wrote several c++ programs a bunch of years ago, using all kind of
>>cool c++ features (from which some i probably am forgotten again) and the code
>>was *dead* slow. Of course the code wasn't meant for speed.

Which means you haven't proven a thing about C++ that IS written for speed.

>>
>>I have not seen neat c++ code that's faster than C, using special c++ features.
>>
>>If you use classical neat c++ then a chessprogram is just busy allocating and
>>destroying objects, which is *real* slow.
>>

If you use textbook examples of c++ for chess, then it's dead slow. So is every
AI textbook algorithm I've ever looked at. Just like real chess programs are
different from what you find in the books, so are real c++ programs.

>>As soon as you start using tricks to avoid all that, then all you end up is a C
>>program with extension cpp.

So you condemn "classic" c++ (a dubious term anyway), and then condemn those of
us who deviate from it?

>>
>>Best regards,
>>Vincent
>
>
>Not true, as always.  _NOTHING_ in OOP says you have to continually
>create and destroy objects.  For chess, you can create a single instance
>of a chess board object and use it forever.

Plenty of other examples. My master list of moves is only created once, just as
efficient as any pure C, and to my mind more readable. As I mentioned above, my
setboard() is expensive due to the creation of dynamic, polymorphic,
supercalafragalistic pieces, but who cares about one call outside the search?

>
>Your thinking is _far_ too rigidly contained in a tiny box.  There is a
>much bigger box _outside_ that little box you stay in.

Here, here!

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.