Rebase

Check the state of the branch you work in,
can't you see it's a crying shame... (Forgive them)
C.I. build fails before it begins
you just broke integration tests... (Forgive them)
Servers flare and patience wears thin,
fingers pointing to you on git blame!
Rebase, rebase, rebase, rebase.
Cause we're two steps away from a real disaster,
that bad commit just destroyed master.
Pushing with force seemed to be much faster,
now you're hunted down as prey (Forgive them)
..two steps away from a real disaster,
we can no longer deploy from master.
Pushing with force seemed to be much faster,
now you're hunted down as prey (Forgive them)
Trying to push the features they create,
they ignore all conflicting changes (Forgive them)
Men discarding another men's work,
they don't care you will find their name (Forgive them)
Your behavior can only cause hate,
now the whole team has gone insane!
Rebase, rebase, rebase, rebase.

2015 IoT Day Hack-a-thing

Yesterday I was at a “hack-a-thing” event sponsored by UPB, Ubidots, Intel and I+D Electrónica, made as part of the international Internet of Things day.

iotday

I have always been curious about the scene of hardware enthusiasts, and I had the time to go so I couldn’t miss the chance 🙂

There was an introductory talk by an Intel representative about how IoT is the future today, and a nice analogy of breaking paradigms. Afterwards it was a bit hectic since the audience was very varied, ranging from students with no clue about anything, to people with a rough idea of it (i.e. me) to already assembled teams of hardware hackers. In the end the organizers decided on a Startup-Weekend like format, with people pitching their ideas and the teams being assembled.

I had no idea what to do since I know nothing about electronics… the sponsors facilitated an array of boards / microcomputers and other components (Arduino, Raspberry Pi and some other fancier stuff from Intel and more), but it was a very short time for me to learn how these work and deliver something; I thought on doing a simple game using the Geolocation API so I could work with just smartphones, but in the end I pitched myself as a volunteer from the software side to a team with an existing idea, I needed to know how these things work.

I ended up working with 2 nice guys finishing their electronic engineering degree; they already had an idea for a Smart Home project so we went into it.

The guys had a lot of ideas so what we did first was trying to organize them into a pitcheable product, here’s what I came up with.

SmartHome Functional / Component Diagram
SmartHome Functional / Component Diagram

The work we did was basically:

  • Wiring things into the Arduino board
    • Temperature Sensor
    • Distance Sensor
    • Contact Sensor
    • Fan
  • Programming the Arduino board (In C)
    • Make the temperature sensor fire the fan if under some temp
    • Making the distance sensor beep if less than some distance
    • Send the data from the sensor via a serial interface to the Raspberry
  • Setting up the camera in the Raspberry Pi so it sent data (via TCP I think)
  • Programming the Raspberry Pi (In Python)
    • Receive the serial data from the Arduino board, parse it and send it to Ubidots via the Python API
    • Display the data received from the arduino board (This was on the plan, but we didn’t manage to implement it; pygame kicked us in the face after trying a lot making it work)
  • Setting up Ubidots
    • Creating the data source and the variables
    • Creating the widgets and getting the embed code
  • Making a web interface
    • Show the streaming data from the camera connected to the Raspberry Pi
    • Create a simple layout for the product
    • Include Ubidot widgets using their embed code.
A Raspberry Pi with a mounted mini display
A Raspberry Pi with a mounted mini display

After lots of wrangling and work we managed to have something for the jurors to appreciate; the guys did most of the work with the arduino to raspberry communication being one of the hardest part (and I think also the temperature sensor stuff, but I don’t know about that 🙂 )

Making things, feel like a "maker"
Making things, feel like a “maker”

We struggled to make pygame work to show the data in a small screen of the Raspberry Pi but didn’t manage to have it. However we managed to do the whole trip from the sensors on the Arduino to the Raspberry Pi and to the Ubidots Cloud, and then show them on a web interface, it worked!

Last minute rush with serial communications.
Last minute rush with serial communications.

The jurors decided our project was pretty nice and gave us some nice stuff, we split the loot and I got a Raspberry Pi which is sitting in my desk now, looking at me asking what I’m going to use it for… I don’t know yet but I’ll know soon!

The Web monitor powered by Ubidots
The Web monitor powered by Ubidots

Other prizes included an Intel Edison microcomputer (which I think is pretty cool!) and some merchandise from the sponsors.

