About the code of strelka

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

Moderator: Ras

Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: About the code of strelka

Post by Tord Romstad »

Tony wrote: So he changes the tables befor he uses them ? So the tables can't be compared with data tables from another program ?

Now why would somebody do that ? I really wonder. Could it be meant to hide something ? No, it couldn't.
The tables in question are present in virtually all bitboard programs, with some small variety depending on board layout. They are nothing more than precomputed bitboard masks for detecting passed pawns, doubled pawns, etc. Nothing very interesting.

Strelka's main function contains a big 'for' loop which iterates over all 64 squares of the board and XORs all entries of all bitboard arrays by Random[0][13]:

Code: Select all

  for (i = 0; i < 64; i++) {
    MaskPawnDoubled[i] ^= Random[0][13];
    MaskPawnIsolated[i] ^= Random[0][13];
    MaskPawnProtectedW[i] ^= Random[0][13];
    MaskPawnProtectedB[i] ^= Random[0][13];
    MaskPawnAttacksW1[i] ^= Random[0][13];
    MaskPawnAttacksB1[i] ^= Random[0][13];
    MaskPawnAttacksW2[i] ^= Random[0][13];
    MaskPawnAttacksB2[i] ^= Random[0][13];
    MaskPawnPassedW[i] ^= Random[0][13];
    MaskPawnPassedB[i] ^= Random[0][13];
    ...
  }
I have no why this is done, but it is difficult to believe that it is in an attempt to hide something, because none of the arrays involved are very original or interesting. They can all be found in lots of open source bitboard chess programs (including mine).

The arrays Christopher asks about below are not XORed with Random[0][13].
Christopher Conkie wrote: PawnStruScore0 and PawnStruScore1

I would like to know what Yuri thinks these two arrays do.
Yuri probably doesn't read the CCC, but I hope he won't mind that I explain the purpose of these two arrays. The two arrays are used to compute king shelter scores. The program looks at the white and black pawns in a 3x4 rectangle in front of the king, and considers these as two 12-bit integers. One of these integers is used to look up a value in PawnStruScore0, the other a value in PawnStruScore1. These values are added to obtain a king shelter score. It's all very simple and straightforward.

Tord
User avatar
Werner
Posts: 2965
Joined: Wed Mar 08, 2006 10:09 pm
Location: Germany
Full name: Werner Schüle

Re: About the code of strelka - thanks Tord -

Post by Werner »

Hi Tord,
thanks a lot for the explanation.
Perhaps this is the reason we do not hear more from Chris 8-) 8-)
Werner
Christopher Conkie
Posts: 6074
Joined: Sat Apr 01, 2006 9:34 pm
Location: Scotland

Re: About the code of strelka - thanks Tord -

Post by Christopher Conkie »

Werner wrote:Hi Tord,
thanks a lot for the explanation.
Perhaps this is the reason we do not hear more from Chris 8-) 8-)
Pity....

Now we know Tord knows......but did Yuri.

After all those are in Rybka too.....
Christopher Conkie
Posts: 6074
Joined: Sat Apr 01, 2006 9:34 pm
Location: Scotland

Re: About the code of strelka

Post by Christopher Conkie »

I have no why this is done, but it is difficult to believe that it is in an attempt to hide something, because none of the arrays involved are very original or interesting.
I have no idea why people hex edit names in chess engines.

After all.....the name is not that interesting.
User avatar
Werner
Posts: 2965
Joined: Wed Mar 08, 2006 10:09 pm
Location: Germany
Full name: Werner Schüle

Re: About the code of strelka - thanks Tord -

Post by Werner »

Hi Chris,
sorry I wrote a little bit provocatively.
The only reason was to get an answer from you: did you find a proof for a clone with that tables :D :D
Werner
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 9:19 pm
Location: Oslo, Norway

Re: About the code of strelka

Post by Tord Romstad »

Christopher Conkie wrote:
I have no why this is done, but it is difficult to believe that it is in an attempt to hide something, because none of the arrays involved are very original or interesting.
I have no idea why people hex edit names in chess engines.

After all.....the name is not that interesting.
There is a very fundamental difference. The name is usually unique to the engine, while the arrays we are talking about are shared by almost all bitboard chess engines in the known universe.

Also, the idea that somebody who is a specialist in cryptography can't find a better way to obfuscate a few tables than XORing every single entry of all tables by a single random number strikes me as extremely absurd. Even I could have done something much more difficult to decipher in a few minutes of work.

Tord
Christopher Conkie
Posts: 6074
Joined: Sat Apr 01, 2006 9:34 pm
Location: Scotland

Re: About the code of strelka

Post by Christopher Conkie »

Tord Romstad wrote:
Christopher Conkie wrote:
I have no why this is done, but it is difficult to believe that it is in an attempt to hide something, because none of the arrays involved are very original or interesting.
I have no idea why people hex edit names in chess engines.

After all.....the name is not that interesting.
There is a very fundamental difference. The name is usually unique to the engine, while the arrays we are talking about are shared by almost all bitboard chess engines in the known universe.

Also, the idea that somebody who is a specialist in cryptography can't find a better way to obfuscate a few tables than XORing every single entry of all tables by a single random number strikes me as extremely absurd. Even I could have done something much more difficult to decipher in a few minutes of work.

