How we built a bot to manage our studio pool games

Potato
Potato
Aug 24, 2018 · 4 min read
Image for post
Image for post

This is what inspired us to get creative with our pool tables in the London and Bristol studios. In the beginning, the team mostly used games of pool to facilitate impromptu chats about complex bugs and other tech headaches.

Over time, a colleague and myself started recording pool victories against one another in a grid on an unofficially-reserved whiteboard in the studio.

Image for post
Image for post

Before long, that faint whiff of competition evolved into a thick stench, and it became clear we needed something else. The whiteboard, limited by its 2D existence, wouldn’t scale to our needs.

Victories and defeats against others still had to be mostly manually recorded. We like building solutions to “problems” like this, so that was how Poolbot was created.

Poolbot

Poolbot is now our resident cue-sports statistician manifested as a Slack bot. Channeling the likes of Hazel Irvine and Steve Davis, it knows all about what goes on on the baize.

Image for post
Image for post

The architecture of Poolbot is a simple client server setup, and uses a tech stack common to many Potato projects. The Slack bot client is written in pure Python and consumes messages returned by the Slack real time message API.

The server is hosted on Google App Engine and runs off a Djangae app. Data is stored in the Datastore, and consequently we denormalise a lot of things across the various models to improve performance and reduce latency.

We use trusty DRF to expose various RESTful API endpoints, to which the client (and other integrations including the NFC reader) can send HTTP requests.

Image for post
Image for post

To record a victory, you can just roll into Slack, type and watch the ELO points trickle in. Yes, we've implemented the ELO rating algorithm to keep some leaderboards – a global one and a seasonal one (we have a new season every 10 weeks) - the top positions of which are coveted by all.

That’s not all Poolbot knows. It comes with a small set of other commands:

  • : see how that user has performed recently
  • : see how your ELO ratings would be affected by playing the other person
  • : see your recent form against the other person
  • : see that user's lifetime & season stats
  • : see that user's current killing spree (number of games won without a loss)
Image for post
Image for post

Poolbot’s career progression roadmap has been outlined too, with it expected to grow into such roles and responsibilities as:

  • 9-ball mode
  • Allowing users to mount challenges against another player
  • Betting extra ELO points on a game
  • Doubles matches
  • Recording game results via a mobile app and NFC
  • Plotting performance over time
  • Recording extra stats per game
  • Eventually sentience and refereeing capabilities (erm, probably)

Here are some of our up-to-date stats:

  • Number of players on leaderboard: 78 (this is almost everyone in London and Bristol)
  • Number of games recorded: 4,248 (this includes many games out of office hours…)
  • First victory recorded on: 7 April 2016
  • All-time ELO high: 1,384
  • Current season ELO high: 1,157
Image for post
Image for post

One of the great things about Poolbot is that it has brought both studios together over a shared passion. Developing it also gave us an unexpected opportunity to explore text as UI, which helps to keep our skills sharp in our everyday work.

If you like the sound of Poolbot, you can use it too. All you need is a Slack team, somewhere to host the client (which can use WebSockets), and a Google App Engine account for the server. Let the games begin!

Originally published at p.ota.to on 31st January 2017

@potato

Award-winning digital product development studio in London and San Francisco

Potato

Written by

Potato

Made better. Potato exists to develop purposeful and effective digital products. Find us in London, Bristol and San Francisco.

@potato

@potato

Award-winning digital product development studio and talent academy in London and San Francisco.

Potato

Written by

Potato

Made better. Potato exists to develop purposeful and effective digital products. Find us in London, Bristol and San Francisco.

@potato

@potato

Award-winning digital product development studio and talent academy in London and San Francisco.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store