Giant Tetris on a building; RI Xmas Lectures

30-12-2014

Myself and Tom Wyatt were approached by the Royal Institution Christmas Lectures this year to help with one of the demos for the lectures; a giant game of Tetris to be played on the side of the Shell Building, Opposite the London Eye. Of course, such opportunities don't often arise, so we jumped at the chance! A fun, interesting project to inspire children to hack more with their gadgets and possibly annoy their parents in the process! Fantastic!

The first lecture is all about bulbs. We had a sponsor who provided us with a set of bulbs, controlled via a small bridge. It turns out the bridge is basically an Ethernet port, connected to a ZigBee module, which in turn, connects to the bulbs, controlling their colour. We had 182 windows to cover; 13 floors with 14 window per floor. With the task laid out before us, we set to work.

Tom was keen to look at the bulbs and bridges to see if they could be made to change their colour quickly enough and over a long enough range. We ran a short test with a small number of bulbs in the building and it turned out one bridge could cover an entire floor, though only just. Tom has found a way to double the 'frame-rate'; from 1 Fps to 2 Fps! :D Considering the loopholes he had to exploit this was no mean feat. You can see the code he put together on Github.

Tetris on the Shell Building

My part revolved around writing the actual game of Tetris, keeping the architecture of the lighting setup in mind. The game is built around a logical 'tick'; on every tick the state of the game changes to the next state. This means we can alter the frame-rate dynamically to whatever we need on the night. I decided to set myself a challenge and see how long it would take to write Tetris in Python from scratch. Turns out it's just under 3 hours. I took a wrong turn but still, I'm quite pleased with that. My version of Tetris is apparently closer to the original version in terms of it's rules. You can't 'wall kick' and the gravity is naive. If you haven't read up on Tetris, you really should check out the Wikipedia Tetris Article because it's really quite interesting!

Danielle George Looking Excited

Tom looks after a Windows network professionally, and so it seemed right and proper that he talk to the Shell Building's network team to see if we could get a VLAN for linking each bridge on each floor. However, they treated us rather poorly I'm afraid to say. In the end, it fell to me to create a temporary network using a set of TP-Link WR702n routers, one for each floor. I had 4 from a previous gig and decided to obtain another 10 by begging, borrowing and buying (thanks a lot Brendan and Artag!). These little guys are great as you can flash them with OpenWRT and run some quite interesting software on them. By default, OpenWRT comes along with WDS Bridging. This seemed to me to be the best option. I know, there are network friends reading this balking at the idea, but trust me, we were lucky to get this, let alone anything else!

Setting up each router with WDS does have some problems generally, but because we were using the same version of OpenWRT on the same hardware the connection between each router was surprisingly quick. The network traffic for playing a game of Tetris is quite small. We'd decided on using UDP instead of TCP, sending packets as fast as we can. If any packets are dropped, the chances are the state of the game should make it to the lamps in a timely manner. The signal between floors dropped considerably but was good enough to see one floor above and one below. With my temporary network in place, we were ready to play.



Other games of Tetris have been played on buildings before, using the actual lights of the offices or DMX lights. This example in Philadelphia is quite impressive! One thing to note are the lights in the windows look like small points. We wanted to illuminate the entire window and not just have a small spot. The lights we were using were somewhat low on the Lumen count so we needed to improve things. After some experimentation, we decided to use tracing paper on the windows with a mylar sheet behind the actual lamp in order to reflect some of the light back onto the diffusing surface. The results were quite good, considering the strength of the bulbs.

Tetris on the Shell Building

Creating 182 rolls of mylar and tracing paper took quite a long time! Thankfully, we had a place to store all the rolls at the Shell Building, which made setup on the day somewhat easier. Annoyingly, we only had one day - a Sunday - to do a full test before filming would commence on the following Thursday. Not exactly a long time. In addition, depending on which way you look at it, Shell were either quite forthcoming or quite annoying. Their insistence on rather annoying health and safety routines, their inaction regarding their network and the number of hoops we had to jump through caused some major problems. On the other hand, this is a large company with huge anti-ram-raid bollards in-front of their lobby. If anything, I'm surprised they let us in at all!

Our test on Sunday actually went quite well in one unexpected area. Despite the drop in signal between floors, my network could be seen from around 200 metres away out in the gardens! Quite an unexpected turn of events for sure! This meant playing the game from outside on my laptop was quite easy to sort out. Previously, I thought we'd need an Internet connection, cantenna or some 5Ghz kit to get everything together but fortunately, this was not needed in the end.

