Lost in the Maze

Last november, me and two friends (Alexandre and Nuno) had the fortune of attending yet another cool Codebits edition in Lisbon.

Being me the computer guy teamed with these two electronics guys, we had to find some idea to join forces.

THE IDEA? Remotely control a servo-driven maze.

So we hooked together two servo motors like this:

Maze

This made it possible to rotate the platform in two different axis.
We handcrafted a cardboard maze to use on top, but our motors couldn’t handle our first attempt, too much weight on the bottom servo. We had to remove half its original size to have some control over it.

Because we didn’t want this setup relyant on having a full-powered computer around, we had an Arduino powering and controlling these motors and a Raspberry Pi serving as webserver.

We printed a QRCode pointing users to a webserver we had running on the RaspPi that was getting the phones’ accelarometer data to drive the maze around. Ended up getting the accelerometer data using the following JS code:

if (window.DeviceOrientationEvent) {
    window.addEventListener("deviceorientation", function () {
        alpha = Math.round(event.alpha);
        beta = Math.round(event.beta);
        gamma = Math.round(event.gamma);
        tilt(alpha, beta, gamma);
    }, true);
} else if (window.DeviceMotionEvent) {
    window.addEventListener('devicemotion', function () {
        rotation = event.rotationRate;
        if (rotation != null) {
            arAlpha = Math.round(rotation.alpha);
            arBeta = Math.round(rotation.beta);
            arGamma = Math.round(rotation.gamma);
        }
        tilt(arAlpha, arBeta, arGamma);
    }, true);
} else {
    window.addEventListener("MozOrientation", function () {
        tilt(orientation.x * 50, orientation.y * 50, orientation.z * 50);
    }, true);
}

We even placed motion sensors for a starting and end point so we could measure users time between solving the maze.

You can checkout the final results in this video:

Having such a reactive system controlled by any iOS or Android device without having to install 3rd party software had many people surprised by our work. And that’s how we ended up getting the 5th place prize!

PacWars

I’ve been programming for a long time now, and for as long as I can remember I always thought programming could be made a fun activity, pleasing to anyone.

For a long time I toyed with the idea of creating something that would mix IDE gamification (Visual Studio Achievements), the idea of programming contests (TopCoder, Mooshak, Project Euler, UVA, SPOJ) and code evaluation (DEI Academy, CodeAcademy) that would be fun and real-time interactive.

Pacwars is my first real-attempt at this.

Pacwars Logo

What is Pacwars?

PacWars is a competitive pacman game, in witch users use any language to program a pac behaviour. These pac’s are playing each other all day long, winning points by eating dots, or even killing each other if a pac is in supermode (by eating a special dot). Each pac has a code running behind him, telling the server every 500ms witch play it want to make. Every pac gets the current map and its current location simultaneous and has a 500ms timeout to call its decision.

Pacwars Code Submission

Where did you get this idea?

My first try was at DEI Academy project. I wanted to integrate yet another code validation platform so that high school students learning Python through the website could just solve some educational challenges by submitting the code and getting instant validation. They win points with correct anwsers.

How did I do this? Leveraging google app engine. App engine allows to program a website using java or python, and automatically have google scale the website using its many servers. I was able to build a evaluation validator using a free account that could handle thousands of submissions a day.

Problems with this solution? Many. As you know the biggest problem with code evaluation is the security (the “dont delete all my files please!” type) and resources exhaustion (“don’t write infinite loops please!”). By using Google App Engine we avoided this as their servers already lock resources access by running the code inside a limited python module and they also kill threads after 15 seconds of processing time.

So this projects is up and running at (http://academy.dei.uc.pt)[DEI Academy], and has been working without problems for a year and half. But there’s still a lot of ideas pending and PacWars is my attempt at showing that.

Plan

I will be developing this as time makes itself available and will be documenting here in the form of blog posts all the main components of the development. I estimate deployment for beta testing late 2013.

Development posts

  • Beta signup landpage
  • Code evaluation benchmarks
  • Browser real-time game
  • Code submission
  • Game engine
  • Make it scale
  • Beta website
  • Deployment