Data Science

Food selection with Game Theory

Using Game Theory to resolve the restaurant selection conflict between two friends.

Prashant Mudgal
January 27, 20214 min read

Food Selection with Game Theory

Although 2020 didn't give us many opportunities to go out and eat like the old times, whenever we did, we spent a long time deciding where to eat! It was a proverbial million-dollar question. These two friends of mine are quite picky (a little less than me though but my goal is to make them look bad :D) and I haven't dined with them much in the past 8 years but in my experience, we have to take an extra half an hour for our deliberations aka food wars.

Photo by Rachel Park on Unsplash
Photo by Rachel Park on Unsplash

I decided to put an end to this by understanding the underlying patterns and finding a way to reach a quick compromise.

Hypothesis: Given the food preferences of my friends on a given day, can we quickly find what cuisine to select that maximises the satisfaction?

A little bit of background about Game Theory

I won't go on a rant about the theory here and will try to be as brief and succinct as possible.

Game theory is the study of mathematical models that describe the interaction (food selection) among rational decision-makers (my two friends). Fair enough!

The outcome of the Game - One method of predicting the game's outcome is by identifying dominant strategies for each player. A dominant strategy is the one that is the best for a given player regardless of the choice of the other player (whatever cuisine satisfies the current cravings of my friends) - so regardless of what friend #2 does, a dominant strategy for friend #1 is the optimal strategy for friend #1.

The set of dominant strategies (cuisines) chosen by the players (friends) is called the Nash Equilibrium. It is called an equilibrium because neither of the players has anything extra to gain by changing his/her choice.

In simple words, the Nash equilibrium is a law that no one wants to break even in the absence of the police. There is no advantage for individuals to break the law, they won't gain anything extra. People observing traffic signals and stopping/going according to the colour of the light is one such phenomenon.

Ok, enough theory, let's get to the application.

You can follow the code present in GitHub here.

I am not going to use Nashpy but basic python functionalities to see whether a result can be achieved.

Let's create our Payoff matrix. In this case, it will be the ratings given by the two friends for various cuisines they want to eat.

Pay off matrix for various cuisines as measured last Friday
Pay off matrix for various cuisines as measured last Friday

The task is to find the dominant strategy given this payoff matrix and end the food wars.

Let's plot the payoff matrix on a scatter plot:

Image by Author
Image by Author

The curve above describes the satisfaction one would get on eating various cuisines. The coordinates that belong to the topmost part of the curve belong to the highest payoffs for both the friends. If 'x' denotes payoffs for Varun and 'y' for Kirti, then we have to maximise 'xy'.

To do so, we need to find the equation of the line that passes through points (1, 4) and (3, 2). The slope of the line is given by:

The slope comes out to be -1.

The equation of the line can be easily found by:

The equation is y = -x + 5

xy = x(-x + 5) = -x² + 5x

Taking the first derivative of xy with respect to x:

Thus, at x = 5/2, xy is maximised(equate the above derivative, -2x + 5 to 0). The value of y at x = 5/2 comes to be 5/2 as well.

The green dot on the line above is the point of compromise. It lies on the line with coordinates for Chinese and Italian payoffs and closer to Italian food.

But what does it really mean? Should we be eating a hybrid of Chinese and Italian? Noodles on a pizza sound quite weird but I have had really weird pizzas (how about eggplant, goat cheese, and potato? Yes, I had it as that was the only vegetarian option for me).

Interpretation

The solution above is mixed, so we either find a restaurant that serves both Chinese and Italian or if we want to save ourselves from the onslaught of Chinese-Italian hybrid food, let's find the probabilities to get a pure solution.

For both of them, the dominant point is 5/2.

For Kirti, 5/2 = p(2) + (1-p)(4)

Solving this we get p = 3/4

We get the same solution if we solve for Varun.

Conclusion

p = 3/4 means for every 4 times we have such preferences for Chinese and Italian food, we will go to Italian place 3 times and to Chinese once.

Finally, I believe we have a solution to this conflict between them. :) All I have to do is keep my laptop with me or create a small app that can run this program.

BTW... It's past midnight after I have finished running this analysis and no food delivery services are running at the moment. So, no Chinese or Italian for me tonight.

Ramen noodles again! BTW...for those who don't know ramen are Japanese and are deemed greatest Japanese invention of the past century.

Related Articles