A Question about Crafty

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

lauriet
Posts: 199
Joined: Sun Nov 03, 2013 9:32 am

A Question about Crafty

Post by lauriet »

Hey Bob,

I understand that if you get a TT hit but the draft is insufficient, you can still try the move early hoping for a cut off.
Do you do this in crafty. I couldn't see it in the code (but then I'm not very clever)
If you don't do it can you comment on why not.

Thanks
Regards
Laurie.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: A Question about Crafty

Post by Sven »

In Crafty 25.0.1 (which is the version I looked at), take a look at the function NextMove() in "next.c", it returns the TT hash move if the current phase of staged move generation is HASH.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: A Question about Crafty

Post by bob »

lauriet wrote:Hey Bob,

I understand that if you get a TT hit but the draft is insufficient, you can still try the move early hoping for a cut off.
Do you do this in crafty. I couldn't see it in the code (but then I'm not very clever)
If you don't do it can you comment on why not.

Thanks
Regards
Laurie.
Yes. You can also look at the bound that was stored and determine whether a null-move search should be avoided as a waste of time on this position also...

If you look at HashProbe() you will see where it stores the best move in tree->hash_move[ply]. And if you look at NextMove() and friends, this is the first move that is searched, before doing a move generation at all.
jefk
Posts: 626
Joined: Sun Jul 25, 2010 10:07 pm
Location: the Netherlands
Full name: Jef Kaan

Re: A Question about Crafty

Post by jefk »

bob wrote:
lauriet wrote: couldn't see it in the code
hi, mr Hyatt
may i take the opportunity also to ask a question; in
all previous versions of Crafty before 25.0, my little old
program Bookbuilder had an interface for the Crafty analysis
via a socalled 'pipe'; works reasonably well (although i'm
thinking if i could make it winboard compatible myself..).

But now with the 25.0 and 25.01 versions, the output
is not recognized anymore, and the only thing displayed
is 'feature' (also for depth) and 'feature done =1 '
for the move/pv. Strange enough if i just run it in a dos window
the output seems normal, comparable with the older versions.
Possibly just a minor issue, but i would be glad if i
could resolve this, in order to become up to date
with the latest crafties again.. :)
thx in advance

jef
www.bookbuilder

PS never compiled crafty myself. with devC++ never gone
further than compiling a single c file, although i also managed
to compile the bookbuilder sources (from previous programmer)
with Borland C++ Builder (nowadays Embarcadero btw)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: A Question about Crafty

Post by bob »

jefk wrote:
bob wrote:
lauriet wrote: couldn't see it in the code
hi, mr Hyatt
may i take the opportunity also to ask a question; in
all previous versions of Crafty before 25.0, my little old
program Bookbuilder had an interface for the Crafty analysis
via a socalled 'pipe'; works reasonably well (although i'm
thinking if i could make it winboard compatible myself..).

But now with the 25.0 and 25.01 versions, the output
is not recognized anymore, and the only thing displayed
is 'feature' (also for depth) and 'feature done =1 '
for the move/pv. Strange enough if i just run it in a dos window
the output seems normal, comparable with the older versions.
Possibly just a minor issue, but i would be glad if i
could resolve this, in order to become up to date
with the latest crafties again.. :)
thx in advance

jef
www.bookbuilder

PS never compiled crafty myself. with devC++ never gone
further than compiling a single c file, although i also managed
to compile the bookbuilder sources (from previous programmer)
with Borland C++ Builder (nowadays Embarcadero btw)
Nothing has changed that I am aware of. Still works with my custom online match program, works with xboard and winboard. Not aware of anything that should be broken.

Can you post your crafty.rc or .craftyrc file? Options have certainly changed...
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: A Question about Crafty

Post by jwes »

I was looking at the code and saw that you update the age if you get a hit and the age is different. You only need to update the age if it causes a cutoff as otherwise the entry will be overwritten when the search of this node returns.
jefk
Posts: 626
Joined: Sun Jul 25, 2010 10:07 pm
Location: the Netherlands
Full name: Jef Kaan

Re: A Question about Crafty

Post by jefk »

bob wrote: Can you post your crafty.rc or .craftyrc file? Options have certainly changed...
ok, yes i suspected also it might have something to do
with the .rc file, so i already had commented out some stuff;
this is what i have now:

# version July 2016 for Bb-4.3
# default wcrafty(x32).exe again
# for x64 systems rename wcraftyx64.exe to wcrafty.exe
hash=256M
hashp=64M
# if you have more Ram memory you can set the above higher
log=off
# added ponder = off SEEMS TO WORK BETTER..
ponder = off
#mt=2 , max threads eg 2 in case of dual core
# or 3 (or 4) in case of quad, etc (uncomment
# by removing the #
mt=2
# spmmt=2
# assuming most comps nowadays have 2 or more threads
# evaluation tropism 140 Only works for wcraftyx64 (version 24.0)
# more gambit style
# evaluation kscale 80 Only works for wcraftyx64 (version 24.0)
# a bit less king safety
learn=on

