Temple of The Roguelike Forums

Development => Programming => Topic started by: watabou on July 29, 2014, 02:23:13 PM

Title: Pixel Dungeon source code
Post by: watabou on July 29, 2014, 02:23:13 PM
Hopefully, it will be useful for someone:
https://github.com/watabou/pixel-dungeon

There is nothing special in the code, I guess, and the style is too far from perfect, but it works :)

Short game info:
Quote
Pixel Dungeon is a traditional roguelike game with pixel-art graphics and simple interface for Android.

The game itself is available on Google Play:
https://play.google.com/store/apps/details?id=com.watabou.pixeldungeon
Title: Re: Pixel Dungeon source code
Post by: reaver on July 29, 2014, 02:52:30 PM
Cool, thanks!
Title: Re: Pixel Dungeon source code
Post by: Eben on July 31, 2014, 08:31:08 AM
nice, although as usual I wish it wasn't GPL so I could grab the interesting bits for my library
Title: Re: Pixel Dungeon source code
Post by: Bear on July 31, 2014, 03:27:51 PM
What licensing do you require for your library? 

'Cos, honestly, GPL usually allows that sort of thing - and if not, most of the people who'd put something under GPL will cheerfully give you explicit permission to relicense, as long as you're not trying to lock something up so nobody else can do what you did with it.
Title: Re: Pixel Dungeon source code
Post by: watabou on July 31, 2014, 07:52:47 PM
What licensing do you require for your library? 

'Cos, honestly, GPL usually allows that sort of thing - and if not, most of the people who'd put something under GPL will cheerfully give you explicit permission to relicense, as long as you're not trying to lock something up so nobody else can do what you did with it.

Exactly!
Title: Re: Pixel Dungeon source code
Post by: chooseusername on August 01, 2014, 09:36:41 AM
What licensing do you require for your library? 

'Cos, honestly, GPL usually allows that sort of thing - and if not, most of the people who'd put something under GPL will cheerfully give you explicit permission to relicense, as long as you're not trying to lock something up so nobody else can do what you did with it.
This is disingenuous and misleading.  The GPL is well known as a viral licence.  It's viral nature is the forced requirement to release any code in turn, which touches the GPL licensed code.  You do not need to necessarily license your touching code as GPL, as long as you make it available.  There is no need to relicense, except if you wish to avoid this viral requirement to release your own code.  In what way can someone relicense if you get the GPL nature whether you relicense or not?

It is unfortunate that the proponents of the GPL misrepresent it, with nothing speak like this.
Title: Re: Pixel Dungeon source code
Post by: chooseusername on August 01, 2014, 09:37:47 AM
What licensing do you require for your library? 

'Cos, honestly, GPL usually allows that sort of thing - and if not, most of the people who'd put something under GPL will cheerfully give you explicit permission to relicense, as long as you're not trying to lock something up so nobody else can do what you did with it.

Exactly!
Exactly what?
Title: Re: Pixel Dungeon source code
Post by: Omnivore on August 01, 2014, 04:21:02 PM
It is unfortunate that the proponents of the GPL misrepresent it, with nothing speak like this.

Biting off a large chunk aren't you?  It is obvious you don't like GPL, however, some of us do not like giving away the fruits of our labor so that others may profit without giving something back to the community.

When I license something as GPL, I *intend* it to be viral.

However, the authors of source code released under GPL, may at their discretion, re-release that same source code under any licensing they choose.  If a library you want to use is under GPL, I suggest you contact the author directly and negotiate for the license of your choice. 
Title: Re: Pixel Dungeon source code
Post by: Bear on August 01, 2014, 05:58:07 PM
I get where you're coming from, honestly.  I'm even sort-of in the same boat, in terms of not using GPL code in my project either.  I guess the main difference is that I have absolutely no problem with the existence of a whole boatload of code that doesn't fit in my project and you do.  I want the right to use any license I choose to, and therefore it behooves me to respect that choice without complaint when others make it.

There is nothing wrong with wanting to do something that won't allow you to use GPL code.  I am not using GPL code in the roguelike game, because GPL would allow someone else to "take over" development without my cooperation and I want to retain artistic control over what content goes into the official version of the game. 

