setjmp() - another one

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

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

Re: setjmp() - another one

Post by bob »

chrisw wrote:
bob wrote:
chrisw wrote:Bob argued that the existence in the Rybka code of setjmp() was "interesting" because this also existed in Fruit and nowhere else.

Uri pointed out that Tom Kerrigan's public program TSCP also used setjmp() and that some other programs were likely/possibly developed, legally, off TSCP as basis.

I'm an engine programmer and always had user interface programmers working in support, so I got very lazy and understand very little about DOS, windows, C support functions and so on. setjmp() knowledge is no way a speciality of mine.

However, casting my mind back many years, I'm fairly sure that the Ren Wu Chess program which was also worked on by Ren at Oxford Softworks used setjmp() to unwind the search on a timeout. CSTal, by contrast, did a proper search unwind.

There are two ways to exit Search() on a timeout or user intervention. The 'correct' way, I suppose, is to unwind the Search back to the start using unmove simultaneously unstacking the variables.
The brutal and simple way is simply to jump straight out, reseting the stack pointer. I guess this is setjmp().

I'l be very surprised if numbers of programs, especially those designed years ago without SMP in mind, didn't use the brutal setjmp() technique to break the search.

Bottom line: setjmp() is not unique and its use doesn't imply anything, certainly it cannot imply copied code.
Again, "I think..." "if I remember"... I said it is rare. It appears to be so. So the presence is both programs is still "interesting". The problem is that longjmp() does not restore the board to the starting position, nor anything else other than whatever is on the stack. That's why it is considered a bad solution to any known problem, because you can get back to the starting point with contradictory state information.
Entirely agreed its no good solution, but that's not the point. You said it was rare/unique whatever. It isn't. And therefore it's another nail in the probably used the same code coffin. It isn't.
Wait just a minute. "Rare; adj. occurring infrequently. etc."

It is in fruit, it is in Rybka, it is in TSCP, and it is in Movei where it was _copied_ from TSCP. So we have four programs, out of hundreds. I believe 1 in 100 would be considered "rare" by anybody's definition. And when one of the four has admitted to copying the code from another of the four, and when one of the four is suspected of copying the code from another of the four, then it becomes 2 out of hundreds and is even rarer.

Rare is not an arbitrary word . Nobody would call 25 out of 100 rare. Probably not even 10 out of 100. But one out of 100 or less? that is rare. But what is _more_ telling is that someone would have the same _bad_ code. :) If you were any good, you would at least copy _good_ code, I would think. So something that is provably rare, and bad, shows up in unexpected places and it is something that makes you think. Wouldn't convict anyone on it, but I would use that as a data point when weighing _all_ evidence.
swami
Posts: 6640
Joined: Thu Mar 09, 2006 4:21 am

Re: setjmp() - another one

Post by swami »

What Chris said regarding moderation is true. Chris had done most of the moderation work in CTF, and also in CCC _before_ these intense debate took place. Now I and Thorsten are doing the moderation work because Chris is involved in discussion but he does occasionally get his chance.

Moderation tool available to mods is poor, thats what resulted in Chris splitting the thread into 4 sub threads in order to delete the quoted replies... that include offensive parts quote in it.
Guetti

Re: setjmp() - another one

Post by Guetti »

Ahem, Bob, I have some deja-vus when reading your posts. Are you trapped in a time loop?
kranium
Posts: 2129
Joined: Thu May 29, 2008 10:43 am

Re: setjmp() - another one

Post by kranium »

chrisw wrote:
kranium wrote:Chris,

it appears that you are trying control everything. it's overbearing.

why do you need to decide what is 'admissible' and what isn't?
and why do you keep talking like a lawyer?
why has the original 'Questions to Vas' thread been cut to pieces, with only your posts (and 1 other) remaining?
why are you trying so hard to influence Zach?
and when did I stop beating my wife?!

to your Q's

A1 I don't
A2 I don't, and will try not to if you think I do
A3 Zach complained about non-technical posts, so the thread was claned of them. Rather than delete them, they ended up comprising soem separate threads. That's the way the forum softwrae works.
A4 I don't try to

