Copying code

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Thomas Mayer
Posts: 385
Joined: Thu Mar 09, 2006 6:45 pm
Location: Nellmersbach, Germany

Re: Copying code

Post by Thomas Mayer »

Rebel wrote:
zamar wrote:
Rebel wrote: Here is the deal, provided a programmer already has an engine and he wants to copy code from another engine:
Why would anyone want to copy code from another engine? Copyright laws in most Western countries prohibit copying anything without author's permission.
IPPO is freeware.
Reading another person's engine and writing your engine by using similar ideas is of course okay. But resulting functions, semantics, arrays are going to very different.
Here is an example that proofs you wrong, at least if you think I did nothing wrong, which I think you do :wink:

2-3 years ago I went through the Fruit source code because of the raging Rybka debate and I found something I did not have, penalizing a trapped bishop on the 6th rank. So I took it and it resulted in the following code.

Code: Select all

	if (board[A6]==WB && board[B5]==BP) score=score-64;
	if (board[H6]==WB && board[G5]==BP) score=score-64;
	if (board[A3]==BB && board[B4]==WP) score=score+64;
	if (board[H3]==BB && board[G4]==WP) score=score+64;
My own code, I copied nothing from Fruit. However, compare this with the Fruit source code, 100% identical, not only semantically equal, even code wise equal.

