The users of Socorro at Mozilla, the Stability team, have very specific needs that vary over time. They need specific reports for the data we have, new aggregations or views with some special set of parameters. What we developers of Socorro used to do was to build those reports for them. It's a long process that usually requires adding something to our database's schema, adding a middleware endpoint and creating a new page in our webapp. All those steps take a long time, and sometimes we understand the needs incorrectly, so it takes even longer. Not the best way to invest our time.
Développement
Thursday, 26 February 2015
Spectateur, custom reports for crash-stats
By Adrian on Thursday, 26 February 2015, 12:00
Tuesday, 2 December 2014
Socorro: the Super Search Fields guide
By Adrian on Tuesday, 2 December 2014, 05:27
Socorro has a master list of fields, called the Super Search Fields, that controls several parts of the application: Super Search and its derivatives (Signature report, Your crash reports... ), available columns in report/list/, and exposed fields in the public API. Fields contained in that list are known to the application, and have a set of attributes that define the behavior of the app regarding each of those fields. An explanation of those attributes can be found in our documentation.
Tuesday, 1 July 2014
About Socorro
By Adrian on Tuesday, 1 July 2014, 16:00
I have been working on Socorro for about 3 years now. It was about time that I started talking about it on this blog! With this first post, I am inaugurating 2 new tags, socorro and mozilla. I'm also going to add a language tag to my posts, so each new post will either be en or fr. This way, you can choose more accurately what kind of content you want to read from this blog. The previous links on the tags lead to the filtered Atom feeds, and I will add the mozilla feed to the Planet.
Tuesday, 27 May 2014
Play Michel in Hell, our Ludum Dare 29 game!
By Adrian on Tuesday, 27 May 2014, 15:30
Last year, my friend Aurélien invited me to participate with him and a few other friends in the Ludum Dare, for the 26th edition. We made a Flash game, which is probably why I didn't write about it (how could I face my Mozilla colleagues after making a Flash game? ). It's called Sniff and it's about a drug dealer that needs to deliver its magical powder to his customers. As those customers are in a night club, you will need to use the music to find your way through the town. Beware of the cops that want to catch you, and beware of not using the different powers the drug gives you...
Monday, 8 April 2013
Soviet VS Asteroids
By Adrian on Monday, 8 April 2013, 11:00
Dear readers,
I am happy to announce today the release of a new game I worked on: Soviet VS Asteroids. The game was developed during the last jam of the Game Dev Party (see the introduction of that 4th jam [fr] or a report of the 2nd edition [en]). The concept is simple: during an entire weekend, 50 people gather, make teams and work on a game, with the goal of having something to show (and to play) in the end.
This time I decided to work with my friend Aurélien Defossez, who proposed a "planet defense" gameplay. The idea is that you are in space, and asteroids are flying at you. You will need to use your weapons to destroy those nasty asteroids and survive as long as possible. Aurélien gathered a team of 6: he was managing the project and programming, along with Louis-Rémi Babé, Maxime Viry and myself. Mathieu Perez created all the sounds and musics of the game, and did a bit of code as well. Frédéric Ostéréro drew all the beautiful graphics. With this fine team and a lot of work, we demonstrated something pretty good on Sunday evening. But it was not ready for release yet. Over the last 2 weeks, we did some bug fixing, added the missing menus (things like credits or tutorial that do not matter for the demo but are needed when you release the game to the public), and polished the gameplay, mainly by adjusting the difficulty so as many people as possible can enjoy it.
And now, it is time: we believe the game is ready to be played! At this point I hope you are excited and want to download the game as soon as possible. You can do just that by clicking one of those links:
- Windows x86 (32 bits) (if you have no idea what "x86" or "32 bits" mean, this is the option for you)
- Windows x64 (64 bits)
- Mac OS
- Linux
You can play the game with your mouse and keyboard, or with a pad. Make sure your pad is plugged in before you start the game or it will not be detected. You have 2 weapons at your disposal: a rocket launcher and a laser command. You aim at asteroids with the joysticks or your mouse and the Q, A or D keys of your keyboard. If you play with a keyboard, the lasers will fire automatically, and you can shoot rockets by clicking your mouse or hitting the space key. With a pad, you shoot with LS and RS. By pressing the Tab or Enter keys, or the Y button on a pad, you enter the upgrade menu: use your money to make your weapons better, or clear the space around you if you are overrun, or place new lasers or drones around you to improve your defense.
We all hope you are going to enjoy our game! Do not hesitate to make any comments here or to share your high scores! We would love to hear from you.
If you are interested by the technical details, there you go: the game in programmed in lua, using the LÖVE framework (also known as love2d). You can find the source code on github: feel free to fork and open pull requests or issues if you find bugs. Quick feedback on lua: it's nice, but some choices in the design of the language are weird. I definitely prefer Python, but wouldn't mind working with lua again. LÖVE on the other hand was quite a pain to work with, for 2 majors reasons: missing features (no sprite system in a 2d game framework? ) and documentation. As usual, the documentation of a tool is critical and even if the API was well documented, there was almost no tutorial, and no examples of basic features or code.
Play & Enjoy!
Wednesday, 31 October 2012
Web Game Workshop: Creating a Game with Crafty.js
By Adrian on Wednesday, 31 October 2012, 15:30
Earlier this month, I gave a workshop in Lyon to teach people how to create Web games with the now famous Crafty.js framework. 13 people attended (out of 15 open places), which appeared to be a good number: I could really help everyone and answer all the questions I received. It was a really good experience, but a short one sadly: we only had 2 hours (30 minutes being me talking about Crafty), and it's really short to be able to actually create a playable game. I think with an hour or two more some people could have had something playable.
Anyway, I created a bunch of content for that workshop, and I wanted to share it. So here it is!
Presenting Crafty.js
I spent the first 30 minutes of that workshop talking about Crafty.js, what it is, what it can do, and how it works. As usual, slides without the actual talk are not really good, but at least you will find some code examples and links to various resources in there. And who knows, maybe someone could make good use of these slides someday?
Creating Web Games with Crafty.js
Workshop: Coding a Web Game
My plan for the coding part was to come with 3 game ideas that people could work on, to provide some help (basic algorithms, some graphic resources) and to give them a working version in the end. That's what I did: I created a simple Snake game, a kind of Fruit Ninja and a Side Runner. After my presentation, I showed the 3 games I coded and asked people to pick one and start working on it. Most people picked the simplest one (some assuming it was the snake, when it was actually the Fruit Ninja clone in my opinion), and no one picked the Side Runner which was certainly harder and mostly impossible to do in less than 2 hours.
After an hour and a half of intense coding, documentation reading and some debugging (I had a few mistakes in my slides sadly), we had some snakes moving and some fruits falling!
I made a simple page with all the resources needed for this workshop:
The Crafty Workshop Awesome Page
There you can find:
- links to the base template in github or as a zip file
- short help with algorithms
- graphics
- and my own implementation of each game
I really enjoyed doing this, and I wish I can do it again someday! Thanks to everyone who attended and thanks to the Game Dev Party association for organizing this event.
Make Games, Not War /-)
Sunday, 18 December 2011
Component Entity Manager for JavaScript games
By Adrian on Sunday, 18 December 2011, 02:00
Hi everyone!
I recently wrote a library to handle a Component Entity model in a JavaScript game. I need it for my ongoing Fightly Game Engine, which I'm trying to work on. If you don't know what the Component Entity model is, here are great resources about it:
- Evolve Your Hierarchy on Cowboy Programming
- Component based game engine design on Stackoverflow
Basically, the idea is to replace classical inheritance with composition. Your game is composed of entities, each being just a list of components. JavaScript's flexibility is well adapted to this sort of programming, as it is easy to change an object to add attributes or methods to it.
That system I implemented is highly based on what Louis Stowasser did on Crafty.js. It works on both server- and client-side, and comes with a few unit tests and examples. Let's first show you how it can be used:
How to use the ComponentEntityManager
Ok, so I like showing code instead of writing English. Here is the most basic way to use that library. First, import and instantiate the Manager:
var cem = require('component-entity-manager'), myCEM = new cem.ComponentEntityManager();
Then, declare a new component:
myCEM.c('HelloWorld', function() { this.hello = function() { console.log('Hello, World!'); }; });
Now create an entity using this component:
var hi = myCEM.e('HelloWorld');
And finally use that entity the way you like. For example:
hi.hello(); // prints "Hello, World!" in the console
Pretty simple, right? Right, we only printed a "Hello World" but still, we did so by using the Component Entity model! Now you can obviously add a thousand more components, and create hundreds of thousands entities. Let's see a more concrete example before I explain why it is useful.
A more concrete example
var cem = require('../../component-entity-manager'), // Instanciate the Game Engine myGE = new cem.ComponentEntityManager(); // Create a few components that can be used in-game var Hero = { "life": 100, "defense": 100, "attack": 100, "hit": function(opponent) { var points = this.attack * 1.1 - opponent.defense; if (points > 0) { opponent.life -= Math.round(points); } return this; }, "specialHit": function(opponent) { return this.hit(opponent); } } var Wizard = { // this component requires the Hero component, and // any entity having a Wizard component will automatically have a Hero one "_requires": "Hero", "life": 80, "mana": 100, // "Overwrite" the specialHit method of the Hero component "specialHit": function(opponent) { var points = this.attack * 1.2 - opponent.defense; if (this.mana > 20) { points += 20; this.mana -= 20; } if (points > 0) { opponent.life -= Math.round(points); } return this; } } var Necromancer = { "_requires": "Wizard", "life": 70, "attack": 110 } var Paladin = { "_requires": "Hero", "defense": 150 } // Add those components to the Game Engine so we can use them myGE.addComponent("Hero", Hero) .addComponent("Wizard", Wizard) .addComponent("Necromancer", Necromancer) .addComponent("Paladin", Paladin); // Create two entities than we can manipulate var gerard = myGE.e("Paladin"), igor = myGE.e("Necromancer"); // And now play with those entities console.log("Before we do anything: "); console.log(" Gerard's life is " + gerard.life); console.log(" Igor's life is " + igor.life); gerard.hit(igor); console.log("\nAfter Gerard hits Igor: "); console.log(" Gerard's life is " + gerard.life); console.log(" Igor's life is " + igor.life); igor.specialHit(gerard); console.log("\nAfter Igor hits Gerard: "); console.log(" Gerard's life is " + gerard.life); console.log(" Igor's life is " + igor.life);
How is this useful?
And how is it better than classical inheritance? Some people answered this better than I could do in other places (see the two links above), but here is the main point. When you come to have a very complex hierarchy, with lots of classes and dependencies between them, you will certainly end up having unneeded code in some of your objects. Let's say you have a few classes: Moving, Vehicle, Car. Vehicle inherits from Moving, Car inherits from Vehicle. Now at some point you want to add a BrokenCar class, to represent a car than cannot move. It seems quite logical to make it inherit from Car as it shares almost everything with it. But that is the point: almost. As you don't want that BrokenCar to move, you will have to overwrite the code from Moving, or to break your entire hierarchy. With composition, you just specify directly what you need in your object. For example, I want this object to be a Car, a Vehicle and a Moving. Or I want that other object to be a BrokenCar, a Car and a Vehicle (but not a Moving). It is more flexible and allows for a wider range of mixing.
Now about that library precisely. The main features are here: you can create components and declare them, express requirements in a component, create entities from one or several components, get entities from their components. It is intended to be used as a building block for any JavaScript game, or any JavaScript game engine. Oh and I'm pretty sure you guys can find some other use cases as well... :)
Licensing
I release this code under a simple MIT license. It's the simplest I know. I'm considering adding a GPL-ish license as well, and maybe some BSD if people ask me to.
And the future...
There are a few things I want to add to this library: a function to get an entity from it's ID, more unit tests, more options for selectors... But what I would really, really love to hear is everything you have to say! I will gladly accept code reviews, forks, pull requests, emails, comments here...
Hack & Enjoy! /-)
Tuesday, 15 November 2011
Examples of how to break long lines in Python
By Adrian on Tuesday, 15 November 2011, 11:33
I recently started learning Python, and as I am a bad student, I didn't follow the coding style PEP8 recommends. So I'm currently in the process of rewriting all of my code to follow PEP8, and that basically means breaking long lines. I ran into several cases where I didn't know how to break my line, and the Internet doesn't seem to be very helpful about this. But fortunately my awesome coworkers are, so here are some examples of cases I had to deal with, and how I ended up dealing with them.
Before I start showing examples, I just wanted to outline the few rules that matter here about PEP8:
- Lines must not be longer than 79 characters ;
- Use 4-space indentation for blocks ;
- Alignment matters ;
- The rest of the rules is well described in the PEP8 documentation.
Breaking an if statement
if condition1 and condition2 and condition3 and condition4 and condition5 or condition6: do_stuff()
At first I did something like this:
if condition1 and condition2 and condition3 and condition4 and condition5 or \ condition6: do_stuff()
It seemed better to me mainly because that way the second line of conditions is not on the same indentation level than the content of the block, but my coworkers convinced me that using parentheses instead of backslashes is better. Reasons are backslashes are not "pythonic", and the use of parentheses shows the limits of the conditions.
Here is what I then thought would be the best solution:
if (condition1 and condition2 and condition3 and condition4 and condition5 or condition6): do_stuff()
But it's still not perfect as the block is aligned with conditions, and it makes it difficult to differenciate them. I believe now the best way to go is the following:
if (condition1 and condition2 and condition3 and condition4 and condition5 or condition6 ): do_stuff()
Assert
assert condition, "This is a very long error message because I like to be verbose when I describe assertion errors with this content: %s" % variable
Becomes
assert condition, ("This is a very long error message because I like to be " "verbose when I describe assertion errors with this " "content: %s" % variable)
Or when the condition is long:
assert condition1 and condition2 and condition3 or condition4, ( "This is a small error message. ")
Other examples?
If you ran into similar examples and couldn't find a documented solution on the Web, please share them in the comments and I'll add them here!
« previous entries - page 3 of 6 - next entries »