Why do you totally distort what I say? I've already posted to you about Q3, your Q1 is a negation of the truth, your Q4 is deviously snide and untrue and your Q2 just plain rude.

Try to be factual please. Attacking the personality of your opponents is never a good thing and usually indicates some problem or frustration with your own position actually.
how do these questions distort what you said?
i think they're fair questions, it's unfortunate you don't like them but i think they're overdue.
Last edited by kranium on Wed Aug 27, 2008 7:54 pm, edited 1 time in total.
chrisw

Re: setjmp() - another one

Post by chrisw »

bob wrote:
chrisw wrote:
bob wrote:
chrisw wrote:Bob argued that the existence in the Rybka code of setjmp() was "interesting" because this also existed in Fruit and nowhere else.

Uri pointed out that Tom Kerrigan's public program TSCP also used setjmp() and that some other programs were likely/possibly developed, legally, off TSCP as basis.

I'm an engine programmer and always had user interface programmers working in support, so I got very lazy and understand very little about DOS, windows, C support functions and so on. setjmp() knowledge is no way a speciality of mine.

However, casting my mind back many years, I'm fairly sure that the Ren Wu Chess program which was also worked on by Ren at Oxford Softworks used setjmp() to unwind the search on a timeout. CSTal, by contrast, did a proper search unwind.

There are two ways to exit Search() on a timeout or user intervention. The 'correct' way, I suppose, is to unwind the Search back to the start using unmove simultaneously unstacking the variables.
The brutal and simple way is simply to jump straight out, reseting the stack pointer. I guess this is setjmp().

I'l be very surprised if numbers of programs, especially those designed years ago without SMP in mind, didn't use the brutal setjmp() technique to break the search.

Bottom line: setjmp() is not unique and its use doesn't imply anything, certainly it cannot imply copied code.
Again, "I think..." "if I remember"... I said it is rare. It appears to be so. So the presence is both programs is still "interesting". The problem is that longjmp() does not restore the board to the starting position, nor anything else other than whatever is on the stack. That's why it is considered a bad solution to any known problem, because you can get back to the starting point with contradictory state information.
Entirely agreed its no good solution, but that's not the point. You said it was rare/unique whatever. It isn't. And therefore it's another nail in the probably used the same code coffin. It isn't.
Wait just a minute. "Rare; adj. occurring infrequently. etc."

It is in fruit, it is in Rybka, it is in TSCP, and it is in Movei where it was _copied_ from TSCP. So we have four programs, out of hundreds. I believe 1 in 100 would be considered "rare" by anybody's definition. And when one of the four has admitted to copying the code from another of the four, and when one of the four is suspected of copying the code from another of the four, then it becomes 2 out of hundreds and is even rarer.

Rare is not an arbitrary word . Nobody would call 25 out of 100 rare. Probably not even 10 out of 100. But one out of 100 or less? that is rare. But what is _more_ telling is that someone would have the same _bad_ code. :) If you were any good, you would at least copy _good_ code, I would think. So something that is provably rare, and bad, shows up in unexpected places and it is something that makes you think. Wouldn't convict anyone on it, but I would use that as a data point when weighing _all_ evidence.
You forget the small OS Chess program which we licenced and the programmer also worked on inhouse which I know for sure can't have come from TSCP because it was written before. That's five.

setjmp() may be politically incorrect, but before SMP was thought of it was a quick and dirty and lazy way to exit Search(). I would imagine many used it if they could avoid otherwise having to write the search unravelling code.

As to the number, well, its unknown. You can't anyway talk of five out of 500, because the 500 have not been polled. Use your brain though, (a) setjmp() is quick, easy and lazy, some programmers like that (b) lots of programs get developed with others as start, or other as advice, and lots of programs have a connection back to TSCP, as others do to Crafty and others to Gnu. So, extrapolate ideas usage from those, to get what? 100? 200? 50? Your guess as good as any. I'll go for 100.
chrisw

Re: setjmp() - another one

