Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Program in pure C

Author: Pat King

Date: 13:10:31 03/19/02

Go up one level in this thread


On March 19, 2002 at 06:08:22, Sune Fischer wrote:

>On March 18, 2002 at 21:44:30, Dann Corbit wrote:
[snip]
>I thought of a complete redesign with a super piece class and sub classes for
>each type, they could have their own MakeMove and RemovePiece which would save a>few conditionals here and there. But since 80% of the makemove is identical for
>all the pieces, there would need to be a lot of identical code segments, which
>is clearly prone to error.

Why so? All that means is that the superclass does the moving 80% of the time,
with the subclasses catching the exceptional cases. No identical code segments,
just a careful encapsulation of common behaviour. That's how Zotron does it, and
it works fine (not that Zotron doesn't have other problems).

>I'm also afraid that with so many small functions being called, there would be a
>noticable overhead.

Less of a handle on this. I did some simple experiments to prove to myself that
the fewer conditionals of OO code compensated for the increased number of
function calls. This experiment was not a full up chess program, and the result
is certainly compiler and platform dependent, but OO is not a pure loss on
speed, and can be a win. Anyone aware of public/GPL/similar C++ profiler?

>Maybe there is a better way to do it in C++?
>
>-S.

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.