Brainbattle – emotiv, flash, union server
Juten Tach,
i was once again lucky enough to be able to build a fun little project. Brainbattle!
But how did it all start?
So, i occasionally give talks at the GoodSchool about technology, internet and so on. The GoodSchool is a school for new ways of communication. All things digital, social, web, etc. and it is targeted at people in the marketing world. They have lots of different events all over the year. One is “camp digital”. Seven days packed full of information, inspiration and, of course, fun things.
So, Christian from the GoodSchool this time gave me two brain sensor headsets from emotiv and asked me to build a little game with it. We decided to do a simple tug-of-war type of game.
So, how does it work?
So the setup is:
- Two emotiv epoc neuroheadsets (and their SDKs)
- Two PCs connected via a twisted Ethernet cable
- One Union Platform server (and the game control module build in Java)
- Two little client flash apps, which take the converted signals from the emotiv SDKs and send it to the server (along with game controls)
- One flash central Display app (seen in the pic above), that shows the game state.
OK, the headsets connect two their respective PC over the air via a dongle. These headsets basically read the electric signals from your brain. As you can see in the picture below, the headset has a bunch of sensors, which need to be wet (using a saline solution). The tricky part is, that the sensors ideally touch the skin, which means, you have to fight a bit with the hair of the user to get out of the way.
These signals are read from a software SDK. Part of that SDK is a “training” program. There you can basically train “actions”. Like pull, push, up, down, vanish, show and lots of others. So you train a certain action, like “pull”. For 8 seconds you think about “pull” and the programm records the signals of your brain during that time. Then if you think that thought again later, the software recognizes the pattern and knows, that you think “pull”.
Then there is a second little tool, called EmoKey. It is a simple converter. It converts an “action” into native Windows key events. So you define, that when the user thinks “pull”, it should emit a key event of the key “p”, for example. It can also do this continuously, lots of settings there.
So then i have a build a little client, which let’s you connect to the union server i have built, let the user click ready and also read those native key events. It then counts those incoming events per second and sends the result to server (every 500 ms).
The server (java) module takes those numbers from the two clients and calculates a force from it, being either positive or negative (depending on the numbers from client1 and client2). The server module of course also controls the various stages of the game, like client registering, game start, winning, and so on. The server is based on the union multiuser server, which is some nice piece of software and well documented. Its concept is around rooms and clients being in one or more rooms. The clients can send messages, set attributes on themselves or the rooms and so on. So i have created such a room, which has the game logic.
That game state is continuously send to the central flash display app, which is connected to the server as well (but only as an observer). It gets the force number and the game states and displays it.
So, that’s basically it. It took me about two and a half days to build it (and test it roughly). You can see a video of the game in action at facebook.