Post by chrisw »

kranium wrote:
chrisw wrote:
kranium wrote:Chris,

it appears that you are trying control everything. it's overbearing.

why do you need to decide what is 'admissible' and what isn't?
and why do you keep talking like a lawyer?
why has the original 'Questions to Vas' thread been cut to pieces, with only your posts (and 1 other) remaining?
why are you trying so hard to influence Zach?
and when did I stop beating my wife?!

to your Q's

A1 I don't
A2 I don't, and will try not to if you think I do
A3 Zach complained about non-technical posts, so the thread was claned of them. Rather than delete them, they ended up comprising soem separate threads. That's the way the forum softwrae works.
A4 I don't try to

Why do you totally distort what I say? I've already posted to you about Q3, your Q1 is a negation of the truth, your Q4 is deviously snide and untrue and your Q2 just plain rude.

Try to be factual please. Attacking the personality of your opponents is never a good thing and usually indicates some problem or frustration with your own position actually.
how do these questions distort what you said?
i think they're fair questions, it's unfortunate you don't like them but i think they're overdue.
When you feel the need to get personal, it's probably a subconscious warning of time to exit the discussion, since that need usually comes from a lack of other possible arguments. N'est ce pas?
CThinker
Posts: 388
Joined: Wed Mar 08, 2006 10:08 pm

Re: setjmp() - another one

Post by CThinker »

Zach Wegner wrote:
chrisw wrote:Entirely agreed its no good solution, but that's not the point. You said it was rare/unique whatever. It isn't. And therefore it's another nail in the probably used the same code coffin. It isn't.
You don't think it is rare? What, five total engines, one which has since been removed, out of how many hundreds??

Bob sums it up perfectly: "I never claimed it to be the ultimate proof. I simply said it was another suspicious detail because it is such a lousy way of writing a program."

Some people will always refuse to accept evidence when it is presented.
I don't think there is anything suspicious with using setjmp(). I also use it in Thinker. I used to use try/catch, just because it frees up all the objects that I have created, but after I did away with dynamic object allocation, I settled for the lightweight setjmp.

I actually have a different view from that of Bob. I think that not using setjmp is the lousier way of coding something like a chess engine. After each call to Search/Research/QSearch, you need check for search termination. That is a lot of code. Way too much for my taste.

I just did a quick look of the Crafty code, and it tests 'abort_search' 8 times inside the Search() function. That's 8 identical code sprinkled around all over a single function.

Contrast that with the Thinker code where I only check once at the start of Search(), and then do a longjmp.

Crafty code (note how all that checking has really nothing to do with chess search logic, but now it makes it difficult to read the real logic).

Code: Select all

Search()
{
    if (terminate search) abort_search = true;
    if (do null move) {
        Search();
        if (abort_search) return 0;
    }
    if (do IID) {
        Search();
        if (abort_search) return 0;
        if (re-search) {
            Search();
            if (abort_search) return 0;
        }
    }
    ... // 5 more calls to Search() follows
}
Thinker code:

Code: Select all

Search()
{
    if (terminate search) longjmp();
    if (do null move) {
        Search();
    }
    if (do IID) {
        Search();
        if (re-search) {
            Search();
        }
    }
    ... // 5 more calls to Search() follows
}
kranium
Posts: 2129
Joined: Thu May 29, 2008 10:43 am

Re: setjmp() - another one

Post by kranium »

chrisw wrote: When you feel the need to get personal, it's probably a subconscious warning of time to exit the discussion
...you have a point. i could have phrased them differently.
my apologies if they appear personal in nature.
User avatar
tiger
Posts: 819
Joined: Sat Mar 11, 2006 3:15 am
Location: Guadeloupe (french caribbean island)

Re: setjmp() - another one

Post by tiger »

chrisw wrote:
bob wrote:
Uri Blass wrote:
Guetti wrote:
chrisw wrote:Bob argued that the existence in the Rybka code of setjmp() was "interesting" because this also existed in Fruit and nowhere else.