Tord
You have all the code there and yet you don't know why he did this although. It would be helpful if you knew this. Surely there must be a reason?
Christopher Conkie
Posts: 6074
Joined: Sat Apr 01, 2006 9:34 pm
Location: Scotland

Re: About the code of strelka - thanks Tord -

Post by Christopher Conkie »

Werner wrote:Hi Chris,
sorry I wrote a little bit provocatively.
The only reason was to get an answer from you: did you find a proof for a clone with that tables :D :D
We have found plenty Werner some of which is good, some suspicious and some bad.

On the whole Strelka 1.8 is much more like Rybka 1.0 beta than Strelka 1.0.

The main problem here is whether it is ok to disassemble something that no source was supplied for. It's worse when that something is a commercial product. If this is how people can be allowed to proceed it is not fair on those original authors who through hard work strive to get there engines better from scratch.

If all you have to do is disassemble something, recompile it and then call it your own, everyone would come straight in at 2700 elo.

The WCCC would be full of Shredders, Loops and Rybkas in disguise which is hardly "competition".

Do you think Stefan Meyer-Khalen would be amused?

In truth the person who can know most about whether Strelka is a clone of Rybka and to what degree, is Vas himself.

Of course there is Fruit in there so it needs the GPL. Problem is Rybka is not GPL so how would you release the source?

If you asked Yuri Osipov to write an engine from scratch do you think it would be 2700 elo?
Uri Blass
Posts: 10788
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: About the code of strelka - thanks Tord -

Post by Uri Blass »

Christopher Conkie wrote:
Werner wrote:Hi Chris,
sorry I wrote a little bit provocatively.
The only reason was to get an answer from you: did you find a proof for a clone with that tables :D :D
We have found plenty Werner some of which is good, some suspicious and some bad.

On the whole Strelka 1.8 is much more like Rybka 1.0 beta than Strelka 1.0.

The main problem here is whether it is ok to disassemble something that no source was supplied for. It's worse when that something is a commercial product. If this is how people can be allowed to proceed it is not fair on those original authors who through hard work strive to get there engines better from scratch.

If all you have to do is disassemble something, recompile it and then call it your own, everyone would come straight in at 2700 elo.

The WCCC would be full of Shredders, Loops and Rybkas in disguise which is hardly "competition".

Do you think Stefan Meyer-Khalen would be amused?

In truth the person who can know most about whether Strelka is a clone of Rybka and to what degree, is Vas himself.

Of course there is Fruit in there so it needs the GPL. Problem is Rybka is not GPL so how would you release the source?

If you asked Yuri Osipov to write an engine from scratch do you think it would be 2700 elo?
I think that the answer is positive
I think that what he did to rybka is an harder task than writing 2700 elo engine.

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

Re: About the code of strelka

Post by Uri Blass »

Tord Romstad wrote:
Tony wrote: So he changes the tables befor he uses them ? So the tables can't be compared with data tables from another program ?

Now why would somebody do that ? I really wonder. Could it be meant to hide something ? No, it couldn't.
The tables in question are present in virtually all bitboard programs, with some small variety depending on board layout. They are nothing more than precomputed bitboard masks for detecting passed pawns, doubled pawns, etc. Nothing very interesting.

Strelka's main function contains a big 'for' loop which iterates over all 64 squares of the board and XORs all entries of all bitboard arrays by Random[0][13]:

Code: Select all

  for (i = 0; i < 64; i++) {
    MaskPawnDoubled[i] ^= Random[0][13];
    MaskPawnIsolated[i] ^= Random[0][13];
    MaskPawnProtectedW[i] ^= Random[0][13];
    MaskPawnProtectedB[i] ^= Random[0][13];
    MaskPawnAttacksW1[i] ^= Random[0][13];
    MaskPawnAttacksB1[i] ^= Random[0][13];
    MaskPawnAttacksW2[i] ^= Random[0][13];
    MaskPawnAttacksB2[i] ^= Random[0][13];
    MaskPawnPassedW[i] ^= Random[0][13];
    MaskPawnPassedB[i] ^= Random[0][13];
    ...
  }
I have no why this is done, but it is difficult to believe that it is in an attempt to hide something, because none of the arrays involved are very original or interesting. They can all be found in lots of open source bitboard chess programs (including mine).

The arrays Christopher asks about below are not XORed with Random[0][13].
Christopher Conkie wrote: PawnStruScore0 and PawnStruScore1

I would like to know what Yuri thinks these two arrays do.
Yuri probably doesn't read the CCC, but I hope he won't mind that I explain the purpose of these two arrays. The two arrays are used to compute king shelter scores. The program looks at the white and black pawns in a 3x4 rectangle in front of the king, and considers these as two 12-bit integers. One of these integers is used to look up a value in PawnStruScore0, the other a value in PawnStruScore1. These values are added to obtain a king shelter score. It's all very simple and straightforward.

Tord
Tord,
I guess that it was done originally by rybka and the reason that it was done is not that these arrays are the most important array but to protect
rybka's code.

Even if these specific arrays are in all bitboard programs then something else is not in all bitboard programs and an hacker who is going to look at many tables is going to have more work to find the important tables.

Uri