Section3.3Using Sage to Graph Lines and Solve Equations
In this section we will use technology to graph lines and solve for the intersection point. In particular, we will use an open online resource called Sage.
We will follow the same steps as in Section 3.2. Let \(p\) be the probability that Player 1 plays B. Let \(m\) be the payoff to Player 1. Since we are trying to find a mixed strategy for Player 1, we will pick a strategy for Player 2 and try to determine the possible payoffs for Player 1.
If Player 1 always plays \(A\text{,}\) then we are considering the strategy pair \([A, C]\text{.}\) Since Player 1 never plays \(B\text{,}\)\(p=0\text{.}\) The payoff to Player 1 for \([A, C]\) is \(m=1\text{.}\) Thus, for the strategy pair \([A, C]\) we get \((p, m)=(0, 1)\text{.}\)
If Player 1 always plays \(B\text{,}\) then we are considering the strategy pair \([B, C]\text{.}\) Since Player 1 always plays \(B\text{,}\)\(p=1\text{.}\) The payoff to Player 1 for \([A, C]\) is \(m=-1\text{.}\) Thus, for the strategy pair \([B, C]\) we get \((p, m)=(1, -1)\text{.}\)
Now we want to know what Player 1’s payoff will be as she varies the probability, \(p\text{,}\) with which she plays \(B\text{.}\) We can draw a graph where the \(x\)-axis represents to probability with which she plays B (\(p\)) and the \(y\)-axis represents the expected payoff (\(m\)). Thus, when Player 1 plays only \(A\text{,}\) she is playing \(B\) with probability 0; when Player 1 plays only B, she is playing B with probability 1. It might be easier to remember if you label your graph as in Figure 3.2.2.
Now we can use Sage to plot the points we determined in Step 1a and Step 1b and the line between them. This line represents Player 2’s pure strategy \(C\text{.}\) See Figure 3.2.3. Click on the “Evaluate (Sage)” button to plot the line between the points \((0, 1)\) and \((1, -1)\text{.}\)
Before moving on, let’s again, make sure we understand what this line represents. Any point on it represents the expected payoff to Player 1 as she varies her strategy, assuming Player 2 only plays \(C\). In this case, we can see that as she plays \(B\) more often, her expected payoff goes down. You can now use this Sage cell to plot any line for Player 2’s pure strategy \(C\text{.}\) Just edit the values for the points \(u\) and \(v\text{.}\) Go ahead and try it! (Don’t worry the original values will reset when you refresh the page.)
If Player 1 always plays \(A\text{,}\) then we are considering the strategy pair \([A, D]\text{.}\) Since Player 1 never plays \(B\text{,}\)\(p=0\text{.}\) The payoff to Player 1 for \([A, D]\) is \(m=0\text{.}\) Thus, for the strategy pair \([A, D]\) we get \((p, m)=(0, 0)\text{.}\)
If Player 1 always plays \(B\text{,}\) then we are considering the strategy pair \([B, D]\text{.}\) Since Player 1 always plays \(B\text{,}\)\(p=1\text{.}\) The payoff to Player 1 for \([B, D]\) is \(m=2\text{.}\) Thus, for the strategy pair \([B, D]\) we get \((p, m)=(1, 2)\text{.}\)
Now, on our same graph from Step 1, we can plot the points we determined in Step 2a and Step 2b. We will connect them with a line representing Player 2’s pure strategy \(D\text{.}\) See Figure 3.2.4.
Now we can see that if Player 2 plays only \(D\text{,}\) then Player 1 does best by playing only \(B\text{.}\) Again, you can use this Sage cell to plot both Player 2’s pure strategies. Points \(AC\) and \(BC\) are for strategy \(C\text{,}\) while points \(AD\) and \(BD\) are for strategy \(D\text{.}\)
As we saw in Section 3.2, for each choice of \(p\text{,}\) the top line represents the highest expected value for Player 1; the bottom line represents the lowest expected value for Player 1; the area between the lines represents the possible expected values for Player 1. Thus, Player 1 wants to maximize the minimum expected value, which means she wants to find the maximin strategy. And, as we saw in Section 3.2, the maximin strategy occurs at the intersection of the two lines.
This is the line passing through the points \((0, 1)\) and \((1, -1)\text{.}\) It has slope \(-2\) and \(y\)-intercept 1. Thus, it has equation \(m=-2p+1\text{.}\) (Recall the \(x\)-axis represents probability \(p\) and the \(y\)-axis represents expected payoff \(m\text{.}\))
This is the line passing through the points \((0, 0)\) and \((1, 2)\text{.}\) It has slope \(2\) and \(y\)-intercept 0. Thus, it has equation \(m=2p\text{.}\)
Step 4. Determine Player 1’s maximin mixed strategy.
Determine Player 1’s maximin mixed strategy. Recalling that \(p\) is the probability that Player 1 plays \(B\text{,}\) we know that Player 1 will play \(B\) with probability 1/4, and thus, play A with probability 3/4. The expected payoff for Player 1, \(m\text{,}\) is 1/2. It is important to check the algebraic solution with where the intersection point appears on the graph. Although we are using technology to help us graph and solve for the intersection point, we need to be able to catch any errors we make entering the information into Sage.
and continuing to label Player 1’s strategies by \(A\) and \(B\text{,}\) and Player 2’s strategies by \(C\) and \(D\text{,}\) we can graph lines for Player 1’s pure strategies \(A\) and \(B\text{.}\) We now let the \(x\)-axis represent the probability that Player 2 plays \(D\text{.}\) In the Sage applet below, for \(AC\) and \(AD\) enter the coordinates of two points that determine the line for when Player 1 plays \(A\text{,}\) then the two points for \(BC\) and \(BD\) that determine the line for when Player 1 plays \(B\text{.}\) We will then have Sage graph the lines. You can enter new values for \(AC, AD, BC,\) and \(BD\) if you would like to draw the graph for a different matrix.
You can now use these last two Sage cells to solve any 2 \(\times\) 2 game with a mixed strategy equilibrium. You can also take some time to experiment with what happens if the game has a pure strategy equilibrium.
Sage is a powerful tool that we can use to solve many different computational problems. It is nice because it is free and open to use. But feel free to use other available graphing and solving tools, such as Desmos 1
Use your graph to determine if there is a mixed strategy equilibrium point. If there is, use technology to determine how often Player 1 should play each strategy. What is the expected payoff to each player?
Use your graph to determine if there is a mixed strategy equilibrium point. If there is, determine how often Player 1 should play each strategy. What is the expected payoff to each player?
Consider the zero-sum game given by Table 3.3.2. If we are finding Player 1’s mixed strategy, which two points are on the line for Player 2’s pure strategy C?
Consider the zero-sum game given by Table 3.3.2. If we are finding Player 1’s mixed strategy, which two points are on the line for Player 2’s pure strategy D?
If we use the graph to try to find Player 1’s mixed strategy, which of the following can we determine with just the graph, without solving for the intersection point?