Uri pointed out that Tom Kerrigan's public program TSCP also used setjmp() and that some other programs were likely/possibly developed, legally, off TSCP as basis.

I'm an engine programmer and always had user interface programmers working in support, so I got very lazy and understand very little about DOS, windows, C support functions and so on. setjmp() knowledge is no way a speciality of mine.

However, casting my mind back many years, I'm fairly sure that the Ren Wu Chess program which was also worked on by Ren at Oxford Softworks used setjmp() to unwind the search on a timeout. CSTal, by contrast, did a proper search unwind.

There are two ways to exit Search() on a timeout or user intervention. The 'correct' way, I suppose, is to unwind the Search back to the start using unmove simultaneously unstacking the variables.
The brutal and simple way is simply to jump straight out, reseting the stack pointer. I guess this is setjmp().

I'l be very surprised if numbers of programs, especially those designed years ago without SMP in mind, didn't use the brutal setjmp() technique to break the search.

Bottom line: setjmp() is not unique and its use doesn't imply anything, certainly it cannot imply copied code.
Leaving the setjmp() relevant or not argument aside for a moment, come on, you state that you believe that an engine used setjmp()? Isn't that a bit vague? You demand always hard facts and source and pretty aligned code from Zach and Christoph, so were are the facts of Ren Wu chess?
Would you believe Zach if he would write he believes that the eval of Rybka is identical to Fruit without further comment?
You always want to see facts, so please before you do a conclusion, gives us some facts.

When I look at the (far from complete) list of chess engines released in recent years at http://wbec-ridderkerk.nl/html/enginesindex.htm, I wonder how many of these engines use setjmp()? 10 of 200? More?
I think it is still a good indication, not a prove.
I do not know but movei used setjmp() at the beginning like tscp
and I simply learned from the code of tscp.

I got rid of setjmp later because I read people said it is not good
so it is not clear how many engines use setjmp.
old movei use it
new movei does not use it and you can download both old movei and new movei from wbec site.

Uri
So, you copied TSCP, which uses setjmp(). And then discovered it is a bad programming solution and removed it. Good. But notice where you got it from. That is the point of this minor side-issue. It is just another indication that perhaps something was copied, because good programmers do not use it for _many_ reasons. Perhaps Fruit started life as TSCP as well, who knows? But if programs that are suspected of being connected by common source, share a particular feature that is known to be bad programming, it is just another hint that things might have been copied...

I never claimed it to be the ultimate proof. I simply said it was another suspicious detail because it is such a lousy way of writing a program.
Ahem. Copied? I would prefer "used the idea". And if it's one line of code, there's not much else he can do, is there?

What if someone reads Crafty use of null move? The call is one line

value = -Search(ply-2); basically

how are we going to get a suitable value back from Search() without telling it to take 2 of the search depth?

Some things just are as they are.


Of course by dissecting the source code into individual lines you can use the argument "one line of code cannot possibly breach the GPL".

Considering that a 4000 lines program is composed of individual lines, and that no single line alone can breach any copyright license, then it follows that none of these lines can breach the GPL and so the program is clean.

We are talking of blocks of code that are identical or equivalent semantically. The probability of them happening in two programs writen independantly is so tiny that it makes them appear suspicious.



// Christophe
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: setjmp() - another one

Post by Zach Wegner »

CThinker wrote:I don't think there is anything suspicious with using setjmp(). I also use it in Thinker. I used to use try/catch, just because it frees up all the objects that I have created, but after I did away with dynamic object allocation, I settled for the lightweight setjmp.
It's understandable. I never said it was lousy, only rare. There's probably a few more engines too that use it, but it's simply not that common. Setjmp in itself is not rare enough to show anything, but I'd say it definitely means something. It's definitely not a difference between the programs.

I personally don't like the checking for a stop condition after each search. That's one reason why I use iterative search. :)

But I do think setjmp is pretty ugly too. When I did parallel search for Toga, one of the first things I did was replace the setjmp with an approach like Bob's. I did enclose it in a macro though, STOP_CHECK(). There was a parameter too that specified whether a move should be unmade or not.