PyBotLearn

PyWeek is finished. Unfortunately, I didn’t have enough time for it this year, so I’m almost a DNF. The theme for this year was Robot. My idea ended up being more like an application than a game. I wanted to create an educational environment for teaching programing to children. Something similar to Logo. The idea was to build a game where your could program a small robot. It should be interactive so children could experiment on the fly.

In other words, It should be something like this: A window with a robot and a world, bellow a Python console. The users should be able to write commands in the console and the robot should execute them. The robot should be able to interact with it’s environment and with the user too. Error, warnings, etc, should be given to the programmer in a friendly way. Additionally, there should be various challenges that the programmers should solve. This should be the fun factor for the game.

But, unfortunately, as I said before, I didn’t have more that a couple of hours every day since Thursday, so I’ve failed on most of my objectives, and the only thing I have is a barely working demo. No challenges, no fun, no objects, no cool environment. Any way, I still like the idea, and I will try to continue with this project. I would love to hear more opinions about it.

My final submission was called “PyBotLearn”. You can download it from my PyWeek 6 Entry Page.

Here is a small video of the demo:

A higher resolution video can be downloaded from here

Effective Text Editing

I saw the video 7 Habits For Effective Text Editing 2.0 that arhuaco recommended months ago. I was tempted to start learning Vim, but after thinking for a while, I came to the conclusion that there is no good reason for learning Vim. I still don’t get why people likes Vim that much. Most of the features that Bram Mooleenar showed in the video have been present in other tools for years and, in my humble opinion, they work much better than in Vim. Other things Bram talked about are just too crazy for me (He suggested that word processing would be more productive if we edit every paragraph in Vim and then copy-paste it on Microsoft Word… WTF!!)

Here are my habits for effective text editing:

Golden Rule: Use the best tool for the Job. I have learned that using a generic text editor for everything leads to be very unproductive. I like to use JEdit as my generic Text Editor. I love it for things like XML, C/C++, this weblog, etc. It has all the advanced features I need in a text editor. I used to use it for C# and Python but I discovered that using an specialized IDE for these languages is thousands of times more productive. Now I use MonoDevelop for C# and PyDev for Python.

The most important features I need when editing source code that can be hardly founded in a generic text editor are:

  • Good Code Completion. Note the “Good” word is remarked. Some generic text editors have support for code completion but most of the time is very, very poor. For C#, MonoDevelop is the open source tool with the best code completion out there (ok, maybe #develop has good code completion too). For Python it’s a bit more difficult due the dynamic nature of the language. I have tested many editors and IDEs and I think PyDev has the best code completion (I’ve heard that Wing IDE has good support too). Code completion is specially useful when you’re working with large libraries like GTK+.
  • Refactoring Operations. Rename, go to definition, go to parent definition, encapsulate, look for references, etc. They are essential features, it’s impossible to be effective without them.
  • Integrated Debugger. This one is missing from MonoDevelop. Hopefully will be there for the next release. It’s lovely how with a simple click you can create a break point in your code, run it, and it will stop right there, then you can easily watch every object state and even add some code (on dynamic languages).
  • Version Control Integration. Automatic add, remove, rename subversion files. Easily track the changes on the files. I love the ChangeLog integration of MonoDevelop. Eclipse has a good support for Subversion too.
  • Integrated UI Editors. It saves a lot of time if you’re writing GUI applications.
  • Task list. If you put notes on your source code comments such as: TODO, FIXME, NOTE, HACK, etc. It will generate a list with all notes present on all files, so you can look for pending things easily. This feature is present in MonoDevelop, PyDev and JEdit. I love it.
  • Integrated Help. Put the cursor on a word, hit F1 and automatically open the help browser with the page for the class or method description for the object or definition you selected.

There are other cool features that I like and most of the time are present in a good generic text editor:

  • Code folding.
  • Easy comment, uncomment of lines.
  • Advanced search and replace.
  • Diff viewers. JEdit has a Diff plug in, but I prefer Meld.
  • Splits. Actually I have not seen a tool with a split support as good as JEdit.

Involúcrate+GNOME

Last week I went to Lima (Perú) to attend Involucrate+GNOME. I really had a good time. Special Thanks toDiego, who invited me. Of course, I’ve got everything what I’ve seen in peruvian tv for years and never had the opportunity to taste. Inca-Cola, Chicha Morada, Cremolada, etc. I also verified that no one can eat a Margarita cookie as a normal cookie, leafs must be eaten first 😛

En Peru

Photo Stolen directly from Tatiana’s FlickrMore Photos on Flickr

Comming soon…

  • PyWeek: March 30th. Of course, I’m not going to miss it.
  • Summer of Code 2008. Receiving applications on March 24th. I’m Trying again. Last year I couldn’t apply because I was in London and I suspended my studies. I hope the third one is going to be the winning one.
  • GUADEC 2008 Istanbul. Registration and sponsorship requests open!

Game bits

Making an Indie MMO
I found the video of Daniel James‘s presentation for the Game Developers Conference Independant Game Summit. Very interesting. I’m impressed to see how Puzzle Pirates was made by only six people. There are also various interesting tips for MMO developers out there.