The prizes for the 1st place
The prizes for the 1st place

All in all, thanks to the organizers of the event, I learned a lot and met some cool people, hoping to see more of these being done in the city!

Great Team!
Great Team!

Stygian Abyss 1.3 released

Work continues with jucarave. Play online and share with your friends! Also check our podcast about it if you haven’t

  • Increase resolution of dungeon textures
  • Increase resolution of monsters
  • Ranged enemy attacks
  • Darken monster colors
  • Improve sounds
  • Walking sound
  • Regen Mana over time

1.3-1 1.3-2 1.3-3

We are looking for a pixel artist to:

  • Enhance the monster sprites with textures, correct shadows and better colors
  • Add more detailed walking animations for monsters
  • Add attacking and dying animations for monsters
  • Add animations for the viewport weapons
  • UI frame similar to Ultima Underworld

If you are interested, check what we currently have and you may find a way to contribute!

The Voice of Slashland 1 – Let’s talk about Stygian Abyss with Jucarave

We made a podcast-like thing; it ended up a bit too long but you may find it interesting, listen to it here!

(Sorry about the quality for my voice recording, I had some microphone issues.)

Things we talk about:

  • Who is Jucarave (Camilo Ramirez) and how we met
  • Our entry for 2015 7DRL Challenge, Stygian Abyss
    • The backstory for the project from the Britannian Underworld and other proof of concept made by Jucarave.
    • The idea behind Stygian Abyss
    • How we feel about it after the 7DRL challenge
    • We react to the reviews made for the game.
    • The reaction to the game from the Ultima community
    • The future of Stygian Abyss.
  • Other projects by Jucarave.

Stygian Abyss 1.2 – New weapons, Intro and ending

Play online!

Stone veins
Stone veins
Intro
Intro

Gameplay

  • Add new weapons and armor
  • Reenable weapon degradation
  • Increase swimming speed

Graphics

  • Animated, bigger and solid dungeon features
  • Changed sprites for Dragon, Gazer, Skeleton
  • Generate different cavern walls

Player Experience

  • Fix typos
  • Reduce messages (Specially in battle)
  • Show player level
  • Add intro and instructions
  • Enhance ending sequence

Bugs

  • Prevent missile serialization issue
  • Fix kerning issue on UI

Stygian Abyss 1.1, Save games, compass, better melee and more!

One week after the 7DRL challenge, I have continued working hard with jucarave on the game!

Play online now! Gameplay vid here

The repo for the continued development is here; this version comes with the following:

The new title screen depicting the avatar
The new title screen depicting the avatar
New class selection
New class selection
Viewport weapons, compass, lowered lava
Viewport weapons, compass, lowered lava
  • Allow Saving and Loading games (using O)
  • Add compass
  • Add weapons on viewport
  • Change melee mechanics
  • Lower water and lava from the floor level
  • Added music tracks to each dungeon level
  • New title screen
  • New select class screen
  • Include 7drl hotfixes (Missing textures)
  • Change item icons and graphics
  • Add new textures for Dragon and Hydra
  • Add Lava Lizard
  • Add features to level
  • Tweaks on pixel font
  • Several tweaks on collisions
  • Lots of infrastructure work

Projects off the top of my head

  • A matchmaking platform for coders, musicians and artist to get together and make their projects happen.
  • A gamified experience to help people get rid of their debts.
  • Polishing Quadrigan’s UI and launching it to the public.
  • Using the Ananias engine to create a new game based on CastlevaniaRL.
  • Releasing Ananias on iOS
  • Reviving and releasing Pixal on it’s original scope, tournament only.
  • Resume development of the Virtual Universe platform.

CircularJS 1.1 – Tutorial

Hi!

About a month ago I created a small lib to serialize and deserialize objects with circular references for JavaScript. I’ve decided it’s about time to write a short tutorial about it. You can get it here

What’s this about?

If you already know what the issue with serializing circular structures is, proceed to the next section

Games, and other kind of frontend JavaScript apps, often have complex structures of linked objects in memory that you’d eventually want to serialize for persistence, be it to save the game, or to keep complex user preferences, or whatnot.

Modern browsers have the JSON.stringify and JSON.parse methods, and they work great for simple objects, but the moment you want to use them for a complex object you’ll get…

typeError

The reason for this is that once the stringify method detects an object has a reference to another object it has already stringified, it will panic since processing it risks ending up in an infinite process, given that that object might then indirectly reference the object that’s currently being stringified!

