Bits and Pieces

Code, algorithms, languages, construction...
User avatar
Bo Persson
Posts: 14
Joined: Thu Jun 10, 2010 10:34 am
Real Name: Bo Persson
Location: Malmö, Sweden

Re: Bits and Pieces

Post by Bo Persson » Sun Mar 06, 2011 2:25 pm

benstoker wrote:
Bo Persson wrote:
benstoker wrote:
hyatt wrote:one-input -> one-output is pretty clear and well-defined. The minute you reach one-input -> multiple possible outputs, you cross the line. But not before, IMHO. Note that this is a suggestion. NO one has adopted it as a rule or policy...
Is this correct, then?

1) If one-input-one-output function, then source code of this function can be copy/pasted into an original engine.

2) If one-input-MULTIPLE-possible-outputs function, then source code of this function cannot be copy/pasted into an original engine.
No. :-)

Source code is text, and is copyrighted just like books and newspaper articles, and web pages. You can't copy that without permission.

However, and I think that's what Bob is hinting at, for a small, well defined function it is very hard to PROVE that you copied it (unless you also copy all the comments verbatim :-)). To be a bit cynical, what is legal is actually what you get away with. Innocent until proven guilty!

For these small code snippets, we have the additional quirk that a disassembled version of my MemberCount function will look exactly like the "disassembled" version of Crafty's asm code. We can all see that it is not because I copied the code from Crafty, but because I, Bob, and the MS compiler writers have all read about the bit twiddling techniques Gerd linked to. Even the compiler understands the intention, and generates the correct code!

In this case it is hard to accuse anybody of stealing the technique, because "everybody" knows about it already.

So, if you have one small function that is identical, it is legal because of the "get away with it" rule. If your have hundreds of identical functions, you will be in more trouble!
Well, well, well. You have really done it now. Hyatt put his imprimatur on my best attempt to express a keep-it-simple-stupid guideline for writing an "original" engine, and you come in and blow it all up. I give up. I am convinced now that I will never know or understand whatever the heck it takes to write an "original" chess engine. Because as soon as one expert agrees on a set of criteria, another expert is always there to not just disagree, but completely diagree. If there exists this thing called an "original" engine, I will not know it if it stands before me, I will just take it to be a kind of ascription of "beauty", and that therefore "originality" is in the eye of the beholder.
To me, an "original" engine is an engine you wrote yourself. ;)

It will of course be based on ideas also used by others. Usually your set of ideas will be slightly different from mine, or from Bob's. The originality lies in actually implementing some ideas in your own way, to see how it works out. Perhaps you can find a new combination that works better than what others have done? Or implement it in a smarter way? That's the fun for me.

I have previously used examples from my BitBoard class (using C++ and templates, instead of ugly C macros) that I wrote after seeing what Bob had done. That's where the MemberCount function comes from. After realizing what Bob did, but without looking too closely at his code, I coded up my implementation on my own. I thought it was obvious to use 0, 45, 90, and 135 degrees for the rotations, so that is what I have. Only several years later did I notice that Bob rotated his boards 0, 90, and +/- 45 degrees. Works either way!

So now we have totally different implementations of the same idea. Using an idea, but not copying code.

As we have seen earlier, it is possible that two implementations of a small function can result in the same machine code, by chance. There could be more functions like that in a program, maybe two, maybe five. What cannot happen by chance is that every function is the same, doing exactly the same things on exactly the same data structures.

So what happens if the similarities are not for five functions, and not for all of the program? Six? Perhaps. Twelve? Well... Hundred and fourty seven identical functions. Definitely copied!

benstoker
Posts: 110
Joined: Thu Jun 10, 2010 7:32 pm
Real Name: Ben Stoker

Re: Bits and Pieces

Post by benstoker » Sun Mar 06, 2011 6:43 pm

