<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Game Theory - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Game Theory - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 26 May 2026 04:44:26 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/game-theory/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Introduction to Evolutionary Game Theory ]]>
                </title>
                <description>
                    <![CDATA[ By Peter Gleeson For the longest time, the evolution of cooperative social behaviour has fascinated evolutionary biologists. The mathematical field of game theory helps shed light on how it emerges. Game theory is “the study of mathematical models of... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/introduction-to-evolutionary-game-theory/</link>
                <guid isPermaLink="false">66d460a8677cb8c6c15f3171</guid>
                
                    <category>
                        <![CDATA[ evolution ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Game Theory ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Math ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Science  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 13 Apr 2021 17:12:33 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/605de4899618b008528a7b69.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Peter Gleeson</p>
<p>For the longest time, the evolution of cooperative social behaviour has fascinated evolutionary biologists.</p>
<p>The mathematical field of game theory helps shed light on how it emerges. Game theory is “the study of mathematical models of strategic interaction among rational decision-makers” (according to <a target="_blank" href="https://en.wikipedia.org/wiki/Game_theory">Wikipedia</a>).</p>
<p>Game theory applies to “games” as varied as economics, politics, chess and tic-tac-toe. In each case, there are some rules, some “players” or “agents”, and a set of strategies available to them.</p>
<p>Each player has a concept of “utility” – a “currency” they seek to individually maximise through the strategies they play.</p>
<p>The currency of evolution is the concept of <a target="_blank" href="https://www.nature.com/scitable/blog/accumulating-glitches/the_meaning_of_fitness/">fitness</a>.</p>
<p>That is, the chance of being represented in the next generation. Genes and traits which increase the odds of survival to reproductive age are more likely to be passed on to future generations. Therefore, they confer a greater fitness to the individual which "hosts” them.</p>
<p>Evolutionary game theory takes the concepts from game theory and applies them in an evolutionary context.</p>
<p>For a given model, it lets you ask questions about which strategy prevails, and whether certain strategies can coexist. And if so – at what frequencies?</p>
<h2 id="heading-replicator-dynamics">Replicator dynamics</h2>
<p>Evolutionary game theory plays “games” over many generations.</p>
<p>Each game will alter the utility (that is, fitness) of the players. The next generation is produced, with players being represented proportionally to their overall fitness.</p>
<p>This set up is called “replicator dynamics”. It is easy to simulate and explore different models of evolutionary games.</p>
<p>The classic model of evolutionary game theory is the “Hawk-Dove” game, popularised by John Maynard Smith in the 1970s.</p>
<p>In this game, there exists a population of animals which compete for a finite resource (for example, food). The more resources an individual wins, the greater its fitness.</p>
<p>Each animal can play one of two strategies:</p>
<ul>
<li><strong>Hawks</strong> are aggressive, and will fight for a resource at all costs.</li>
<li><strong>Doves</strong> are passive, and will share instead of fight for a resource.</li>
</ul>
<p>The animals are all the same kind – “hawk” and “dove” refer to their behaviour.</p>
<p>There are three pairwise competitions that can exist:</p>
<p><strong>Hawk vs Hawk</strong></p>
<ul>
<li>If two hawks compete, they will engage in a 50:50 battle to win the resource. This is a winner-takes-all scenario – the winner obtains the full value of the resource. The injured loser pays a price, and loses a certain amount of fitness.</li>
</ul>
<p><strong>Hawk vs Dove</strong></p>
<ul>
<li>If a hawk meets a dove, the dove will back down immediately. The hawk wins the full value of the resource, and the dove walks (or, rather flies) away with nothing. But they do not pay any cost.</li>
</ul>
<p><strong>Dove vs Dove</strong></p>
<ul>
<li>When two doves meet, they agree to share the resource evenly. No one gets hurt.</li>
</ul>
<p>This can be modelled mathematically. Doing so allows us to understand whether these strategies can coexist (or if one of them prevails).</p>
<h3 id="heading-the-math-of-replicator-dynamics">The math of replicator dynamics</h3>
<p>Let <em>V</em> be the value of winning a contest, and <em>C</em> be the cost of injury in a contest.</p>
<p>Represent the frequency of hawks in the population as <em>p</em>, and the frequency of doves as <em>1-p</em>.</p>
<p>Now, define two functions F(H) and F(D) which define the expected fitness of playing the hawk and dove strategies, respectively.</p>
<p>Playing as a hawk will mean engaging in a hawk-vs-hawk contest with frequency <em>p.</em> The expected utility of doing so is understood as the average outcome. Half the time the hawk wins <em>V</em>, half the time it loses <em>C</em>.</p>
<p>The rest of a hawk’s contests will be against doves. This guarantees an easy win <em>V.</em></p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F8b5ac2e8-fdfb-4ffc-8abe-15d0d014f580_544x112.png" alt="Image" width="544" height="112" loading="lazy"></p>
<p>Playing as a dove will win nothing against hawks. But a dove will encounter another dove with frequency <em>1-p</em>. Under this scenario, the expected utility is the shared resource, worth <em>V/2</em>.</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6303e0b2-d6ab-434d-b7ec-cad18a82d154_508x110.png" alt="Image" width="508" height="110" loading="lazy"></p>
<p>Now, set <em>F(H)</em> equal to <em>F(D)</em> and solve for <em>p</em>.</p>
<p>This reveals the frequency <em>p</em> at which the hawk strategy confers no more or less fitness than the dove strategy.</p>
<p>At this frequency, there is no advantage to either strategy, so this is the equilibrium at which both strategies may coexist.</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F77be89c1-0286-4673-867f-1c8e1a038cb7_516x104.png" alt="Image" width="516" height="104" loading="lazy"></p>
<p>Some algebraic rearrangement gives:</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fca77237e-29a4-4826-af4a-2fbb390d3572_404x108.png" alt="Image" width="404" height="108" loading="lazy"></p>
<p>Which provides the ratio of hawks-to-doves that exists at equilibrium.</p>
<p>Just a little more rearranging gives the equilibrium in terms of <em>p</em>:</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fb812b56c-8387-4a47-902e-61aaa87cf317_342x98.png" alt="Image" width="342" height="98" loading="lazy"></p>
<p>Considering the properties of this expression reveals two things:</p>
<ul>
<li>Whenever the cost <em>C</em> of losing a contest is less than or equal to the value <em>V</em> of winning, the hawk strategy will dominate. Neither strategy can coexist.</li>
<li>If the cost <em>C</em> is greater than the value <em>V</em>, the strategies will coexist in equilibrium.</li>
</ul>
<p>Plugging in the values <em>V</em>=4 and <em>C</em>=6 shows the equilibrium occurs when 2/3 of the population play the hawk strategy.</p>
<p>You can test this by simulating the model in Python.</p>
<h3 id="heading-the-code">The code</h3>
<p>In the file called bird.py:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> random

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Bird</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, strategy</span>):</span>
        <span class="hljs-string">"""
        Each bird has a strategy type (hawk or dove)
        And a small starting fitness
        """</span>
        self.strategy = strategy
        self.fitness = <span class="hljs-number">10</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">contest</span>(<span class="hljs-params">self, opponent, v, c</span>):</span>
       <span class="hljs-string">"""
       Simulate the outcomes depending on the strategies
       """</span>

        <span class="hljs-comment"># both hawks --&gt; 50:50 battle</span>

        <span class="hljs-keyword">if</span> self.strategy == opponent.strategy == <span class="hljs-string">"hawk"</span>:
            <span class="hljs-keyword">if</span> random.randint(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>) == <span class="hljs-number">1</span>:
                self.fitness = self.fitness + v
                opponent.fitness = opponent.fitness - c
            <span class="hljs-keyword">else</span>:
                self.fitness = self.fitness - c
                opponent.fitness = opponent.fitness + v

        <span class="hljs-comment"># hawk meets dove</span>

        <span class="hljs-keyword">elif</span> self.strategy == <span class="hljs-string">"hawk"</span> != opponent.strategy:
            self.fitness = self.fitness + v
            opponent.fitness = opponent.fitness
        <span class="hljs-keyword">elif</span> self.strategy == <span class="hljs-string">"dove"</span> != opponent.strategy:
            self.fitness = self.fitness
            opponent.fitness = opponent.fitness + v

        <span class="hljs-comment"># both doves --&gt; share the resource</span>

        <span class="hljs-keyword">else</span>:
            self.fitness = self.fitness + v/<span class="hljs-number">2</span>
            opponent.fitness = opponent.fitness + v/<span class="hljs-number">2</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">spawn</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-string">"""
        Allow a small chance of mutation to flip strategy
        Otherwise, return offspring of the same type
        """</span>

        mutation = random.randint(<span class="hljs-number">0</span>, <span class="hljs-number">1000</span>) &gt; <span class="hljs-number">999</span>
        <span class="hljs-keyword">if</span> mutation:
            <span class="hljs-keyword">if</span> self.strategy == <span class="hljs-string">"dove"</span>:
                <span class="hljs-keyword">return</span> Bird(<span class="hljs-string">"hawk"</span>)
            <span class="hljs-keyword">else</span>:
                <span class="hljs-keyword">return</span> Bird(<span class="hljs-string">"dove"</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">return</span> Bird(self.strategy)
</code></pre>
<p>The next file is called simulation.py.</p>
<ol>
<li>Initialise a population of all doves.</li>
<li>Define a timestep function to simulate randomised contests.</li>
<li>Draw the next generation weighted by their relative fitnesses.</li>
<li>Rinse and repeat a thousand times over, then save the output as a graph.</li>
</ol>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> bird <span class="hljs-keyword">import</span> Bird
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> matplotlib


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">initialise</span>():</span>
    <span class="hljs-string">"""
    Create a population of birds - all dove to begin
    """</span>

    birds = []

    <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(<span class="hljs-number">1000</span>):
        birds.append(Bird(<span class="hljs-string">"dove"</span>))

    <span class="hljs-keyword">return</span> (birds)


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">timestep</span>(<span class="hljs-params">birds, value, cost</span>):</span>
    <span class="hljs-string">"""
    Pair up the birds, make them compete
    Then produce next generation, weighted by fitness
    """</span>

    next_generation = []

    random.shuffle(birds)

    <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(<span class="hljs-number">1000</span>):

        <span class="hljs-comment"># pair up random birds to contest</span>
        a, b = random.sample(birds, <span class="hljs-number">2</span>)
        a.contest(b, value, cost)

    <span class="hljs-comment"># generate next generation</span>
    fitnesses = [bird.fitness <span class="hljs-keyword">for</span> bird <span class="hljs-keyword">in</span> birds]

    draw = random.choices(birds, k=<span class="hljs-number">1000</span>, weights=fitnesses)
    next_generation = [bird.spawn() <span class="hljs-keyword">for</span> bird <span class="hljs-keyword">in</span> draw]

    <span class="hljs-keyword">return</span> next_generation


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>

    birds = initialise()

    rows = []

    V = <span class="hljs-number">4</span> ; C = <span class="hljs-number">6</span>

    <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(<span class="hljs-number">1000</span>):

        <span class="hljs-comment"># add the counts to a new row</span>
        strategy = [bird.strategy <span class="hljs-keyword">for</span> bird <span class="hljs-keyword">in</span> birds]
        n_hawks = strategy.count(<span class="hljs-string">"hawk"</span>)
        n_doves =  strategy.count(<span class="hljs-string">"dove"</span>)
        row = {<span class="hljs-string">'n_hawks'</span>: n_hawks, <span class="hljs-string">'n_doves'</span>: n_doves}
        rows.append(row)

        <span class="hljs-comment"># run the timestep function</span>
        birds = timestep(birds, V, C)


    <span class="hljs-comment"># create dataframe and save output</span>

    df = pd.DataFrame(rows)
    df.to_csv(<span class="hljs-string">'simulation.csv'</span>)
    fig = df.plot(y=[<span class="hljs-string">"n_hawks"</span>, <span class="hljs-string">"n_doves"</span>]).get_figure()
    fig.savefig(<span class="hljs-string">'simulation.pdf'</span>)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main()
</code></pre>
<p>And voilà - here’s an example of the output for <em>V</em>=4 and <em>C</em>=6:</p>
<p><img src="https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F44100a89-d377-435e-bf11-97b046db5f32_1438x1048.png" alt="Image" width="1438" height="1048" loading="lazy"></p>
<p>Exactly as the theory predicts.</p>
<h2 id="heading-outro">Outro</h2>
<p>The evolution of complex systems is a fascinating field of study. Understanding how natural forces and competitive pressures can shape individual-level traits to give rise to complex social behaviours has been one of the major areas of research in biological sciences in the last few decades.</p>
<p>The ability of relatively simple mathematical models to accurately predict outcomes of dynamic systems is also a key point to take away. </p>
<p>In this case, it is the existence of a feedback loop that results in the two strategies reaching an equilibrium. The advantage conferred by either strategy varies depending on how many others in the population are playing that strategy.</p>
<p>In other words, when more individuals play "dove", there is an advantage to playing "hawk". However, as more individuals play "hawk", the expected value of playing "dove" increases.</p>
<p>Finally, the availability of programming and software tools makes it possible to test theoretical predictions through simulation.</p>
<p>If you found this article interesting, you may also find <a target="_blank" href="https://www.freecodecamp.org/news/how-to-model-an-epidemic-with-r/">How to Model an Epidemic With R</a> worth checking out, too.</p>
<p>You can follow more of my writing at <a target="_blank" href="https://gleeson.substack.com/">gleeson.substack.com</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ In need of evolution: game theory and AI ]]>
                </title>
                <description>
                    <![CDATA[ By Elena Nisioti Artificial Intelligence (AI) is full of questions that cannot be answered and answers that cannot be assigned to the correct questions. In the past, it paid for its persistence to wrong practices with periods of stagnation, known as ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/game-theory-and-ai-where-it-all-started-and-where-it-should-all-stop-82f7bd53a3b4/</link>
                <guid isPermaLink="false">66c34b2ea7aea9fc97bdfb29</guid>
                
                    <category>
                        <![CDATA[ Artificial Intelligence ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Game Theory ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Reinforcement Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 12 May 2018 21:07:00 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*ddulq7MNPa7NPjVf5xCuEw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Elena Nisioti</p>
<p>Artificial Intelligence (AI) is full of questions that cannot be answered and answers that cannot be assigned to the correct questions. In the past, it paid for its persistence to wrong practices with periods of stagnation, known as AI winters. The calendar of AI, however, has just reached spring, and the applications are flourishing.</p>
<p>Yet, there is a branch of AI that has long been neglected. The talk is about reinforcement learning, that has recently exhibited impressive results on games like <a target="_blank" href="https://www.deepmind.com/research/highlighted-research/alphago">AlphaGo</a> and <a target="_blank" href="https://www.deepmind.com/publications/playing-atari-with-deep-reinforcement-learning">Atari</a>. But let’s be honest: these were not reinforcement learning wins. What got deeper in these cases was the deep neural networks, and not our understanding of reinforcement learning, which maintains the depth it achieved decades ago.</p>
<p>Even worse is the case of reinforcement learning when applied to real life problems. If training a robot to balance on a rope sounds hard, try training a team of robots to win a football game, or a team of drones to monitor a moving target.</p>
<p>Before we lose the branch, or even worse the tree, we must sharpen our understanding of these applications. Game theory is the most common approach to studying teams of players that share a common goal. It can lend us tools to guide learning algorithms in these settings.</p>
<p>But let’s see why the common approach is not a common sense approach.</p>
<blockquote>
<p>To kill an error is as good a service as, and sometimes even better than, the establishing of a new truth or fact. <em>— Charles Darwin</em></p>
</blockquote>
<p>First, let’s dirty our hands with some terminology and basics of these areas.</p>
<h3 id="heading-game-theory">Game theory</h3>
<h4 id="heading-some-useful-terms"><strong>Some useful terms</strong></h4>
<ul>
<li><strong>Game:</strong> like games in popular understanding, it can be any setting where players take actions and its outcome will depend on them.</li>
<li><strong>Player:</strong> a strategic decision-maker within a game.</li>
<li><strong>Strategy:</strong> a complete plan of actions a player will take, given the set of circumstances that might arise within the game.</li>
<li><strong>Payoff:</strong> the gain a player receives from arriving at a particular outcome of a game.</li>
<li><strong>Equilibrium:</strong> the point in a game where both players have made their decisions and an outcome is reached.</li>
<li><strong>Nash equilibrium:</strong> an equilibrium in which no player can gain by changing their own strategy if the strategies of the other players remain unchanged.</li>
<li><strong>Dominant strategy:</strong> occurs when one strategy is better than another strategy for one player, no matter how that player’s opponents may play.</li>
</ul>
<h4 id="heading-prisoners-dilemma"><strong>Prisoner’s dilemma</strong></h4>
<p>This is probably the most famous game in the literature. The figure below presents its payoff matrix. Now, a payoff matrix is worth a thousand words. It is sufficient, to an experienced eye, to provide all the information necessary to describe a game. But let’s be a bit less laconic.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3C9rRuM6lrhidno7Ihm5g82g2CLkNPSMrD0R" alt="Image" width="271" height="221" loading="lazy">
<em>Prisoner’s dilemma payoff matrix</em></p>
<p>The police arrest two criminals, criminal A and criminal B. Although quite notorious, the criminals cannot be imprisoned for the crime under investigation due to lack of evidence. But they can be held for lesser charges.</p>
<p>The length of their imprisonment will depend on what they will say in the interrogation room, which gives rise to the game. Each criminal (player) is given the chance to either stay silent or snitch on the other criminal (player). The payoff matrix depicts how many years each player will be imprisoned depending on the outcome. For example, if player A stays silent and player B snitches on them, player A will serve 3 years (-3) and player B will serve none (0).</p>
<p>If you reviews the payoff matrix carefully, you will find out that the logical action of a player is to betray the other person or, in game-theoretic terms, betraying is the dominant strategy. This will lead to the Nash equilibrium of the game, where each player has a payoff of -2.</p>
<p>Does something feel odd? Yes, or at least it should. If both players somehow agreed to remain silent they would both get a higher reward of -1. Prisoner’s dilemma is an example of a game where rationality leads to a worse result than cooperation would.</p>
<h4 id="heading-some-historical-remarks"><strong>Some historical remarks</strong></h4>
<p>Game theory originated in economics, but is today an interdisciplinary area of study. Its father, John von Neumann (you will notice that Johns have serious career prospects in this area), was the first to give a strict formulation to the common notion of a game. He restricted his studies to games of two players, as they were easier to analyze.</p>
<p>He then co-authored a book with Oskar Morgenstern, which laid the foundations for expected utility theory and shaped the course of game theory. Around that time, John Nash introduced the concept of Nash equilibria, which helps describe the outcome of a game.</p>
<h3 id="heading-reinforcement-learning">Reinforcement learning</h3>
<p>It did not take long to realize how vast the applications of game theory can be. From games to biology, philosophy and, wait for it, artificial intelligence. Game theory is nowadays closely related to settings where multiple players learn through reinforcement, an area called multi-agent reinforcement learning. Examples of applications in this case are teams of robots, where each player has to learn how to behave in favor of its team.</p>
<h4 id="heading-some-useful-terms-1"><strong>Some useful terms</strong></h4>
<ul>
<li><strong>Agent:</strong> equivalent to a player.</li>
<li><strong>Reward:</strong> equivalent to a payoff.</li>
<li><strong>State:</strong> all the information necessary to describe the situation an agent is in.</li>
<li><strong>Action:</strong> equivalent of a move in a game.</li>
<li><strong>Policy:</strong> similar to a strategy, it defines the action an agent will make when in particular states</li>
<li><strong>Environment:</strong> everything the agent interacts with during learning.</li>
</ul>
<h4 id="heading-applications">Applications</h4>
<p>Imagine the following scenario: a team of drones is unleashed into a forest in order to predict and locate fires early enough for the firefighters to respond. The drones are autonomous and must explore the forest, learn which conditions are likely to cause fire, and cooperate with each other, so that they cover wide areas of the forest using little battery and communication.</p>
<p>This application belongs to the area of environmental monitoring, where AI can lend its predictive skills to human intervention. In a technological world that is becoming increasingly complex and a physical world under threat, we can paraphrase <a target="_blank" href="https://www.brainyquote.com/quotes/rudyard_kipling_118509">Kipling’s quote</a> to “Man could not be everywhere, and therefore he made drones.”</p>
<p>Decentralized architectures are another interesting application field. Technologies like the <a target="_blank" href="https://en.wikipedia.org/wiki/Internet_of_things">Internet of Things</a> and Blockchain create immense networks. Information and processing is distributed in different physical entities, a trait that has been acknowledged to offer privacy, efficiency and democratization.</p>
<p>Regardless of whether you want to use sensors to minimize energy consumption in the households of a country, or replace the banking system, decentralized is the new sexy.</p>
<p>Making these networks smart, however, is challenging, as most of the AI algorithms we are proud of are data- and computation-hungry. Reinforcement learning algorithms can be employed for efficient data processing and rendering the network adaptive to changes in its environment. In this case, it is interesting, and to the benefit of overall efficiency, to study how the individual algorithms will cooperate.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/RcvtMhf4sDKByN00Jncb2s9aMCNZ5cB39fmv" alt="Image" width="800" height="600" loading="lazy">
<em>Deep or collective learning? AI research has based its harvest on increasingly deeper networks, but it could be that the answers to challenging problems come from collective knowledge, not deep-rooted individuals. Did we miss the forest?</em></p>
<h3 id="heading-not-just-a-game">Not just a game</h3>
<p>Translating AI problems to simple games like the prisoner’s dilemma is tempting. This is a usual practice when testing new techniques, as it offers a computationally cheap and intuitive testbed. Nevertheless, it is important not to ignore the effect that the practical characteristics of the problem, such as noise, delays, and finite memory, have on the algorithm.</p>
<p>Perhaps the most misleading assumption in AI research is that of representing interaction with iterated static games. For example, an algorithm can apply the prisoner’s dilemma game every time it wants to make a decision, a formulation that assumes that the agent has not learned, or changed, along the way. But what about the effect learning will have on the behavior of the agent? Won’t interaction with others affect its strategy?</p>
<p>Research in this area has focused on <a target="_blank" href="https://en.wikipedia.org/wiki/The_Evolution_of_Cooperation">evolution of cooperation</a> and Robert Axelrod has studied optimal strategies that arise in the iterated version of prisoner’s dilemma. The <a target="_blank" href="https://en.wikipedia.org/wiki/The_Evolution_of_Cooperation#Axelrod%27s_tournaments">tournaments</a> that Axelrod organized revealed that strategies that adapt with time and interaction, even as simple as Tit-for-Tat may sound, are very effective.The AI community has <a target="_blank" href="https://arxiv.org/abs/1803.00162">recently</a> investigated learning under the <strong>sequential prisoner’s dilemma</strong><em>,</em> but research in this area is still in a premature state.</p>
<p>What differentiates multi-agent from single-agent learning is the increased complexity. Training one deep neural network is already enough of a pain, while adding new networks, as parts of the agents, makes the problem exponentially harder.</p>
<p>One less obvious, but more important concern, is the lack of theoretical properties for this kind of problem. Single-agent reinforcement learning is a well-understood area, as Richard Bellman and Christopher Watkins have offered the algorithms and proofs necessary to learn. In the multi-agent case, however, the proofs lose their validity.</p>
<p>Just to illustrate some of the mind-puzzling difficulties that arise: an agent executes a learning algorithm to learn how to react optimally to its environment. In our case, the environment includes the other agents, which also execute the learning algorithm. Thus, the algorithm has to consider the effect of its action before it acts.</p>
<h3 id="heading-the-early-concerns"><strong>The early concerns</strong></h3>
<p>The concerns start where game theory started: in economics. Let’s begin with some assumptions made when studying a system under classical game theory.</p>
<p><strong>Rationality:</strong> generally in game theory, and in order to derive Nash equilibria, perfect rationality is assumed. This roughly means that agents always act for their own sake.</p>
<p><strong>Complete information:</strong> each agent knows everything about the game, including the rules, what the other players know, and what their strategies are.</p>
<p><strong>Common knowledge:</strong> there is common knowledge of a fact <strong>p</strong> in a group of agents when: all the agents know <strong>p</strong>, they all know that all agents know <strong>p</strong>, they all know that they all know that all agents know <strong>p</strong>, and so on <strong>ad infinitum</strong><em>.</em> There are interesting puzzles, like the <a target="_blank" href="http://mesosyn.com/mental1-2.html">blue-eyed islanders</a>, that describe the effect common knowledge has on a problem.</p>
<p>In 1986 Kenn Arrow expressed his reservations towards classical game theory.</p>
<blockquote>
<p>In <a target="_blank" href="http://dieoff.org/_Economics/RationalityOfSelfAndOthersArrow.pdf">this paper</a>, I want to disentangle some of the senses in which the hypothesis of rationality is used in economic theory. In particular, I want to stress that rationality is not a property of the individual alone, although it is usually presented that way. Rather, it gathers not only its force but also its very meaning from the social context in which it is embedded. It is most plausible under very ideal conditions. When these conditions cease to hold, the rationality assumptions become strained and possibly even self-contradictory.</p>
</blockquote>
<p>If you find that Arrow is a bit harsh with classical game theory, how rational would you say your last purchases have been? Or, how much consciousness and effort did you put into your meal today?</p>
<p>But Arrow is not so much worried about the assumption of rationality. He is worried about the implications of it. For an agent to be rational, you need to provide them with all the information necessary to make their decisions. This calls for omniscient players, which is bad in two ways: first, it creates impractical requirements for information storing and processing of players. Second, game theory is no longer a <strong>game theory</strong>, as you can replace all players by a central ruler (and where is the fun in that?).</p>
<p>The value of information in this view is another point of interest. We have already discussed that possessing all the information is infeasible. But what about assuming players with limited knowledge? Would that help?</p>
<p>You may ask anyone involved in this area, but it suffices to say that optimization under uncertainty is tough. Yes, there still are the good-old Nash equilibria. The problem is that they are infinite. Game theory does not provide you with arguments to evaluate them. So, even if you reach one, you shouldn't make it such a big deal.</p>
<h3 id="heading-reinforcement-learning-concerns"><strong>Reinforcement learning concerns</strong></h3>
<p>By this point you should suspect that AI applications are much more complicated than the examples classical game theory concerns itself with. Just to mention a few obstacles on the path of applying the Nash equilibrium approach in a robotic application: imagine being the captain of a team of robots playing football in RoboCup. How fast, strong, and intelligent are your players and your opponents? What strategies does the opponent team use? How should you reward your players? Is a goal the only reason for congratulating, or will applauding a good pass also improve the team’s behavior? Clearly, just being familiar with the rules of football will not win you the game.</p>
<p>If game theory has been raising debates for decades, if it has been founded on unrealistic assumptions and, for realistic tasks, if it offers complicated and little-understood solutions, why are we still going for it? Well, plainly enough, it’s the only thing we’ve got when it comes to group reasoning. If we actually understood how groups interact and cooperate to achieve their goals, psychology and politics would be much clearer.</p>
<p>Researchers in the area of multi-agent reinforcement learning either completely emit a discussion on the theoretical properties of their algorithms (and nevertheless often exhibit good results) or traditionally study the existence of Nash equilibria. The latter approach seems, to the eyes of a young researcher in the field, like a struggle to prove, under severe, unrealistic assumptions, the theoretical existence of solutions that — being infinite and of questionable value — will never be leveraged in practice.</p>
<h3 id="heading-evolutionary-game-theory"><strong>Evolutionary game theory</strong></h3>
<p>The inception of evolutionary game theory is not recent, yet its far-reaching applications in the area of AI took long to be acknowledged. Originating in biology, it was introduced in 1973, by John M. Smith and George R. Price, as an alternative to classical game theory. The alterations are so profound that we can talk about a whole new approach.</p>
<p>The subject of reasoning is no longer the player itself, but the population of players. Thus, probabilistic strategies are defined as the percentage of players that make a choice, not the probability of one player choosing an action as in classical game theory. This removes the necessity for rational, omniscient agents, as strategies evolve as patterns of behavior. The evolution process resembles Darwinian theory. Players reproduce following the principles of survival of the fittest and random mutations, and can be elegantly described by a set of differential equations, termed the <strong>replicator dynamics</strong>.</p>
<p>We can see the three important parts of this system in the illustration below. A population represents the team of agents, and is characterized by a mixture of strategies. The game rules determine the payoffs of the population, which can also be seen as the fitness values of an evolutionary algorithm. Finally, the replicator rules describe how the population will evolve based on the fitness values and the mathematical properties of the evolution process.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/pcZhSDCQhuD1w4AMlmVxdNV-M0cymDbheIM8" alt="Image" width="800" height="600" loading="lazy">
_Image credit: By HowieKor [CC BY-SA 3.0 ([https://creativecommons.org/licenses/by-sa/3.0](https://creativecommons.org/licenses/by-sa/3.0" rel="noopener" target="<em>blank" title="))], from Wikimedia Commons</em></p>
<p>The notion and pursuit of Nash equilibria is replaced by <strong>evolutionary stable strategies</strong><em>.</em> A strategy can bear this characterization if it is immune to an invasion by a population of agents that follow another strategy, provided that the invading population is small. Thus, the behavior of the team can be studied under the well-understood area of stability of dynamical systems, such as <a target="_blank" href="https://en.wikipedia.org/wiki/Lyapunov_stability">Lyapunov stability</a>.</p>
<blockquote>
<p>The attainment of equilibrium requires a disequilibrium process. What does rational behavior mean in the presence of disequilibrium? Do individuals speculate on the equilibrating process? If they do, can the disequilibrium be regarded as, in some sense, a higher-order equilibrium process?</p>
</blockquote>
<p>In the above passage, Arrow seems to be struggling to pinpoint the dynamic properties of a game. Could evolutionary game theory be an answer to his questions?</p>
<p>Quite recently, famous reinforcement learning algorithms, such as <a target="_blank" href="https://link.springer.com/chapter/10.1007/978-3-540-39857-8_38">Q-learning,</a> were studied under this new approach and significant conclusions were drawn. How this new tool is used ultimately depends on the application.</p>
<p>We can follow the forward approach, to derive the dynamic model of a learning algorithm. Or the inverse, where we start from some desired dynamic properties and engineer a learning algorithm that exhibits them.</p>
<p>We can use the replicator dynamics descriptively, to visualize convergence. Or prescriptively, to tune the algorithm in order to converge to optimal solutions. The latter can immensely reduce the complexity entailed in training deep networks for tough tasks that we face today, by removing the need for blind tuning.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>It’s not hard to trace when and why the paths of game theory and AI became convoluted. What’s harder, however, is to overlook the restrictions AI, and in particular multi-agent reinforcement learning, has to face when following classical game theoretic approaches.</p>
<p>Evolutionary game theory sounds promising, offering both theoretical tools and practical advantages, but we won’t really know until we try it. In this case, evolution will not arise naturally, but out of a conscious struggle of the research community for improvement. But isn’t that the essence of evolution?</p>
<p>It takes some effort to deviate from where inertia is pushing you, but reinforcement learning, despite general successes in AI, is in serious need of a lift.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
