Temple of The Roguelike Forums
Development => Programming => Topic started by: Pueo on September 08, 2012, 03:53:12 AM
-
My computer science class in school is teaching us Python, and I was wondering if it's viable to create a roguelike in said language. I know that Python is a fully featured language, so it theoretically should be viable, but I wanted to know if it was good, specifically for roguelikes.
Are there libraries to help with RL development? Is it (relatively) easy to get into? What's the portability like? Those kinds of things.
-
Python is good programming language and works well for creating a roguelike. It is easy to use, has good set of features and friendly community. Python is portable, unless you're doing something very system specific, same program will run on different platforms. Because Python is interpreted language, it will run somewhat slower than native applications written in C/C++ for example. But with roguelikes that usually isn't a problem (and you can always mix Python with C/C++ if you want speed at certain parts).
I'm writing a roguelike with Python and so far haven't had any problems because of the language, on the contrary. I'm using PyQt for user interface and bunch of libraries for testing. I'm not aware of any libraries that are specifically aimed at writing roguelikes, but those might exists.
Python is both strongly and dynamically typed. They'll most likely go through this at school much better than what I can explain, but http://en.wikipedia.org/wiki/Duck_typing gives short and nice explanation too. If you have been programming with statically typed languages like C/C++, Java or such, this feature might take some time to get used to (certainly took some time for me).
Another feature that sometimes confuses/annoys people is that white space matter for Python programs. There isn't special character or keyword to mark end of function for example. Instead of special keywords, indentation of code is used.
http://python.org/doc/ has huge amount of information available. That is usually the place where I turn when I don't know or understand something about how Python works. Of course, if you have specific questions, I can always try helping where I can.
-
Thanks, that answered my question :)
Follow up question: can Python run on iOS devices (iPad/iPhone)? I would like to write programs for those devices as well, but I don't want to have to learn another language just yet.
-
I don't develop anything for iOS, so I might not be the best person to answer. There is Python for iOS (http://pythonforios.com/), but that's not really suitable for writing games (no graphics output yet). It seems to me that using Python on iOS devices is currently pretty limited.
-
The good thing is if you learn one language, like Python, you can easily pick up others. Very very easily.
Here is an article you might like, it's about programming Roguelikes in Python.
http://roguebasin.roguelikedevelopment.org/index.php/Python
Here is a tutorial on how to make a roguelike using Python.
http://roguebasin.roguelikedevelopment.org/index.php/Complete_Roguelike_Tutorial,_using_python%2Blibtcod
Have fun! Making a roguelike is a great way to learn a language.
-
As said above, it is an interpreted language. Do not ignore that information. "Interpreted" means that someone has to interpret it and that in turn means nobody will be able to run your game unless they have installed the intepreter. And some people will not install it just to try out your game.
-
Also note that there might be version issues. The Python port of libtcod is affected by that - apparently there are problems when switching between x86/x64 versions and Python 2.x/3.x (though there's a workaround for the latter one iirc).
-
Libtcod is a great set of roguelike libraries that works with Python, and there are lots of examples of python games out there you can copy source from. Using python is probably one of the quickest ways to get started in roguelike development. I would recommend looking into Py2exe before release though, as getting python games running on Windows can be a huge pain.
-
Also note that there might be version issues.
True. Some programs simply come with entire python with it, like Blender. It's a problem when people need to be sure what version is the proper one and you may end up having several versions of python.
-
Also note that there might be version issues.
True. Some programs simply come with entire python with it, like Blender. It's a problem when people need to be sure what version is the proper one and you may end up having several versions of python.
Of which the 2x and 3x versions of Python are not compatible!
I have a neutral stance toward Python's syntax. It's a nice try, but some very basic things are not very intuitive. The stock libraries and classes are quite powerful, though a loop with 10k+ iterations will slow down significantly as compared to Java or C++. I also don't like Python's politics. Their goals and their decisions don't always seem to line up.
I'm also being forced to learn it for university. It is very easy to learn and to use, and writing quick simple prototypes is a breeze. It's powerful, but my inner being despises it.
-
Python is a great language! I have a little trouble intuiting Python code, because I think my brain has become hardwired to curlybrace languages over the years, but that's my fault, not Python's. :P
can Python run on iOS devices (iPad/iPhone)?
There is probably a roundabout way to get it to work, just like there is for Java and other stuff. But unless you want to have aggrivating hacky stuff on your hands and/or too much work getting something running, I think you're still pretty much stuck with ObjC + XCode for any "real" work on iOS. Apple recently relaxed their insane licensing terms a bit, but as of yet I haven't seen anything else that's really viable yet.
I stick to Android myself. Maybe it's not as cool, but the platform is way, way more open than iOS, and that (in my opinion) makes it a lot easier to develop on.
-
I think, you just should try out some languages and see in what you feel the most comfortable with. I've tried out Python by myself and I don't like it but that does not mean I claim it is a bad language or would not be suitable for your project.
If you want to support iOs in the longterm, you may check C#/Mono, which is available for every major platform (Windows/Mac/Android/Linux/iOS etc.). Just be aware of that for Mono on Android/iOs you have to pay a quite high license fee/year (but using Mono for Windows/Mac is free).
C# and its libraries is a cool language, much more superior than Java.
I've just started today my own roguelike project with C#/.NET
Just my thoughts.
-
Python is perfectly sufficient for writing a RL. Depending on your design, you may have to optimize stuff like map generation and AI a bit, but where's the harm in that? And although it is an interpreted language, there are tools to convert a Python project into binaries for Windows (py2exe works well enough) and OS X (py2app, amongst others, which I haven't tried out). So your users won't have to install Python as long as you put in half an hour worth of extra work.
As always,
Minotauros
-
I'm a huge Python fan.
Linux folks shouldn't have any issues with version differences. It's trivial for Linux users (using any reasonable Linux distro) to have multiple Python versions installed.
Before you pick the version of Python to use, make sure the extensions you want to use work with it. It can be non-trivial to recompile extensions for Python -- especially for Windows.
I'm specifically a Python 3 fan. The fixes put in place for Python 3 are useful and important for the growth of the language. More importantly, Python 3 is the future, and when folks use Python 2 impacts how quickly they can stop supporting two major versions.
If you use Python 2.x, expect everyone else to migrate to 3.x before you, and then the Python folks to drop support of 2.x, and then a major security issue happens and you're the last person effected by it. For a 7DRL you might not care about this. If you're trying to make a new major Roguelike, however, this could definitely be an issue.
Unfortunately, on Windows having Python 3 installed interferes with basically any other program that has features to use Python. (LibreOffice/OpenOffice fails to start if I have it include Python support, etc.)
Last time I looked at Python Roguelike development my requirement to use Python 3 meant I was writing my own UI code using TkInter. This was ~3 years ago, though.
My advice: Look in to py2exe (for Windows) and py2app (for Mac OS X). They'll allow you to make a first-class application using Python. Both py2exe and py2app work basically the same way, they create a ZIP file of the compiled Python code bundled with the Python interpreter.
To finish it off, on Windows you need to use a installer-creation program like the Nullsoft Installer. And on Mac OS X you'd create a "DMG" file. If you have access to Windows and Mac OS systems it is straight-forward to create packages for Windows, Mac OS X and DEB-based Linux distributions. (I've never created packages for other Linux package management systems so I can't say how easy it is.) At a university it should be possible to get access to both Mac OS X and Windows machines. Otherwise it's probably easiest to have a Mac and either dual-boot or have Windows in a VM. (Linux runs smoothly in a VM everywhere without license issues.)
By shipping your game as a standard installer for Windows and Mac OS X and source for everything else, you're basically completely covered in terms of making it easy for the folks that "need" it easy, and making it possible for the people using odd operating systems you've never heard of.
Cheers,
Steven Black
-
For fancy UI things and Python 3, there's always PyQt. If possible at all, using Python 3 would make sense. But as yam655 said, that depends on the libraries you want to use.
I wouldn't worry about installers and creating executables at this point. It pays to keep them in mind for the distant future, but that's probably something you would want to tackle after getting something together.
-
I wouldn't worry about installers and creating executables at this point. It pays to keep them in mind for the distant future, but that's probably something you would want to tackle after getting something together.
I agree completely. First get something working.
The folks who have issues with running something for a "different" version of Python? Those are the people that benefit from having easy installers. It is a subset of users that is important to get, considering the size of the Roguelike userbase.
When the extensions are readily available for a platform the py2exe/py2app solutions are simple and straight-forward. It's a distraction until things are working -- but if you're familiar with the process it's much faster to spin it up for a new project.
If you're familiar with the process and you've done it for a simple test using the extensions you plan to use beforehand, it is totally doable to have nightly builds for each platform for a 7DRL project. (Especially if you ignore the installers and just ship as ZIP files.)
If it is doable for a 7DRL (seven day Roguelike challenge) it is something you should seriously consider when your project hits the beta stage and you want real players to test it out.
Cheers,
Steven Black
-
Thanks for all the replies, guys (and possibly gals :)). I guess for now I'll work on Python, and if I start getting troubles with iOS, I'll just learn Objective C (which should be easy with my newfound Python knowledge) :P
-
i'm a novice programmer too who wants to write a simple roguelike, i learn two languages - c and python (well, a bit of javascript too, but it doesn't matter, for roguelikes it looks like a worse version of python with a browser instead of an interpreter) and i decided that python will be harder to write something for me as for an almost complete novice. yes, harder, i preferred to have arrays of structures, functions and sprintf instead handy classes, methods and python's amazing string support for two reasons:
with c i don't need any additional libs at all, even ncurses, i can have color and arrow input with basic c libs. it saved me a lot of time, i already have a working very basic game - draft of level generator (random placement of walls, random monsters, traps), basic ai (chasing, rounding obstacles), combat, moving&fighting hero, basic hud, even some drafts of item implementation (inventory, dropping, looting), while if i had chosen python i would probably have spent most of time trying to understand how to use some lib to have almost the same output (i don't want to use graphic anyway)
easy executables and portability, i can use the same code for windows (compiled with cygwin) and linux, while i don't even figured yet how to make exe from a python script