Bo Persson wrote:
benstoker wrote:
Bo Persson wrote:
benstoker wrote:
hyatt wrote:one-input -> one-output is pretty clear and well-defined. The minute you reach one-input -> multiple possible outputs, you cross the line. But not before, IMHO. Note that this is a suggestion. NO one has adopted it as a rule or policy...
Is this correct, then?

1) If one-input-one-output function, then source code of this function can be copy/pasted into an original engine.

2) If one-input-MULTIPLE-possible-outputs function, then source code of this function cannot be copy/pasted into an original engine.
No. :-)

Source code is text, and is copyrighted just like books and newspaper articles, and web pages. You can't copy that without permission.

However, and I think that's what Bob is hinting at, for a small, well defined function it is very hard to PROVE that you copied it (unless you also copy all the comments verbatim :-)). To be a bit cynical, what is legal is actually what you get away with. Innocent until proven guilty!

For these small code snippets, we have the additional quirk that a disassembled version of my MemberCount function will look exactly like the "disassembled" version of Crafty's asm code. We can all see that it is not because I copied the code from Crafty, but because I, Bob, and the MS compiler writers have all read about the bit twiddling techniques Gerd linked to. Even the compiler understands the intention, and generates the correct code!

In this case it is hard to accuse anybody of stealing the technique, because "everybody" knows about it already.

So, if you have one small function that is identical, it is legal because of the "get away with it" rule. If your have hundreds of identical functions, you will be in more trouble!
Well, well, well. You have really done it now. Hyatt put his imprimatur on my best attempt to express a keep-it-simple-stupid guideline for writing an "original" engine, and you come in and blow it all up. I give up. I am convinced now that I will never know or understand whatever the heck it takes to write an "original" chess engine. Because as soon as one expert agrees on a set of criteria, another expert is always there to not just disagree, but completely diagree. If there exists this thing called an "original" engine, I will not know it if it stands before me, I will just take it to be a kind of ascription of "beauty", and that therefore "originality" is in the eye of the beholder.
To me, an "original" engine is an engine you wrote yourself. ;)

It will of course be based on ideas also used by others. Usually your set of ideas will be slightly different from mine, or from Bob's. The originality lies in actually implementing some ideas in your own way, to see how it works out. Perhaps you can find a new combination that works better than what others have done? Or implement it in a smarter way? That's the fun for me.

I have previously used examples from my BitBoard class (using C++ and templates, instead of ugly C macros) that I wrote after seeing what Bob had done. That's where the MemberCount function comes from. After realizing what Bob did, but without looking too closely at his code, I coded up my implementation on my own. I thought it was obvious to use 0, 45, 90, and 135 degrees for the rotations, so that is what I have. Only several years later did I notice that Bob rotated his boards 0, 90, and +/- 45 degrees. Works either way!

So now we have totally different implementations of the same idea. Using an idea, but not copying code.

As we have seen earlier, it is possible that two implementations of a small function can result in the same machine code, by chance. There could be more functions like that in a program, maybe two, maybe five. What cannot happen by chance is that every function is the same, doing exactly the same things on exactly the same data structures.

So what happens if the similarities are not for five functions, and not for all of the program? Six? Perhaps. Twelve? Well... Hundred and fourty seven identical functions. Definitely copied!
I think your comments get back to the distinction that BB+ made between pure copyright law and "chess engine orginality". These concepts are not equivalent. Conceivably, one could violate someone else's copyright yet still have an "original" engine. You are right that copy/pasting code is almost by definition a copyright infringement! But, I am pretty sure that the ICGA is going to focus squarely on this "originality" issue. They have no interest in adjudicating copyright infringement claims.

Perhaps this example illustrates the distinction?: an engine that is inarguably original as to its search and evaluation functions, yet has simply copy/pasted UCI string parsing code from someone else's copyrighted engine, even without proper credit to the original author of the UCI code. I would guess that the ICGA would not penalize this engine as being a "clone", even though it infringes, in part, someone else's copyright.

This is not to say, of course, that a copyright infringement is never an issue about "originality."! If I copy/paste search() and eval(), then the engine is not original and also infringes a copyright.

Post Reply