a program that write chess programs(can you do it?)

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Uri Blass
Posts: 10268
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

a program that write chess programs(can you do it?)

Post by Uri Blass »

The way that I change parameters in movei is simply by changing parameters in an ini file when I have code like

if (latereduction)
{
...
}

I think that it is not efficient and the efficient way is to have simply a program that read an ini file and based on the ini file change the source of the program and compile an exe.

By that way it is possible to get rid of if statement that probably make the program slightly slower inspite of the fact that latereduction never change during the program run except beginning time of reading the personality.

I think that if somebody can do it this can be considered as a program that write chess programs because the program generate different exe file of chess program based on changing some parameters in an ini file.

Uri
Aleks Peshkov
Posts: 892
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia

Re: a program that write chess programs(can you do it?)

Post by Aleks Peshkov »

#define LATEREDUCTION

#if defined LATEREDUCTION
...
#endif
Guetti

Re: a program that write chess programs(can you do it?)

Post by Guetti »

Aleks Peshkov wrote:#define LATEREDUCTION

#if defined LATEREDUCTION
...
#endif
Ahhhrg, macros, they are DEPRECATED! :wink:
Uri Blass
Posts: 10268
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: a program that write chess programs(can you do it?)

Post by Uri Blass »

Aleks Peshkov wrote:#define LATEREDUCTION

#if defined LATEREDUCTION
...
#endif
I also use things like that not for LATEREDUCTION but I need to change the code to have a different exe file.

latest seriously tested version is version 438 so I have in the code of latest version that is not well tested

#define AFTER438
#define AFTER439
#define AFTER440

I also have code like
#ifdef AFTER440
...
#endif

The problem is that I do not know how to delete define AFTER440 without changing the source and simply delete
#define AFTER440 from defs.h.

The main question is if version like that can be used by a user that has not the source when we can delete #define AFTER440 from the source without getting the source and compile it.

Uri
Oliver

Re: a program that write chess programs(can you do it?)

Post by Oliver »

Would you really go so far for a few if's? I doubt it.
You could implement some options with "defines", but that would distract your users from testing them.
Nevertheless, progammers here do talk a lot about branchprediction.
In your case, branchprediction works 100% to your favour. Your only concern arises, if for some reason nothing is known about the jump in question. In this case the default rule apply: "Branches backwards (e.g. in loops) are always taken, branches forward never."

Applying this rule to your if-example means, that the processor always falls through. Therefore i suggest, you should make at least certain, that your favorite options always do interact well with the defaultrule.

Oliver
User avatar
Bo Persson
Posts: 243
Joined: Sat Mar 11, 2006 8:31 am
Location: Malmö, Sweden
Full name: Bo Persson

Re: a program that write chess programs(can you do it?)

Post by Bo Persson »

Guetti wrote:
Aleks Peshkov wrote:#define LATEREDUCTION

#if defined LATEREDUCTION
...
#endif
Ahhhrg, macros, they are DEPRECATED! :wink:
And not needed much anymore:

config.h
const bool latereductions = false;

...

search.cpp

if (latereductions)
{

}
Uri Blass
Posts: 10268
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: a program that write chess programs(can you do it?)

Post by Uri Blass »

Bo Persson wrote:
Guetti wrote:
Aleks Peshkov wrote:#define LATEREDUCTION

#if defined LATEREDUCTION
...
#endif
Ahhhrg, macros, they are DEPRECATED! :wink:
And not needed much anymore:

config.h
const bool latereductions = false;

...

search.cpp

if (latereductions)
{

}
Again you need to change config.h and compile again if you want to test the option that laterreductions=true.

I want to give one exe file to testers who are not programmers and enable them to test laterreduction=true without changing the source
and without making the program slower simply by editing ini file when editing the ini file will cause the program to do the following steps:
1)write different code with const bool latereductions = true;
2)compile that code and make optimization for speed so there is another exe file that the testers can use.

1 or 2 are part of writing a chess program so I want a program that is able to do part of the job of writing chess programs and the question is if it is possible to do it.

Note that even if I am sure that some change is productive it is possible that later changes cause it to be counter productive so I need the option to test if it still help for the future.

Uri
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: a program that write chess programs(can you do it?)

Post by bob »

it would be trivial to do it. But the savings would be extremely small. And it would make the program harder to tune for individuals that like to do this. It takes me 10 minutes to compile Crafty (using PGO) at a minimum. Who would want to wait that long to adjust a parameter and then play a game?
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: a program that write chess programs(can you do it?)

Post by bob »

the problem is, those do the same thing. It is like the days of "gotoless programming" where everyone found bizarre ways of eliminating the goto, without really eliminating the goto.
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: a program that write chess programs(can you do it?)

Post by Dann Corbit »

You can achieve what you want with arrays of function pointers.
You can completely change the behavior of the program at runtime by installing different pointers.

The C++ equivalent is to use virtual methods (which are replaceable).

Ernst Heinz uses this technique in evaluation. He has completely different functions for evaluation in opening, midgame, endgame, for instance.

Now, in order to be able to do this, you will need to build each and every function you want to try and add them all into your program. Then, at runtime, you can configure your program on the fly to choose what functions it uses to perform all of its operations (search, eval, etc.)