That said, I don't have any problem at all with someone reusing my code.  I just don't want people introducing overpowered crap that will screw up game balance or design, and in doing so pretending to be a later, presumed "improved", version of the same game.  If they make a game with different content, I want them to be required to identify it as a different game.

So I picked the Artistic License instead of GPL.  People can copy the code, use it, change it, build new stuff on it, whatever -- but they can't release a changed version or derived work pretending to be a later version or continuation of my development.  If they want to release something based on my code, it cannot continue to use my project name.

Not using GPL code in my project (because it won't allow me to relicense it under the Artistic License) means I have free access to all the public-domain code that people posted and released in rgrd, free access to all the LGPL code like standard libraries, compilers, etc, and although I haven't searched for it, I suppose there is other Artistic-License code out there that I could use at will if it seems appropriate. 

That's enough.  The people who really wanted a copyleft on their code weren't writing it for my use, and I respect that.  That was their right, they exercised it, and it is a point of pride, not to mention the right thing to do, to honor and abide by that decision.  I want the power to make that same decision myself, and have others abide by my choice in copyright.  I'm sure as HELL not going to gripe about the choices others made. 

Title: Re: Pixel Dungeon source code
Post by: Bear on August 01, 2014, 07:43:23 PM
Anyway, getting distracted here. 

The main reason to ask what licensing you require for your library, is to see if I can make contributions.  As I mentioned in the last post, I have a bunch of code I've written which is more or less free for reuse as far as I'm concerned, and doesn't have any copyleft. Putting it in a library, completely away from the game content I want to protect, would satisfy me that it won't be used to hijack creative control over my game content.  So.... 

Seriously, what do you need?

Title: Re: Pixel Dungeon source code
Post by: Eben on August 01, 2014, 08:38:39 PM
Anyway, getting distracted here. 

The main reason to ask what licensing you require for your library, is to see if I can make contributions.  As I mentioned in the last post, I have a bunch of code I've written which is more or less free for reuse as far as I'm concerned, and doesn't have any copyleft. Putting it in a library, completely away from the game content I want to protect, would satisfy me that it won't be used to hijack creative control over my game content.  So.... 

Seriously, what do you need?

I need Apache 2.0 or compatible.

I do it that way so that people can port parts of my library to other languages without having to go GPL on their project. LGPL isn't appropriate for me because I want people to freely change and use my code, not just use the library itself.

As an example, if Blacken took my code for sizing to arbitrary fonts and put in their project, I think that would be really cool even though it's a "competing" project. The reverse of that is that when Blacken went Apache 2.0 (right before it became unmaintained) I was able to use some bits of it that were better than my equivalents.

The biggest problem with GPL license for me isn't even that I can't use the code in my non-GPL project. It's that because I can't use the code it's dangerous for me to even look at the code and risk re-implementing something that turns out to be similar enough that someone thinks I ripped it off against the license. So I end up not even looking at the code and potentially missing out on some good ideas regardless of the usefulness of the code itself.

My understanding is that if an author gives me permission to use their GPL code in my Apache 2.0 project, that code is then Apache 2.0 forever and they might as well have not made it GPL to start with. I understand why you'd want your game code in GPL though, especially for a game as popular as Pixel Dungeon. And it's a pain to try to maintain just the "library" sections in a BSD-style and the "game" sections in GPL if you're not planning that from the start.

I wish there was a license that was "Anyone may use this code freely but has to give me credit. And if they make a lot of money off it they have to give me some." But that's basically not possible :)
Title: Re: Pixel Dungeon source code
Post by: Bear on August 02, 2014, 07:52:43 AM
Well, as I understand it you can suck essentially anything that's licensed under Artistic License into an Apache-licensed project (it's compatible -- you can relicense under Apache, in the context of a different project, without infringing Artistic).  Further, just in case anyone disagrees, I have no problem contributing stuff I've written (and am otherwise licensing with Artistic License) for an Apache-licensed library.  So I'll say again.... 

What is it, specifically, that your library needs?