Some of the lights refused to work properly on both our test run and the live filming. Though Tom had managed to hack the lights to change at a fast rate, the signals were not quite robust enough between the bridges and the bulbs. In the end, we had to turn off 4 columns of lights, two on both sides of the board. The lights refused to change at their fastest speed, so they fell back to mesh networking which slowed the frame-rate down to 1 Fps. Still, just about playable in the end.

Tetris on the Shell Building

One complicating factor was the requirement that the game be played from the Royal Institution itself. Sadly, this proved a step too far; one that ultimately doomed playing the game from the park. In order for this to work, I granted a laptop at the Royal Institution access to my OpenVPN network - a tried and true setup I've used before. The only problem here was the connection at the site. Both Shell and the TV Production company were not forthcoming in allowing us Internet access. Tom and I tried to use 3G dongles for the connection. Given the amount of traffic and the 1 Fps limit, even an edge connection would have sufficed. Sadly, given the height of the Shell building and the proliferation of WiFi signals, the dongles proved unreliable. I suspect they were constantly hopping between the best cell towers, jostling for slots. Had I insisted we use 4G gear this may not have been a problem.

Fortunately, Jubilee Gardens is awash with public WiFi. I managed to secure access to one, but by this point there was very little battery left on my laptop (despite charging it completely!). All of the production crew were using large batteries and there was no provision made for a generator or any kind of external power. In the end, we decided we'd get Tom to play the game from the inside of the building and film it from the outside. We'd talk to him via radio, letting him know which buttons to press. However, for 5 glorious minutes, I was playing Tetris, using a building instead of my laptop screen!

People tend to focus on the technical side when doing these write-ups but it occurs to me that the technical implementations are not the real heart of the matter; between the two of us, Tom and I had all the ideas and backup plans all set and with some more time and access, we'd have set up a whole series of games and animations (we had scrolling text, explosions, everything!). The difficult and unpredictable side is much more to do with people, nature and unknowns!

We had a large army of volunteers who turned up on the filming day to help us put up the blinds. It would have been nice for them to have seen the final result but sadly, due to the way TV is, everything is secondary to what the finished product looks like. Some of the volunteers felt justifiably mistreated but others had an appalling attitude. Some of the Shell personnel were generally unhelpful, as were some of the production team. The real skill in these situations is being able to keep your cool and work around such problems as best as you can. This is something I've had to learn along the way and it isn't easy. We couldn't have done it without the help of all the RI Staff & members of the public who volunteered to help roll up mylar and tape up lots of paper sheets.

Some of the people on our team were superstars and able to manage the problems we faced with amazing generosity and skill! I'd made sure we had brought a set of radios for the main teams to talk to each other without having to rely on mobiles (which makes a huge difference). A lovely chap by the name of Cepmender loaned them to me. I was fortunate enough to be teamed with two lovely electricians who just go on with their jobs and managed to get my network up in very short time. Finally the lovely FearAndSequins proved that scotch eggs and a clear management style can solve many problems. Indeed it was down to her and the two amazing cameramen that we managed to grab the best footage. Between them, they may have just saved Christmas.

It would have been great to have more time to test everything at least 3 times over. One of the most annoying setbacks was the need for a couple of electricians to plug-in the lamps for us! Unbelievable really! The safest plugs in the world and we had to stand back and watch each floor being laboriously plugged in, one lamp at a time. Though I can understand the need to be safe, this restriction, along with the lack of a decent network were the two main problems. Shell clearly wanted to show their control over the situation and this is natural, though unnecessary and grossly inefficient.

You can't predict everything and one should never assume anything with these large setups. Despite being armed with that mantra there were still bits we couldn't account for. At one stage, my WiFi connection totally dropped. I had no idea way until it was pointed out that the rain soaked umbrella being used to protect my laptop might have been a problem! TV tends to work on a real shoestring and tends be somewhat hyperactive and corner cutting so long as it looks good on telly. Charles Yarnold has quite a lot to say on this matter; his talk with Tom Scott about geeks in telly sums it up much better than I ever could.

The look on Professor Danielle George's face, as she introduces the building, says it all really! Even she can't believe her eyes at a working game of Tetris! Despite the time restrictions, annoying light bulbs, and hundreds of other setbacks, we managed to make the first Tetris game on the side of a building in the UK, in record time! No mean feat at all. The lecture is being shown on the 29th of December, 2014, 8pm on BBC 4! You can see the source-code for Tetris over at Github and if you want to know more, just drop me an email or natter on irc (oni on freenode). Watch the clip on the BBC 4 Homepage too!