<< Back

Generating Tic Tac Toe Data – The Alteryx Way

At The Information Lab we believe that anyone should be able to work with data and gain understanding from it. How do we do that? By using and reselling easy to use tools like Tableau and Alteryx which need no coding and no specialist expertise.

So we love it when people like Joshua Milligan publish amazing Tableau workbooks like this pushing Tableau to it’s limits and showing the tool is capable of almost anything in the right hands. All Joshua needed in Tableau was a little bit of creativity in the way he used Tableau Actions (I’m clearly understating the effort here!) and he was able to produce a masterpiece that had our jaws on the floor.

However, Joshua’s next post on how he created the data behind that visualisation left me a little deflated, he used some C# code to create the dataset:

 …I’d need to have data at the level of a space on the board. There are nine spaces. But I’d also need to have every possible move so that clicking on a square could send an action filter specific to a given board. So I’d need every possible board. This is more than just the possible outcomes of the game – in fact, even more important, I’d need every possible board of every possible game at every possible state: Win, Draw or In Progress.

I’ve never seen such a data set. So, I set out to create one. I wrote an application in C# to generate the data as flat files. I subsequently imported the data into SQL Server so I could manipulate it as needed. I won’t go into the code (you can download it here)

…and with that suddenly Joshua’s solution was no longer accessible to us mere mortals. I can’t code C#, perhaps I could learn, but looking through his code I was crestfallen that I might not be able to see what he’d done and begin to replicate it myself. This is not a slight at Joshua’s solution, his approach used his skillset and is clearly right for him, but Joshua is a guy with a programming background and his approach might not suit every Tableau user without programming skills.

So with this in mind I decided to set out and try and replicate Joshua’s solution without coding, and so I turned to Alteryx. Alteryx is my first choice when it comes to data manipulation and I felt sure it would be up to the task. 15 minutes later, and with no code in sight except a few simple formula, I had my solution which I have shown below. Click on the image to open a larger version.

I personally think this visual solution has many advantages over the coded version, namely you can see exactly what the process is doing, and how I’ve approached the problem. I’ve also added my own annotation too. The other advantage is that I could manipulate the data in flow and generate a Tableau Data Extract right out of the module to use directly in Tableau – it takes only seconds to run.

The astute may notice my answer differs from Joshua’s answer in that I have fewer board combinations, perhaps I misunderstood part of Joshua’s data needs for his viz, however I am confident I have generated every board combination possible which was my original purpose.

I have shared my solution, and a tableau workbook showing all the boards I generated, and the winner of each board (if any), here. Feel free to explore and comment on my solution in the yxmd module, if you need a copy of Alteryx then remember the trial version is available and can be used unrestricted for 14 days.

Finally I once again want to congratulate Joshua again on a truly fantastic Viz, to see someone got to the effort of producing such an amazing piece of fun reminds me why I work with Tableau and why I love the Tableau community.

Just to repeat you can download my Alteryx solution here. Thanks for reading.

Chris Love

Nottingham, UK

3 thoughts on “Generating Tic Tac Toe Data – The Alteryx Way

  1. Nice work!

    I wonder if board combinations and possible moves are different beasts – and this might explain the significant difference observed in comparison to JM’s work?

    If board combinations are snapshots of possible game states, then one single game state can have multiple unique preceding/subsequent moves.

    This would explain the difference between your 19,683 possible board combinations and the 4,949,514 possible moves required for JM’s heuristics and Viz.

    1. Yes RG you’re absolutely right, I spoke to JM and we went through what he needed, it seems he needed the combinations for the next two moves after that one as well, so it quickly blew up the number of combinations. I didn’t attempt that in Alteryx as the point was to show the method rather than the result.

Leave a Reply

Your email address will not be published. Required fields are marked *