Title: Re: Pixel Dungeon source code
Post by: Eben on August 03, 2014, 07:56:11 PM
Well, as I understand it you can suck essentially anything that's licensed under Artistic License into an Apache-licensed project (it's compatible -- you can relicense under Apache, in the context of a different project, without infringing Artistic).  Further, just in case anyone disagrees, I have no problem contributing stuff I've written (and am otherwise licensing with Artistic License) for an Apache-licensed library.  So I'll say again.... 

What is it, specifically, that your library needs?

Do you mean what does it need in terms of functionality?

Artistic License (or more specifically the Clarified or 2.0 versions) is perfectly fine as far as me using code in my lib. Pixel Dungeon and its supporting library are both GPL, which is what I thought we were talking about with the "what my library needs" question.
Title: Re: Pixel Dungeon source code
Post by: Bear on August 04, 2014, 06:20:31 AM
If you had said that you needed pathfinding code - for example - I could have sent you a library of C routines that implement A-Star, Sight-gradient pathfinding, and Breadth-first search pathfinding, all licensed under the Artistic License.  If you had said you needed an implementation of poison, with damage over time, antidotes, a 'cure poison' spell and a 'slow poison' spell ... well, I'd have kept you in mind for when I finish what I'm planning to work on a week or two from now.

Why should we have gone on talking about Pixel Dungeon if we've already determined that it isn't what you want?  I'm asking what code functionality you would like to add to your library, If you can find it under a license that suits your needs.
Title: Re: Pixel Dungeon source code
Post by: Krice on August 04, 2014, 07:51:51 AM
It's that because I can't use the code it's dangerous for me to even look at the code and risk re-implementing something that turns out to be similar enough that someone thinks I ripped it off against the license.

That's quite funny, because all possible algorithms have been implemented under all possible licenses. But maybe it's like that in US where people copyright and patent everything starting from smileys and blinking cursors.

Btw, I was looking at one source file of Pixel Dungeon. It has magic numbers all over the place (I think it was the dungeon generator or something like that). I wonder if the rest of the source code is equally bad.
Title: Re: Pixel Dungeon source code
Post by: Eben on August 05, 2014, 08:58:24 PM
If you had said that you needed pathfinding code - for example - I could have sent you a library of C routines that implement A-Star, Sight-gradient pathfinding, and Breadth-first search pathfinding, all licensed under the Artistic License.  If you had said you needed an implementation of poison, with damage over time, antidotes, a 'cure poison' spell and a 'slow poison' spell ... well, I'd have kept you in mind for when I finish what I'm planning to work on a week or two from now.

Why should we have gone on talking about Pixel Dungeon if we've already determined that it isn't what you want?  I'm asking what code functionality you would like to add to your library, If you can find it under a license that suits your needs.

I can find that stuff as well once I know I need/want it. The value to me in looking at other peoples' code is that I can get ideas for things I didn't even know I could need or want. For example, the Blacken library had code for dice rolling based on "1d6+2" style strings. Before I looked at that I hadn't even considered doing such a thing.

Short of other people putting up RFEs on my github or emailing me (both of which have happened), I like to see what other people are doing so I can make my own product better.

I have no idea if there are any nuggets in Pixel Dungeon or not, but because I'm a law-conscious individual (in the USA as Krice guessed) I'll not be able to find out. Unless someone else who's seen the code puts in an RFE for a feature they saw.

In particular I'm interested in Pixel Dungeon because it has been commercially successful, which makes it doubly rare to be open source and in my language of choice.
Title: Re: Pixel Dungeon source code
Post by: Omnivore on August 06, 2014, 06:32:24 AM
GPL and similar are forms of licensing based on copyright law.  It is absurd to not look at GPL licensed source for fear of copyright violation.  Show me case law that says otherwise.


Title: Re: Pixel Dungeon source code
Post by: chooseusername on August 07, 2014, 02:11:17 AM
GPL and similar are forms of licensing based on copyright law.  It is absurd to not look at GPL licensed source for fear of copyright violation.  Show me case law that says otherwise.
You provide case law that shows it is safe for people to look at.  Oh wait, you can't.  Because that is an irrational assertion, as you well knew when you made the matching one yourself.  Being an open source fundamentalist, who hand waves away objection to your cause, helps no-one.

The GPL is a viral license.  It is what it was designed to be.  It removes one developer's freedom, as it gives another developer theirs.  It is rude to expect other people to take the risk, and just rely on your word that it is okay.

