Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
Labels (1)
avatar

Yesterday evening, in a moment of inspiration, I wondered if one could build a game in NiFi (a tool for moving data in realtime). Of course, building a game is quite unnecessary, but it is far from pointless as it can really show how flexible a tool can be with a bit of creativity. A few years ago I played ‘Worlds first game of chess… against PySpark’ but given that NiFi is meant for simpler logic, I decided to start with something different.

Screen Shot 2020-06-29 at 9.18.33 PM.png

Building Tic Tac Toe in NiFi

My goals were to build something that allowed people across the globe to play in realtime, by using a board (no code). Fortunately, the Graphical User Interface of NiFi was made with realtime interaction of multiple users in mind, so I had a good foundation for this. Furthermore, I wanted NiFi to determine the winner automatically. For this, I leveraged its capabilities in applying logic/business rules. Of course, NiFi wants to apply the logic to something, so to ensure that the winner would be determined in a timely manner, I introduced a heartbeat that checks 10x per second whether someone made the winning move.

Let's get startedLet's get started

How did it go?

I was hoping I could say it only took 30 minutes, but admittedly I had to think a bit about how to make the evaluation work and represent things in a visually appealing way. So, ultimately it took me about 2 hours, which is still not bad for creating an interactive multiplayer game in a tool that is actually meant for moving data. I am quite happy with how easy it turns out to play the game. However, please note that I only built the logic for multiplayer Tic Tac Toe. NiFi actually has enough capabilities, so it would not be hard to make it decide its own moves at various levels of playing strength for a simple game like Tic Tac Toe. 

Make your moveMake your move                  Automatically evaluate the winnerAutomatically evaluate the winner

 

What will come next?!

First of all, I will think about more cool stuff to do with tools for moving data, perhaps with NiFi or more complex engines like Flink. I hope I have shown that NiFi is indeed very flexible and enables the great speed of development. 

Secondly, I invite you to think of something to do with NiFi or another open-source tooling. Good luck and do share the results!

Well played!Well played!

 

----

NiFi Template (right-click to save): Tic_Tac_Toe.xml

2,354 Views
Comments
avatar
Super Guru

Too cool man,  great work!

Version history
Last update:
‎06-29-2020 11:48 PM
Updated by: