Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: what classes all the serious C++ chess programs have?

Author: Volker Böhm

Date: 10:22:55 08/10/04

Go up one level in this thread


On August 10, 2004 at 02:59:10, Andrew Dados wrote:

>On August 09, 2004 at 18:26:10, Volker Böhm wrote:
>
>>Hi Uri,
>>
>>IceSpell has lot of classes for everything. It has a class for
>>
>>Square
>>Piece
>>Board
>>Value
>>Direction
>>Position
>>Evaluation (one class for every piece)
>>Move-Generation (one class for every piece)
>>SearchStack (holding the local information)
>>Search
>>Time-Control
>>Move
>>MoveList
>>Killer
>>History
>>...
>>(I don´t remeber everything).
>>
>>That had speed issues. Thats why Spike does not have those basic classes like
>>Square, Piece, Value, Direcion, Move, ...
>>
>>Spike has got the following classes:
>>
>>1. A "Const" Class holding only constants that do not need memory (no const
>>fields). Nearly every class is derived from the const class giving it the
>>opportunity to access all relevant constant values.
>>
>>2. A "Const-Field-Class" holding basic lookup tables
>>3. A Move-Generator-Class (only one)
>>4. An Attack-Table Class
>>5. A Board-Class
>>6. An Evaluation-Class
>>7. An Incremental-Evaluation-Class
>>8. A Pawn-Hash Class
>>9. A Hash Class
>>10. A SEE Class
>>11. A simple SEE Lookup-From-Attack-Table class
>>12. A Search Class
>>13. A Ponder Class
>>14. An Interface Class (Supporting Winboard and UCI)
>>15. A Time-Control Class (Controls that time does not exceed limit, calculates
>>the "base" time and a maximal time for the current move. The base time is only
>>calculated by time settings and amount of moves done)
>>16. A Timefactor Class (Calculates the current time factor, the time-factor is
>>only dependant of game situation and search issues (pv-change, value-change,
>>...))
>>
>>Maybe I forgot one or two. Some Classes are large, this is not good in a design
>>point of view. But for Chess speed is most relevant.
>>
>>Greetings Volker
>
>IMO above is a typical example of bad oo programming: classes for everything.
>Art for art imo. very scholar and 'proper' and sloow from design. Passing
>pointers everywhere.

Hi,
in my tests there are now speed-drawbacks because of the classes used. I read
the generated assembly code there are no useless pointers in speed relevant
parts of the program.

Chess is a very small software project, it´s hard to argue for oo priciples
here. You can find many advantages of oo in large projects.

>
>Take hashtable: allocate at startup (reallocate as option) then 2 functions:
>store and retrieve. Does it need its own class? NO. Ponder... Const... (why not
>const.h file?).

What is a class with constants other than a const.h file? All constants are
declared and defined in the class declaration thus in the const.h file. Every
class derives from const.h that needs those constants. Thus the constants are
directly availiable. There is absolutely no speed reduction for doing this. It
is just a sort of additional namespace that reduces namespace-pollution.

> Square and piece is just enum... why waste time to call its class is beyond my
>understanding.

As you can read above I am no longer using those in spike. I speed is not a big
issue it is a very good idea do implement a piece class.
I used many same classes of IceSpell for different games (reversi, connect-4,
muhle, ...) and had been able to have most code (search algorithms, optimizing
algorithms, gui, ...) in a general purpous library.

In the IceSpell framework you can implement a new search algorithm and get it
working for many games without implementing game specific code. This is done by
the ability to derive from classes and encapsulate game specific code for
example in the piece class. This is impossible with an enum.

C++ compilers have good functionality to reduce speed overhead by additional
classes like inlining.

>
><rant> I hate watching those sources where *everything* is wrapped in some
>useless class - is it just me?</rant>

Then don´t look at those sources ;-)

One additional information:
The Spike source code is c++ and java at the same time. Thus we use only java
and c++ compatible functionality. Enum´s for example are not java compatible.
Thus they are not used.

- Volker -

>
>-Andrew-



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.