Applying Game Theory to your App
Tags: flatiron, gametheory, webdev
Published: 2019-03-11 15:59:05

---
title: Applying Game Theory to your App
published: true
description: An introduction to game theory as it applies to software development 
tags: flatiron, game theory, web dev
---

Game theory is all about creating rules, incentives and payoffs for your users. Players need to know what the goal of the overall game is, and the actions they can take to further themselves toward that goal. Technically speaking, Game theory is a branch of applied mathematics that sort of merges mathematics and behavioral economics in order to analyze and develop strategies for competitive situations and systems that takes player’s choice into account. A player in the context of game theory can be any active participant in a system be it a single user, a group of people or even a country. As developers, we can take advantage of this school of thought to enrich our applications to include more engaging user interactivity. 

Game theory was originally developed by the mathematician John von Neumann and Oskar Morgenstern, a Princeton economist, to solve problems found in economics. In their book “The Theory of Games and Economic Behavior”, published in 1944 Neumann and Morgenstern asserted that the contemporary mathematics developed for the physical sciences,, was a poor model for economics. They observed that economics is much like a game, wherein players anticipate each other’s moves, and therefore requires a new kind of mathematics, which they called game theory. It is important to note that there is no single overall “capital G” Game theory due to the large breadth of situations and systems that fall into its umbrella. While game theory is used to identify systems already in place, we can use it to implement systems of our own design. 

The features of a game system that I am going to focus on are:

-Players
-Rules
-Skill and Luck
-Incentive
-Payoff

<strong>Players</strong>

As I stated before, players are any participants in the game system, but the number of players can be important especially if the action of a player influences the behavior of another. For example, this can be seen in social media with hashtags that get popular or trends, content creators see what is getting shared around and change their content to reflect what their audience wants to see.

<strong>Rules</strong>
I’ll be talking game theory in relation to an overall goal as it relates to a software application, for a game that goal would be player enjoyment. However, for a social media app, a game system could be applied to how your user’s content gets shared around. In software, the possibilities for what players can do and the actions they take seem endless… and that’s because as developers, we know that we can do pretty much anything we want. So setting up loose rules at the beginning of the design process is important, things like number of players, the incentives and goal of the game itself. The key word here is “loose” because we don’t want to get into the mindset that everything is locked down, set in stone and unchanging. The reason is that during the process of implementing your system, it’s nearly inevitable that things will need to be altered or changed in service to the overall goal.

<strong>Skill and Luck</strong>

![](https://i2.wp.com/avoiderdragon.com/wp-content/uploads/2015/02/chart_skill-luck.jpg)

This is one of my favorite sections of implementing a system because this is where the interactivity gets tweaked in something like a video game. This concept does have its place outside of recreational games. Consider Vine: a platform spawned from Twitter where you tried to make a 7 second clip go viral. It has a clearly defined goal but in order to make your video go viral it took talent (editing, writing and timing) and also luck (posting at a time of day so that most eyes would see it). Increasing the difficulty of performing an action or affecting another player can result in players feeling engaged but also frustrated. This frustration can be a very powerful emotion that turns people off from using your service, so you can use luck as a yin to skills yang. By providing luck you are giving a player the ability to soften the blow to their ego by providing an excuse why they lost a zero-sum game or why their Vine didn’t end up on national news (shouldn’t have posted it at midnight). 

<strong>Incentive and Payoff</strong>

Incentive and payoff answer the "Why should I?" questions your users may ask. To incentivize is to entice the player into performing an action, be it liking a post, commenting or something as simple as making the player keep playing the game. Payoff is the feedback for those actions, this can be positive or negative. Payoff determines whether or not a player will perform the action again.


<strong>Zero Sum and Non Zero Sum Games</strong>

![](http://www.salemmarafi.com/wp-content/uploads/2011/10/prisoners_dilemma.jpg)

The above diagram is a demonstration of the Prisoner’s dilemma in which each individual prisoner benefits if they rat the other prisoner out. This benefit is only reaped though if the opposing prisoner stays silent. However it is overall more beneficial if the prisoner’s work together, stay silent and take the much lower sentence. This is an example of a non-zero game, because the outcome, of either twenty years, five years, or one, is always greater (or less) than zero.

Zero sum games have a fixed, limited set of resources and therefore in order to win you must take away resources from your opponent resulting in a net loss for them. An example of a zero sum game would be Poker. Adding the net losses and winnings together will yield the result 0, hence the name. 

<strong>Perfect and Imperfection Information Games</strong>

Games of perfect information are games in which players know all of the rules, and any actions that can be played and the history of all those actions (even if they can’t remember). These are traditional board games like chess and checkers. These are also games that can be cracked by computers to determine the best overall decision by looking at probability of the opponent’s actions and the consequences of their own. Imperfect information games are the opposite, some information is kept secret from the players. Most games you’d play today fall into this category. Algorithms can take in variable values, do some magic and spit out a result that the player may have not intended. 

Games can be made of nearly anything regardless of the intention of the original design of a program. Recently, I happened upon a Twitter thread of a speed runner who has been attempting to try and [crash Windows 95](https://twitter.com/Foone/status/1103384684812255233) as fast as possible. This is another reason why it's important to consider the motivations your users may be harboring and actions you provide them. 

Now that you know the individual parts of a game you can now analyze current systems in place and apply these concepts to your own development. Add an incentive and pay off for the user to interact with other players or your app itself. Make it rewarding to use your site every day, and if you find that when your testing, your program feels sterile,  maybe take a look at what interactivity you can add.