By the way, just so you can't imagine I dislike the GPL again, I have used software based on it in the past.  And I've released my own software based on it, which others have in turn used, in the past.  There's a lot of misunderstanding of the license, by people who haven't even read it.  And I've worked at companies where the complication of the license, has resulted in whatever was using it, not being adopted. And not because it would have been problematic to release the source code.  But because it is a legally problematic license, which makes things harder to use.
Title: Re: Pixel Dungeon source code
Post by: Bear on August 07, 2014, 04:13:20 AM
I'm no partisan.  And besides, the whole effort of developing roguelikes really has nothing to do with the license.  Hopefully we've got more important things to discuss here.

Whatever license something is available under, you either use it and abide by the license, or you don't use it.  Both are honorable choices.  Neither is worth making a complaint.  If you don't like the GPL, nobody minds if you don't use that software. 

Title: Re: Pixel Dungeon source code
Post by: Omnivore on August 07, 2014, 05:06:35 AM
You provide case law that shows it is safe for people to look at.  Oh wait, you can't.  Because that is an irrational assertion, as you well knew when you made the matching one yourself.  Being an open source fundamentalist, who hand waves away objection to your cause, helps no-one.

Fear mongering is irrational. 

Nothing in 1452 years of copyright case law leads me to believe that any of the following logically equivalent cases are true:

All of the above cases are equally absurd. 

Copyright are exclusive rights granted to the author or creator of an original work, including the right to copy, distribute and adapt the work. Copyright does not protect ideas, only their expression or fixation.  There are various, and ever evolving, limitations and exceptions to copyright.  Copyright is not a patent.

Finally, as to fear mongering, adjudication of copyright issues is expensive in time, money, and reputation.  In the absence of clear inarguable violation and/or a copyright holder willing to spend tens of thousands or more USD in enforcement, an independent software developer is relatively safe. 

In the final analysis: what Bear said above.
Title: Re: Pixel Dungeon source code
Post by: Cfyz on August 07, 2014, 10:41:04 AM
Quote from: Omnivore
Nothing in 1452 years of copyright case law leads me to believe that any of the following logically equivalent cases are true <...> A programmer violates copyright if they read any copyrighted source code and then solve the same problem in their own works.
False statement. Oracle vs. Google case has shown one indeed can be attacked because of the code that simply looks copied. This time it ended good. However, it did happen once and monstrous Google being on the receiving end must have contributed greatly to the result.
Title: Re: Pixel Dungeon source code
Post by: Omnivore on August 07, 2014, 11:43:57 AM
Quote from: Omnivore
Nothing in 1452 years of copyright case law leads me to believe that any of the following logically equivalent cases are true <...> A programmer violates copyright if they read any copyrighted source code and then solve the same problem in their own works.
False statement. Oracle vs. Google case has shown one indeed can be attacked because of the code that simply looks copied. This time it ended good. However, it did happen once and monstrous Google being on the receiving end must have contributed greatly to the result.

I suggest you reread the case.  Google did indeed copy the Java API.  The initial pro-Google settlement was overturned by the district court, yet the district court did not rule out a 'Fair Use' exception.  The case is still contested and further actions are indicated.

My quoted argument still holds.

Furthermore, the argument of mine you quote bears no resemblance to the Google v Oracle case.  The employees of Google did not merely read the Oracle copyrighted source and then implement their own version of a similar algorithm, they copied a portion (~7000 lines) of the Oracle source.
Title: Re: Pixel Dungeon source code
Post by: Cfyz on August 07, 2014, 12:40:38 PM
Quote from: Omnivore
My quoted argument still holds.
Well, if taken literally the statement is undeniably true right now, my bad. However, the initial question was whether is it safe to look at the source code or not.

