Rosie the Red Robot

By Rob Zwetsloot. Posted

The clock is ticking as the contestants concentrate hard on finding the longest word possible from nine randomly selected letters. Yes, it’s Countdown, the classic TV game show loved by students, senior citizens… and robots. Playing along at home is Rosie, her Camera Module eye focused on the screen. Within seconds she blurts out, “I have a six-letter answer: murder.”

Rosie first came to life when Alan Peaty was challenged by his daughter to build a robot. Despite his engineering experience, Alan didn’t find it easy. “It didn’t take long before I was completely out of my comfort zone,” he tells us. “Possibly the most challenging aspect of trying to build a robot is that there are so many different areas of technology involved, from hardware to software, mechanics to electronics. For example, just to get Rosie’s neck to move, we had to write some code in Python, learn about Serial Peripheral Interface bus (SPI), and get familiar with servo motors and the physics of torque, even before thinking about connecting the whole thing together. Be prepared to Google absolutely everything and anything.”

As documented in detail on the rosietheredrobot.com blog, Alan has spent several months building Rosie and gradually adding extra hardware and abilities, while learning a lot along the way. At first Rosie was a simple wheeled robot, but she is now equipped with a headlight, LED matrix expressive ‘eyes’, motion sensor, GPS receiver, ultrasonic distance sensors, and a Camera Module.

 Please don't sit as close as Rosie does to your TV

Playing the game

It’s this last addition that enables Rosie to see the Countdown letters on the TV screen. Optical character recognition is then carried out using Google Cloud Vision API, to read the letters. “She performs relatively well at different distances on one condition – only the individual letters from the letters round is showing on-screen when the photo is captured,” reveals Alan. “When the contestants’ names, or even the channel name, appear in the same picture, it starts to muddle Rosie’s brain.”

A Python application runs the identified letters through an algorithm that matches possible results from a dictionary containing 10 000 words – a dataset from magpi.cc/2mgxuv4 that Alan has arranged alphabetically. Python’s gTTS text-to-speech module is then used to get Rosie to say the longest word she’s found, along with the numbers of letters in it, via an on-board speaker.

Naturally, replacing the dictionary with a larger one would improve Rosie’s performance, but she’s still a decent player. “It perhaps goes to show that machines are so much better than us humans at processing large volumes of data rapidly, when the requirements of the task are crystal clear,” says Alan. “The letters round doesn’t really require any tactics or strategy, or even any complex decision-making. You simply need to remember every single word in the English dictionary and have the ability to filter and search through them in under 30 seconds.”

As for getting Rosie to play the Countdown numbers game, “We’ve had a quick look at this,” says Alan, “but it turns out to be a little more complicated than just trawling through a list of words and letters. The algorithm is likely to need to work out every single mathematical operation possible not only between the chosen numbers, but between the results of subsequent operations. She would need to add this to her repertoire, however, if she was ever to appear on the actual TV show…”

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.