Friday, September 18, 2009

Rigs Of Rods - understanding a new codebase

Before to get into some coding, I'm trying to get an overview of RoR's codebase. Unfortunately it's not very clean. No big deal, I created monsters worst that this... But really, trying to figure out what does a function of thousand lines called frameStarted is depressing. I would have like they took time to split what can be.. Sub-functions, sub-classes and packages not only give a felling of order, but also help comprehension.

Indeed, when you arrive in a project which is already well advanced, get some understanding of how the stuff works is the first thing to do. If someone, say Robert, is here to explain it to you, it is somehow easy. Robert will sit on a chair next to you and go straight to key classes, gives you a little sentence explaining what each class or function is supposed to do and how they are related to other classes.

If the project is big, he will skip what doesn't interest you, eventually tell you that you don't have to understand this or that to accomplish your task.

On a well structured code, the brain will classify everything in little boxes saying: this is a class for handling the terrain, this class I don't care for now, classes in this package are about physics, etc.

Alright, but when nobody is there to explain? Well, that is what comments are about, they need to replace Robert, give a picture of what is the code does. That is why all classes should at least have a little explanation that can be read by someone who doesn't know much about the code.

I can give an illustration, taken from a exam revision program I wrote:

// A file where answers are stored (with compression)
class AnswerArchive;

There it is. It's a nice comments that probably says enough for a man that already knows about the project internal details. But doesn't give the class reason of existence in the big picture, so it's little help for newcomers.

Let's try again.

// Overview:
// Answers given by the user needs to be stored to allow review of previous exams later in time.
// - the ExamReview class loads data from an AnswerArchive for this purpose.
// - the ExamState class appends given answers to the AnswerArchive at the end of a session.
// Compression is applied to the data, because the mobile version have a low storage capacity.

// A file where answers are stored (with compression).
class AnswerArchive;

Now we know who uses this class and why it exists. Because what it does is not the only thing one would like to know about a class or function, why it does it also is important.

Well, I really wish RoR developers took time to do it. They didn't so I think I'll better try to find some "Robert" in forum!

Wednesday, September 16, 2009

Rigs Of Rods - first thoughts

Our virtual driving project may radically change direction. Since we started it, "Rigs of Rods" got open-sourced and it's a very good simulator. Probably more interesting than Torcs was.

So my job now consists in understanding a new code-base and trying to get involved. Well, getting involved is basically about founding something to do that both interests the RoR's projects leaders and interests us.

After some hard time loading the repository and making it compile and execute on my computer, I played for some hours...

First feeling: the game is ok. In fact it's not really a game, just a simulator. You are given the choice between eight maps, then you pick a vehicle and drive around... You can drive cars, trucks, planes or boats. There are probably some nice physics models behind them, however somehow buggy.

Few things happened:
- I've been stuck into a wall.
- I had my car completely lost in space.
- The game suddenly became incredibly slow.

But, most of the time it's ok.

The simulation of engines sound is very good.

The graphics are correct, nothing more. But really it's too slow for what it does... My 7600GT shouldn't have such hard time display particles and vegetation. The textures shadows are buggy (sometime the shadows appear "above" me), the implementation of HDR is horrible to see. I'm sure there are some improvement in both speed and quality I can make there, I'd like to.

Concerning the geometry, roads sometime falls into the ground and require more smoothness. Hard angles make the car jump and we lose control.. I think I'll go into this code, because I still like to think providing data compatibility between Torcs, RoR and OpenRacing should open some interesting possibilities. We'll see that later...

Anyway, this is a nice simulator that I hope we can improve enough to host the our Virtual Darpa Challenge!

Thursday, June 25, 2009

Open-source will win the race for driverless cars

This project seems a bit crazy. Let's imagine the scene: you sit down on your car, tell your GPS where you want to go and close your eyes for a little nap, the car will wake you up when parked next to your destination.

But this is not science fiction: prototypes exist and big companies are working hard on this problem which will probably be the next revolution for the car industry (before oil-shortage).

Indeed, as my boss Keith Curtis often states, it's a purely algorithmic problem since all the required hardware are webcam, GPS and (eventually) lasers detectors. Cheap stuffs that we can find everywhere.

So, the first who succeeds in writing the software wins! (and probably he will win a lot!)

That's our project, we're trying to be the first to have this software working. It seems ambitious for a team of two programmers fighting against Goliaths of the car industry, but we have a secret weapon: it's called open-source!

We are initiating a project where everybody can participate. The first step is to have a car simulator and a virtual town to drive into, then we can start experimenting algorithms on a computer (instead of crashing few cars in the process).

We're informing scientists from AI laboratories, computer vision experts and trying to reach any other interested persons so this platform becomes a base for community driven development. It's a hard task, but it's the key to success.

