Author: Dann Corbit
Date: 13:57:48 04/02/04
Go up one level in this thread
On April 02, 2004 at 16:37:45, Uri Blass wrote:
>On April 02, 2004 at 16:25:26, Jay Scott wrote:
>
>>On April 01, 2004 at 21:33:00, Uri Blass wrote:
>>
>>>I want to have some general search code(not only for chess) when it will be
>>>possible to implement failsoft,failhard,mtd and many search ideas by the right
>>>defines.
>>>
>>>I still do not have defines for different possibilities
>>
>>I think you mean, write it in C and use #define.
>>
>>I'd suggest instead writing it in C++ with templates, and avoiding #define.
>>Conditions can be handled by _if_ and by template instantiation. Compilers are
>>smart enough to do the right thing.
>>
>>- it's clearer
>>- it's more expressive; you can do more things
>>- there's no efficiency loss if you do it right
>>
>>If you're gonna do something generic, why not use generic programming?
>>
>> Jay
>
>The only reason is my lack of knowledge in C++ so I guess that this project may
>also help me to learn C++.
You can accomplish something similar to templates with classes and inheritance.
You can use virtual functions which are replaceable. So you could have a move
generator class that uses 0x88 or that uses bitboard and your game could inherit
from the move generator.
In order to accomplish this, you will need to keep the implementation details
out of the classes that do not absolutely need them as much as possible and only
use the interfaces.
So your methods will look like:
spaceValue = Game.GetSpaceScore();
positionalValue = Game.GetPostionalScore();
And something like this:
for (i = 0; i < 8; i++) {
pmove.target_square = knight_square + knight_direction[i];
if (!(pmove.target_square & 0x88)) {
that assumes a definite architecture should only live in your virtual functions.
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.