More than 20 people with no prior Akka experience, 10 minutes preparation talk, one idea: getting everyone to write Actors participating in a realtime competition to beat others in the game of Prisoner’s Dilemma.
Yes, it is.
Did we manage to do it?
Yes, we did!
Before I explain what we did during the workshop, big thanks to the Scala Vienna User Group organizers and participants (special thanks to Rafael and Manuel for helping out), and to Stockwerk for hosting us! Also, Heiko Seeberger, Director of Education at Typesafe, came all the way from Munich – thanks for joining the workshop!
The workshop was split into 3 steps: First, I quickly introduced the concept of Actors and provided some code examples. And then the first challenge: develop your first actors in preparation for the game of Prisoner’s Dilemma. Once everyone was able to code basic Actor communication with Akka, we could move on to the final part: get everyone connected.
Real time tournament of Prisoner’s Dilemma
Using actor communication, all participants connected their Prisoner actors to the Tournament hosting actor, participating in a real-time round robin tournament. The tournament system continuously picked actors from the pool to play a game of Prisoner’s Dilemma against each other. Each actor represents a Prisoner in the game, and has to decide whether or not to cooperate with the other actor. Making the right decisions gives you points in the game, and we displayed the results live on a highscore.
Prisoner’s Dilemma explained
The game of Prisoner’s dilemma is actually pretty simple. Both prisoners have to make a decision. Each of them knows the name of the other prisoner, and has to decide: do you cooperate or defect? If both cooperate, they get some points. If both defect, they don’t gain anything. But if one cooperates, and the other one defects, the cooperator looses points and the defector gets it all, exploiting the other prisoner.
An Evil Twin strategy
If you are a prisoner in the Prisoner’s Dilemma, you better remember who the bad guys are, otherwise you’re not going to make a lot of points in the game.
After running the tournament for a while, one participant using an “Evil Twin” strategy scored most of the points. Peters strategy was straightforward: Be nice for a while, but then switch strategy and try to exploit everyone for a while, before turning back to being nice again. It’s quite challenging to implement a strategy like this in just a few minutes time. So, congratulations Peter! You can see his Evil Twin code here on GitHub.
Connected Actors for the win – what’s next?
Now one question remains: what’s next? If you have some ideas, some games perhaps, or other things that could be implemented with live-feedback during a workshop, please let me know! Comments and suggestions are always welcome.
Update [27.11.2013]: Check out our learnings from using Akka in a coding workshop
 Code of the Play framework application that hosted the tournament during the workshop (Akka+Play+Websockets)
 Meetup page of this workshop
 “Evil Twin” solution by Peter