So if you are talented and you think you can help, you are very welcome! The project is fun and we promise you'll be given back as much as you participate.

Here are some links:
- Keith Curtis' view of the project
- Launchpad project.
- Our wiki

Friday, June 12, 2009

Little contribution to the Mono/C# debate

I just got through this article which explains why "anti-mono" peoples are just stupid people, none of them even developers for the open-source community, so I wanted to add my unnecessary contribution to the Mono/C# debate.

I was first wondering where does the "anti-mono are not open-source developers" statement comes from? I am an active open-source developer and most other anti-mono people I know are too.

Anyway, I agree there is a lot of "mono is evil" vs. "mono is so cool" debates without real value, but there is at least one very strong argument against Mono, which is the most important to my little green eyes.

C# specification is driven by Microsoft, the open-source community is follower and not leader. Sure this was once true for C and using C didn't created such debate, but then you had no equivalent, open and widely recognized alternatives.

Maybe you're now asking yourself: "Why is this a problem? Why a language with an open community-driven specification is better?". Then I think you lost the point about the open-software model.

Let me go into little details.

Developers of open languages are free to create the features they like, Mono have no choice but follow Microsoft's implementation. Python's enhancement proposals is a great example of how open specification work. Everybody can write down ideas of enhancements for the language, the ideas are reviewed and discussed by the community, good ideas are accepted and will eventually go into next version of the language... This is open-source. And Mono can't do that.

Ok, I should add that my current open-source project is in written C# (not my choice unfortunately). So, please, do what I say and not what I do! If you really like open-source, I recommend you choose an open language.

Thursday, May 28, 2009

The game sound track

Nowadays, most games choose MP3 or OGG for storing and playing in-game musics, indeed it provides the artists full flexibility in the choice of creation tools. However, the data folder will quickly grow when a few MP3 are stored in.

Retro or not, we are using the old Amiga style MOD format for the music in our next game, Super FloboPoP. The format basically contains a list of samples and patterns in which you play samples at different pitch and apply a few sound effects. It's kind like MIDI with the samples stored in if you like. It's the PDF of music formats!

Its strength: a bunch of kilobytes can contains hours long musics. Also a lot of so-called trackers can be found freely all over the internet.

But it have also downsides:
- the so-called trackers are all but intuitive to use by a newcomer and have long learning curve;
- the range of effects you can apply is quite limited (and you must know hexadecimal!);
- the samples are stored as raw sound. They surely could be made lighter with new stuffs like OGG.

I'm wondering if there are alternatives, an ideal tracker-like format, with an open specification and even better: an available open source portable implementation. If I find one I'll let you know!

Thursday, May 7, 2009

Story of a lucky open-source programmer

When I was a student, one of my first hacker project was the badly-called Goom visual effect generator. Incidentally it was also the time I discovered the Linux OS, so I ended up making it a plugin for XMMS, the most popular MP3 player at the time, and released it Open Source.

It became quite popular, being among the best ones available for Linux. I can write pages about its extremely optimized SIMD assembly heart, which made it one of the first true 32 bits advanced plugin (compared to the rotating color palette oldies), but that is not what made it so popular. It became so widely used because of its very simple API and pure C code.

Nowadays, you can launch VLC, mplayer, gstreamer based players (like Totem or Firefox), or Xbox Media Player, and see that Goom already is installed on your computer. You can download it for Windows Media Player, iTunes, Winamp, etc. I'm not responsible for a single one of this ports. I just made goom an easy to integrate, dirty, but pure C code, hidden behind this simple API:

File goom.h

void goom_init(int width, int height);
void *goom_update(short *sound); /* returns RGB buffer. */
void goom_close();

I made no money for years from this project, except a few $15 donations, being able to eat like three time at Mac Donald's. But it helped me more that I could possibly expect.

The first job I found, I found it because one of the open source addict responsible for selecting applications knew Goom. It allowed me to work on exciting graphical research projects for years.

Later, a guy with money needed a guy which knows to program cool stuff. This guy knew Goom, wanted me to improve it, ended up hiring me to write a complete 3D engine.

Give something, you should always hope to be given back one day!

Sunday, April 26, 2009


Those who know me from long time probably remember how fan I was of Michael Abrash's Zen books.

- The Zen of Graphics Programming. Master the Art of Creating Fast PC Games and Graphics Applications.
- The Zen of Code Optimization. The Ultimate Guide to Writing Software That Pushes PCs to the Limit.

Those two books, where he tells us with enthusiasm some insides of his fascinating job, were certainly among the main reasons why I'm now an independent game developer and 3D engine designer. They pushed the start button!

I discovered that games and graphics applications make the area of software development where challenges and technologies are the most interesting to me, along with providing a very rewarding output.

Hoping that I can share my experience with the same talent than my "mentor", I wish you welcome to my blog and happy reading!