seems to work fine in the dos window,
so i also looked up the pipe transmission c++ code, which
still works fine for 24.x versions, its listed below

void __fastcall TfrmMain::ReadCrafty(TMessage &msg) {
if(msg.WParam!=0) {
char c = (char)(msg.WParam);
tempss += c;
}
else {
if(!needAnalizer) {
return;
}
AnsiString All, Move, Depth, Time, Score, PV;
char *p = new char[strlen(tempss.c_str())+1];
strcpy(p,tempss.c_str());
int SpaceCounter = 0,n;
TStringList *Lines = new TStringList;
Lines->Text = p;
for(n=0; n<=Lines->Count-1; n++)
{
p = Lines->Strings[n].c_str();
char *s1 = " ";
double s2=0;
double s3 = 0;
char *s4 = " ";
char *s5 = " ";
Move = "";
sscanf(p, "%s %lf %lf %s %s", s1, &s2, &s3, s4,s5);
Depth = s1;
Time = AnsiString(s3/100);
Score = (frmMain->Bord->MoveColor == 1) ? AnsiString(s2/100) : AnsiString(-s2/100);
PV = s5;
int Index;
Index = Lines->Strings[n].Pos(PV);
PV = Lines->Strings[n].SubString(Index, 100);
CraftyHandler(this, Lines->Strings[n], Move, Depth, Time, Score, PV);
}
delete Lines;
tempss = "";
}

}

bool sending = false;
//send the data to the NT pipe
void TfrmMain::SendNTPipe(char *data) {
while(sending){
Sleep(1);
}
sending = true;
int i;
HWND hwndPipe = FindWindow("Pipe",NULL);
//ShowMessage(data);
SendMessage(hwndPipe,WM_APP + 0x0505,0,0);
for(i=0;i<strlen(data);i++) {
SendMessage(hwndPipe,WM_APP + 0x0501, data,0);
}
SendMessage(hwndPipe,WM_APP+0x0501,0,0);
sending = false;
}
//closes the crafty engine
void __fastcall TfrmMain::QuitCrafty1Click(TObject *Sender)
{
if(usedCrafty) {
StartCrafty(Sender);
}
}

this is a bit above my current competence, i must admit.
but anyway this is the programming forum, isn't it :)

jef
jefk
Posts: 626
Joined: Sun Jul 25, 2010 10:07 pm
Location: the Netherlands
Full name: Jef Kaan

Re: A Question about Crafty

Post by jefk »

jefk wrote:
bob wrote: Can you post your crafty.rc or .craftyrc file? Options have certainly changed...
ok, yes i suspected also it might have something to do
with the .rc file,
maybe there's now a new .rc option to show more under the 'time' heading ?

Because upon further inspection i noticed a difference in the 25.x output, namely,
two numbers for time (instead of formerly one), separated
with a / (slash). So after depth (eg 1) time (eg 2.34/27.00) pv etc

(maybe the 27.0 is max 27 seconds per move or so ?)

So for the 25.x version i would like to avoid output of the /27.00
(as in above example_; or i later have to/will try to modify my code..
(if it wouldn't be better to start digging into winboard already)
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: A Question about Crafty

Post by bob »

I didn't have time to look at the code, but certainly the stdin/stdout handling has not changed in the least with newer versions. It still works just fine with winboard and with my custom interface.

the tropism stuff might not work as expected (eval command). I will have to look at that to be sure it won't break since I don't normally adjust those kinds of values.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: A Question about Crafty

Post by bob »

jefk wrote:
jefk wrote:
bob wrote: Can you post your crafty.rc or .craftyrc file? Options have certainly changed...
ok, yes i suspected also it might have something to do
with the .rc file,
maybe there's now a new .rc option to show more under the 'time' heading ?

Because upon further inspection i noticed a difference in the 25.x output, namely,
two numbers for time (instead of formerly one), separated
with a / (slash). So after depth (eg 1) time (eg 2.34/27.00) pv etc

(maybe the 27.0 is max 27 seconds per move or so ?)

So for the 25.x version i would like to avoid output of the /27.00
(as in above example_; or i later have to/will try to modify my code..
(if it wouldn't be better to start digging into winboard already)
I am not sure when that was done but certainly within the last year or two. It was an attempt to be more informative since the target search time changes each time there is a fail high or fail low. The output format is "current/target" so that you have some idea of how much longer you will be waiting, if nothing changes.

There is currently no way to turn that off although I will look at adding such an option.

Winboard doesn't seem to mind the current output as it works as expected.