Computer Chess Club Archives


Search

Terms

Messages

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

Author: Daniel Clausen

Date: 00:33:21 08/11/04

Go up one level in this thread


On August 10, 2004 at 13:35:39, Álvaro Begué wrote:

[snip]

>A colleague of mine proposed a way of getting rid of the indirection and the
>extra argument, without forcing you to use a single board. It is a little
>twisted, but interesting. You just make your engine a template class that gets a
>pointer to Board in the template:
>
>class Board {
>  //...
>};
>
>template <Board *b>
>class Engine {
>  //...use the board *b for everything.
>};
>
>Board my_board;
>Engine<&my_board> my_engine;
>
>Board my_other_board;
>Engine<&my_other_board> my_other_engine;
>
>This gives you performance that is as good as using a single global board, but
>you can have more than one board. Of course this duplicates all the code
>internally and your binary ends up being very large, but you can't get
>everything.

Nice idea! The only problem in my case is that I already have templated versions
of makeMove etc with the side-to-move. Maybe I should "templatize" everything
and get rid of all parameters. :)

Sargon



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.