CircularJS allows you to circumvent this issue by generating a table of references and flattening the objects so that they only keep a reference to that table, then you can safely serialize the base object and the table, and use that data to deserialize it back!

Real life scenario

Consider this simple scenario, you have a Game object you’d want to persist, and it has two attributes: One for the current Level of the game, and another one for the Player. At the same time, the Player Object contains a reference to his current level.

Untitled (2)

Let’s recreate it quickly in JavaScript.

function Game(){
  this.currentLevel = null;
  this.player = null;
}

function Level(){}

function Player(){
  this.currentLevel = null;
}

var game = new Game();
var level = new Level();
var player = new Player();
game.currentLevel = level;
game.player = player;
player.currentLevel = level;

So, let’s say you want to serialize your game object so that you can later resume the game, this should be simple right? let’s just do:

var serializedGame = JSON.stringify(game);
localStorage.setItem('game', serializedGame);

…and then, to restore, we could just do….

var serializedGame = localStorage.getItem('game');
var gameObject = JSON.parse(serializedGame);

But this won’t work! JSON.stringify will complain the moment you try to serialize the game object, because it finds a circular reference to the Level object, the panick!

CircularJS to the rescue!

You can overcome this issue using circularJS! solution is as simple as:

var serializedGame = circular.serialize(game);
localStorage.setItem('game', serializedGame);

And then, when you have to load the game

var serializedGame = localStorage.getItem('game');
var gameObject = circular.parse(serializedGame);

For this to work however, you’ll need to add a small bit to your classes initialization:

function Game(){
  this._c = circular.register('Game');
  this.currentLevel = null;
  this.player = null;
}

function Level(){
 this._c = circular.register('Level');
}

function Player(){
  this._c = circular.register('Player');
  this.currentLevel = null;
}

The register function adds required metadata to your JavaScript objects, basically assigning an uniqueId to each object, as well as keeping track of what class it’s an instance of.

Using this metadata, circularJS is able to fully recreate the object, including the class (or rather function) it was an instance of!

Revivers and transient fields

The past section should cover most of the scenarios you’ll need, but when it comes to real life, you might need to fine tune the process.

Consider now that there are some fields you’d rather NOT serialize, but you need them to be reset when restoring the object state. That’s when revivers and transient fields come to play.

Continuing with our example, let’s pretend that the Player object has a Sprite attribute, which is his graphical representation, the sprite depends on the Race of the player. We don’t want to save it, since sprites are set up by our engine on initialization.

function Game(){
  this._c = circular.register('Game');
  this.currentLevel = null;
  this.player = null;
}

function Level(){
 this._c = circular.register('Level');
}

function Player(){
  this._c = circular.register('Player');
  this.currentLevel = null;
  this.race = null;
  this.sprite = null;
}

For this example we will also have at hand a SpriteCreator object, which is in charge of creating the sprites on runtime, it has a createSprite method which takes a spriteId, and can create sprites for the different races.

What we need to do here is register the Player class on circularJS, defining the transient methods and the reviver function:

circular.registerClass('Player', Player, {
  transients: {
    sprite: true
  },
  reviver: function(player, spriteCreator){
    player.sprite = spriteCreator.createSprite(player.race);
  }
}

This affects the behaviour of circular in two ways: it won’t (try to) save the sprite when serializing the player object, and when deserializing it it will recreate the sprite object at runtime. To do this, you’ll need to send the sprite creator object to the parse method:

var serializedGame = localStorage.getItem('game');
var gameObject = circular.parse(serializedGame, theSpriteCreator);

“Safe” objects

Finally, in order to save memory and processing time while parsing / serializing, you might want to declare a class to be “safe”; this means that circularJS will keep it off the reference management process and will just serialize it directly. You can use this for simple objects that do not reference other objects (just native values), or plain objects that are not meant to represent instances of classes. Be warned tho! if you add a reference to an object marked as safe, it may generate a circular structure and circularJS will fail!

To mark an object as safe, use the circular.setSafe method, i.e.

function Player(name, x, y){
  var location = {
    _c: circular.setSafe(),
    x: x,
    y: y
  };
  var name = name;
}

Circular will then understand the location object won’t need to be checked for circular references, but it’s YOUR responsability to keep objects from being assigned to it! 🙂

And that’s about it!

Feel free to send your comments or contributions to the github repo!