Did I plagiarize Fruit ?
you took the idea which is in that case not that easy to type differently. (The only reason why I do not have something similar in Quark is, that Quark counts mobility for the bishop and the penalty looks more like

Code: Select all

if (mobility_bishop<something) score-=penalty;
I mean whether something is a clone of something else depends as well on quantity then quality. E.g. the shift from one board representation to another one is tremendous work but of course it doesn't make the result in itself unique.
Let's say if I share one pattern in my eval with another engine my engine is still no clone, but if most of my eval has exactly the same patterns then another one maybe even in the same order without adding a lot of other sustantial parts, this looks fishy. Who decides when it is too much ? Don't know... Common sense ? But that is still different for each human being.

Greets, Thomas
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Copying code

Post by michiguel »

Thomas Mayer wrote:
Rebel wrote:
zamar wrote:
Rebel wrote: Here is the deal, provided a programmer already has an engine and he wants to copy code from another engine:
Why would anyone want to copy code from another engine? Copyright laws in most Western countries prohibit copying anything without author's permission.
IPPO is freeware.
Reading another person's engine and writing your engine by using similar ideas is of course okay. But resulting functions, semantics, arrays are going to very different.
Here is an example that proofs you wrong, at least if you think I did nothing wrong, which I think you do :wink:

2-3 years ago I went through the Fruit source code because of the raging Rybka debate and I found something I did not have, penalizing a trapped bishop on the 6th rank. So I took it and it resulted in the following code.

Code: Select all

	if (board[A6]==WB && board[B5]==BP) score=score-64;
	if (board[H6]==WB && board[G5]==BP) score=score-64;
	if (board[A3]==BB && board[B4]==WP) score=score+64;
	if (board[H3]==BB && board[G4]==WP) score=score+64;
My own code, I copied nothing from Fruit. However, compare this with the Fruit source code, 100% identical, not only semantically equal, even code wise equal.

Did I plagiarize Fruit ?
you took the idea which is in that case not that easy to type differently. (The only reason why I do not have something similar in Quark is, that Quark counts mobility for the bishop and the penalty looks more like

Code: Select all

if (mobility_bishop<something) score-=penalty;
I mean whether something is a clone of something else depends as well on quantity then quality. E.g. the shift from one board representation to another one is tremendous work but of course it doesn't make the result in itself unique.
Let's say if I share one pattern in my eval with another engine my engine is still no clone, but if most of my eval has exactly the same patterns then another one maybe even in the same order without adding a lot of other sustantial parts, this looks fishy. Who decides when it is too much ? Don't know... Common sense ? But that is still different for each human being.

Greets, Thomas
It is not easy to draw a line, and this will always be subjective. But, the amount of information content is what suggest where that line "may be". Ed's example is of very low information content.

If you can write a concept in English (or another human language), and then you translate that concept into code, that should be ok. Ed's example fall into that category too. For instance, I could write a very similar code just following the words "a bishop trapped in a6 by a pawn". Ed's code is very straightforward, so the chances to have identical code if I write it in a straightforward way are really high.

Information content is a key component related to these issues. For instance, a PST could have very high or very low IC. If I tune each square separately for each piece, the IC will be high. But if I have a simple stupid formula to calculate all of them, the IC will be much lower. The simpler the lower.

The question should be, how much (unique) IC are you copying? The answer may be subjective, but it should be phrase along these lines.

Miguel
Dave_N
Posts: 153
Joined: Fri Sep 30, 2011 7:48 am

Re: Copying code

Post by Dave_N »

In the strictest sense I think the answer is yes the code is copied, but if the code is distributed under a relaxed licence with the specific statement that it can be reused for free then it does not matter, and its polite to give credit, for example lots of demo app's don't even contain a license, and source code supplied with books is often distributed with the "supplied as is with no express warranty" and "permitted to redistribute" statement, so if they aren't specifically bound to a licence (Free BSD etc) they can be used - the programmer has to make the decision concerning the ethics of using the code. Another point is that often the best code is tried and tested over many years and programmers do not wish to reinvent the wheel, and other paradigms like "open source is best" or "time is money", and so in some cases a high quality product looks good if it is open source. There is also a software engineering approach to design that involves using "black box" components to form a system block diagram.

I am still not completely convinced that the time taken to digest a project really outweighs the benefits from being the original author.
User avatar
hgm
Posts: 28478
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Copying code

Post by hgm »

michiguel wrote:The question should be, how much (unique) IC are you copying? The answer may be subjective, but it should be phrase along these lines.
I think two things should be distinguished: whether you are copying, and whether it is provable beyond reasonable doubt. Even if the information content is low, copying is illegal. Independently writing the same is not.

So the 'gray area' exists only in the provability, what you consider "beyond reasonable doubt". With things that can be done in only 3 or 4 obvious ways, the explanation that you independently produced the same code is quite credible. Especially since there are many Chess programs, so each of the 4 ways to do it must have been independently invented many dozen times, and no matter how you would implement it, it would always be identical with how some other program does it.

A consequence of this is that you can get away with copying a piece of code with very low information content. That does not mean there is a gray area on how much you are "allowed" to copy. The unambiguous answer to that is: "nothing at all". Just like you are not allowed to kill people. That doesn't mean, however, that you will never be able to get away with it. O.J. Simpson was acquitted...
jdart
Posts: 4429
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Copying code

Post by jdart »

hgm wrote:That does not mean there is a gray area on how much you are "allowed" to copy. The unambiguous answer to that is: "nothing at all". Just like you are not allowed to kill people. That doesn't mean, however, that you will never be able to get away with it. O.J. Simpson was acquitted...
I have seen a couple posters maintain that the allowable amount of copying is zero but US Copyright law has a concept of "fair use". See http://www.copyright.gov/fls/fl102.html. Plus as I said earlier, often the issue is not whether something is copied but whether that usage is allowed under the license that the user has.
User avatar
hgm
Posts: 28478
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Copying code

Post by hgm »

Well, I was not so much talking about copyright law, as about getting your engine accepted as your own work. I can copy 100% of Fruit without violating its licence agreement (if I don't change anything in it, I don't even have to release any sources, but just make a faster compile of it with an optimizer of my own design). That doesn't mean I could now call it my own engine, and would be accepted to play in most tournaments with it.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Copying code

Post by tpetzke »

The most engine programmers do their programming for fun, their own education, improving their programing skills or because it confronts them with sides of computer science they had no contact before.

Copying code makes no sense to them because it doesn't serve their interest in any way.

And then there are few that buy a WOW level 80 warrior account at ebay or or compile an open source chess engine and play a bit with the sources to call it their own. I actually don't care about them, if they get caught and are not invited to participate in tournaments anymore, bad luck.

They will get over it, life goes on.

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

Re: Copying code

Post by bob »

Rebel wrote:There currently are discussions in CCC and RF about copying and it's much confusing what is allowed and what is not.

Here is the deal, provided a programmer already has an engine and he wants to copy code from another engine:

Verbatim copying code does not exists because the variable names, data structure are not compatible, so he will have to rewrite the code anyway to his own variable names, data structures.

Is that own written code ?

Data is another matter of course, this can be done by copy&paste without or minimal changes, thus copying.
That is ABSOLUTELY NOT "own written code". No more than copying an English page and just translating it to Spanish.

That is "plagiarism 101" for students. Copy a program. Change variable names. Reword comments. Maybe reformat using an auto-indent tool. Still a copy and still considered software plagiarism.

Even copying Fruit code, and converting it to work with a different board data structure (whether it be bitboard or non-0x88 is irrelevant) is STILL copying and translating, rather than "creating".

That's the whole idea here.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Copying code

Post by bob »

Rebel wrote:
zamar wrote:
Rebel wrote: Here is the deal, provided a programmer already has an engine and he wants to copy code from another engine:
Why would anyone want to copy code from another engine? Copyright laws in most Western countries prohibit copying anything without author's permission.
IPPO is freeware.
Reading another person's engine and writing your engine by using similar ideas is of course okay. But resulting functions, semantics, arrays are going to very different.
Here is an example that proofs you wrong, at least if you think I did nothing wrong, which I think you do :wink:

2-3 years ago I went through the Fruit source code because of the raging Rybka debate and I found something I did not have, penalizing a trapped bishop on the 6th rank. So I took it and it resulted in the following code.

Code: Select all

	if (board[A6]==WB && board[B5]==BP) score=score-64;
	if (board[H6]==WB && board[G5]==BP) score=score-64;
	if (board[A3]==BB && board[B4]==WP) score=score+64;
	if (board[H3]==BB && board[G4]==WP) score=score+64;
My own code, I copied nothing from Fruit. However, compare this with the Fruit source code, 100% identical, not only semantically equal, even code wise equal.

Did I plagiarize Fruit ?
Yes and No.

Yes, because you did copy code. But No, because I do not believe anyone would say "you are a derivative because out of Nk lines of code, those 4 are identical.

But, for argument's sake, in my code, that would just be

if (trapped_mask[bishop_square] && pawns[enemy[) score -= 64;

And that would work for ANY bishop square and enemy pawn structure. Most of those trapped_mask[] values would be zero, for trapped_mask[a3] the thing would have one bit set for square b4. For trapped_mask[a4] you would find one bit set for b5. Etc.

is that a copy? Clearly not. Is it any different from what you did? Semantically equivalent at the data level. Too small to try to claim copying. A complete function, such as SEE would be far different because there are MANY different ways to write that, so such close agreement would be impossible.

BTW I do not do that a3 trapped bishop test. Cluster testing showed zero gain. The a2/h2/etc is a significant point however.
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Copying code

Post by michiguel »

hgm wrote:
michiguel wrote:The question should be, how much (unique) IC are you copying? The answer may be subjective, but it should be phrase along these lines.
I think two things should be distinguished: whether you are copying, and whether it is provable beyond reasonable doubt. Even if the information content is low, copying is illegal. Independently writing the same is not.

So the 'gray area' exists only in the provability, what you consider "beyond reasonable doubt". With things that can be done in only 3 or 4 obvious ways, the explanation that you independently produced the same code is quite credible. Especially since there are many Chess programs, so each of the 4 ways to do it must have been independently invented many dozen times, and no matter how you would implement it, it would always be identical with how some other program does it.

A consequence of this is that you can get away with copying a piece of code with very low information content. That does not mean there is a gray area on how much you are "allowed" to copy. The unambiguous answer to that is: "nothing at all". Just like you are not allowed to kill people. That doesn't mean, however, that you will never be able to get away with it. O.J. Simpson was acquitted...
I was not talking about copyright or anything specific. I was trying to explain what I think philosophically should be accepted in a discipline like this. Just my opinion. I was not talking about provability of "copying", but what I believe should be ok in the open. In fact, I was directly addressing Ed's question. An author that decides to acquire something learned from another engine may need to answer how much? how? what?

I do not believe that we can realistically ask authors to have "zero" from other engines. Someone mentions "fair use" of certain things, but also, if we consider that copying ideas or concepts is ok, many times those cannot be easily separated from code or their semantics. For that reason, I thing that information content is what matters. Of course, this would be impossible to quantify easily, but I am talking philosophy here.

Miguel