Igda scholarships
Igda will award 25 scholarships for the Game Developer Conference 2007. It will be in San Francisco on February 18-22.

Open Liero
Liero was one of my favorite freeware games of all times. I was very pleased to see that there is an open source implementation around similar to what OpenTTD is for Transport Tycoon Deluxe.

Urban Terror
These days, I can be found playing Urban Terror, a tactical like Counter Strike. Urban Terror is based on Quake III Arena and is completely open source. My nick name is Kira. Yes is because of Death Note.

PyWeek Ended

PyWeek is over. It was absolutelly fun!. My final entry is not what I would call a finished product, but it’s not bad. A couple of hours before the challenge end, the pyweek.org server went down. We had to send a md5 sum of our final entries to one of the event’s coordinators via e-mail.

Video of my game:

http://video.google.com/googleplayer.swf?docId=-3566000892545301155&hl=en

My code and more detailed comments in my PyWeek Entry Page.

PyWeek

Tomorrow, I’m going to participate in the fifth edition of PyWeek. PyWeek is a challenge in which participants must develop a video game in one week using Python. I like the idea because it brings a possibility to finish a project and have some fun by the way.

Some of the games created during PyWeek are really awesome. It’s amazing the fact that they were made in only one week. My favorite games of previous editions of PyWeek are:

I also like the competition and challenge feeling that you can breath in PyWeek.s

It’s possible to participate in two categories: Individual and Team. This time I am going to participate as Individual. I am thinking in use PyGame only. Even when some people are talking about Panda3D. I also want to use Blender to create pre-rendered sprites. I have been learning it secretly for a while. The result has been exactly what I expected: I suck as a graphic artist. My models are absolutely ugly, but at least I can do something for a game. By the way, now I prefer Blender to Wings3D for 3D modelling.

Screenshots of my attempt to model an aircraft with Blender. I also tried some kind of cell-shading or toon-shading redering:

If I suck with Blender. I prefer not even talk about my talent with sounds and music.

See you in one (py)week!

Vala

These days, a lot of people on GNOME planet are talking about Vala, a new programming language aimed to facilitate the development of applications and libraries for the GNOME platform. Vala is very similar to C#, but what is interesting about it, is that it’s perfectly integrated with the Glib/GObject object system. The compiler translates the Vala source code into C. It uses GObject to create classes and interfaces, and GIDL metadata for introspection. This has some advantages: there is no need for any additional runtime, Vala programs are compatible at ABI level with C programs, writing bindings for existing GNOME libraries is really easy and straightforward. Alberto Ruiz wrote about how simple was to write a binding for GtkMozEmbed. After look at howtraumatic were the Java bindings for Gtk, or how difficult has been the creation of GStreamer bindings for Mono, I think this is the best feature of Vala.

Anyway, I think Vala still lacks some key tools in order to become a real choice for GNOME developers. In the case of Mono, there is a great advantage called MonoDevelop. Days ago, version 0.15 of this awesome IDE was released. With no doubt, I think this is the best IDE for GNOME. The GUI editor, the subversion integration, the localization support and autotools integration are very appreciated features. Of course, is not perfect, It lacks a debugger and fixes for some annoying bugs, but it’s a very active project and has a great community behind it.

And talking about languages, at the end of this month, it should be released the alpha version of Python 3.0. On June, Guido van Rossum published a report about the final decisions concerning Python 3000. I am very happy with most of the changes, it was time to break some backwards compatibility. Python will be even better that what it is now.

Dolor de cabeza con Python

Un problema de usar lenguajes dinámicos es que, al no tener etapa de compilación, no es posible detectar muchos de los errores sino hasta que se lanza alguna excepción mientras el programa se ejecuta. Un problema peor es cuando por alguna razón el error no produce una excepción y el programa termina funcionando erróneamente si dar ninguna pista sobre dónde puede estar el problema.

Examinen este pedazo de código en Python:

class MyClass:
	pass

if MyClass() < 1:
	do_something()
else:
	do_something_else()

o algo más curioso todavía:

if MyClass() < float('-infinity'):
	do_something()

do_something() siempre se ejecuta.

Lo correcto debería ser que al hacer este tipo de comparaciones se lanzara una excepción. La única forma de poderlo hacer debería se cuando sea explícito que el objeto puede compararse.

Noten que este código si lanza una excepción del tipo TypeError:

a = MyClass() + 1

Según lo que me dijeron en #python, parece ser que todos los objetos en Python están habilitados para hacer comparaciones. Esta es la razón por la cual se pueden ordenar fácilmente listas con cualquier tipo de datos en ellas. Debido a que arreglar esto supondría un corte con la compatibilidad hacia atrás, sólo podremos disfrutar de una adecuado comportamiento hasta que tengamos Python 3.0. Si esto hubiera estado listo ahora mismo me habría ahorrado un gran dolor de cabeza buscando un error.

Scratch

Quedé impresionado con Scratch, el nuevo lenguaje para introducir a los niños en la programación desarrollado por el MIT Media Lab. Lo bueno es que es libre (Licencia MIT), aunque sólo está para Mac y Windows, pero dicenque ya lo están portando para el X0 del proyecto OLPC. ¡Que bacano sería ser niño y tener este juguete!