Quote from: cnet.com
The jury similarly found that Google did not infringe on English-language comments in CodeSourceTest.java and CollectionCertStoreParameters Test.java or source code in seven "Impl.java" files. However, it agreed that Google did infringe on the rangeCheck method in TimSort.java and ComparableTimSort.Java.
Here is the code of rangeCheck:
Code: [Select]
/**
 * Checks that {@code fromIndex} and {@code toIndex} are in
 * the range and throws an appropriate exception, if they aren't.
 */
 private static void rangeCheck(int length, int fromIndex, int toIndex) {
     if (fromIndex > toIndex) {
         throw new IllegalArgumentException(
             "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
         }
     if (fromIndex < 0) {
         throw new ArrayIndexOutOfBoundsException(fromIndex);
     }
     if (toIndex > length) {
         throw new ArrayIndexOutOfBoundsException(toIndex);
     }
 }
Google might have copied thousands of lines but in the end the war was fought over individual pieces a dozen of lines in length. If you look at some source code you are more likely to write a similar one. With modules as small and trivial as rangeCheck or modules demonstrating some clever trick you might end up writing the same (or very similar) code unintentionally.

My point is, it's just damn scary. I can't guarantee that I would have implemented rangeCheck any differently, both code and comments (having looked at original code at least once and being bound by the similar code conventions).
Title: Re: Pixel Dungeon source code
Post by: Omnivore on August 07, 2014, 01:43:41 PM
With modules as small and trivial as rangeCheck or modules demonstrating some clever trick you might end up writing the same (or very similar) code unintentionally.

My point is, it's just damn scary. I can't guarantee that I would have implemented rangeCheck any differently, both code and comments (having looked at original code at least once and being bound by the similar code conventions).

It would be very easy to implement a rangeCheck clone without ever seeing the original.  In cutting edge cases like Google v Oracle, we're once again seeing the effects of clueless judges and jurists being asked to render opinion beyond their capabilities.   Can you imagine the travesty of similar copyright litigation in an even more idiomatic language, say one with built in coding conventions such as Google's own Go?  Bring software patents into the picture and we can scare ourselves into immobility. 

So yeah, as things seem to stand at the moment, if you are a large company you probably don't want to take many chances of even giving the appearance of infringing on another large company's copyright.

As for me, I'm not going to lose any sleep over it.  If Bear (or anyone else reading this) wants to sue me because I read their copyrighted code (regardless of license) and some small part of my published code resembles some small part of theirs, go ahead, take your best shot.  I'll even go one step further and say that if I want to violate your copyright, I can easily do so and pretty much be gauranteed to get away with it.  The fear factor is way overblown.
Title: Re: Pixel Dungeon source code
Post by: Eben on August 08, 2014, 06:20:12 AM
Having spent some time thinking the arguments over and discussing things with other folks, I would have to agree that I've perhaps been overly paranoid.

However, if looking at code and re-implementing it is effectively risk free (or incredibly small risk), then why use GPL at all? You're basically just being a dick and wasting peoples' time by re-implementing code rather than just letting them use yours. You're not protecting your ideas and clever tricks at all (which is what patents are for).

So yeah, I've concluded that my fear was unjustified, but so is using GPL.
Title: Re: Pixel Dungeon source code
Post by: Omnivore on August 08, 2014, 05:43:18 PM
However, if looking at code and re-implementing it is effectively risk free (or incredibly small risk), then why use GPL at all? You're basically just being a dick and wasting peoples' time by re-implementing code rather than just letting them use yours.

When I put a license on code I publish, I'm making a statement of intent. 

To me, GPL says "Here's some code you can freely use in your own GPL'd stuff".   Now there is no way that I'm going to know if someone violates that and uses it in a closed source commercial product.. but the violator will know and perhaps someday be motivated to give back something to the community.

If I want to be a dick and waste people's time, forcing them to re-implement, I don't publish the code at all.

In the case where you have Some Other License, if you want to use excerpts, snippets, from my GPL'd code, I'm not going to object, though I'd appreciate a attribution and an email.  That is the kind of thing you need to negotiate with the author of the package.

However if you want to wrap my entire GPL'd package in your SOL'd program, effectively turning my code into SOL'd code instead of GPL'd, well.. you're SOL (Shit Outta Luck).  Other authors may feel differently on a case by case basis.
Title: Re: Pixel Dungeon source code
Post by: Eben on August 08, 2014, 10:05:04 PM
moved conversation over to http://forums.roguetemple.com/index.php?topic=4260.0 (http://forums.roguetemple.com/index.php?topic=4260.0)