Solving Police vs. Guerrillas#
The functions below will create the correct game matrix and will calculate the winning percentages of the various strategies. First, we initialize python in the code block below. Then, we can generate several version of Police vs. Guerrillas.
Functions that Create the Game Matrix#
Given that all three toolkit functions are working properly, the following code will generate any Police versus Guerrillas example game matrix we wish.
Example 1: 8P vs. 6G#
p = 8
g = 6
P = create_player_dict('P', p)
G = create_player_dict('G', g)
results = game_matrix(P,G)
for i in P['index']:
for j in G['index']:
results.loc[P['strat_name'][i],G['strat_name'][j]] = play(p,g, int(P['strat_name'][i][0]),int(G['strat_name'][j][0]))
results.style.set_caption(f"<b>{p} Police vs. {g} Guerrillas</b>").format(precision=1)
| 3 - 3 | 4 - 2 | 5 - 1 | 6 - 0 | |
|---|---|---|---|---|
| 4 - 4 | 1 | 1 | 0 | 0 |
| 5 - 3 | 1 | 1/2 | 1/2 | 0 |
| 6 - 2 | 0 | 1/2 | 1/2 | 1/2 |
| 7 - 1 | 0 | 0 | 1/2 | 1/2 |
| 8 - 0 | 0 | 0 | 0 | 1/2 |
Example 1: Reducing by Doominance#
Notice that Police 6 - 2 dominates 7 - 1 and 8 - 0. After these two rows are deleted, then Guerrillas 6 - 0 dominates 5 - 1 and 4 - 2. This leaves:
With Police 4 - 4 and 5 - 3 equally effective, we can choose either one to retain while deleting the other, so we have the following:
The solution by oddments: both players oddments will be \(1\) and \(\frac{1}{2}\), so the players optimal strategy sets (including all original strategies) will be as follows:
Example 2: 10P vs. 8G#
p = 10
g = 8
P = create_player_dict('P', p)
G = create_player_dict('G', g)
results = game_matrix(P,G)
for i in P['index']:
for j in G['index']:
results.loc[P['strat_name'][i],G['strat_name'][j]] = play(p,g, int(P['strat_name'][i][0]),int(G['strat_name'][j][0]))
results.style.set_caption(f"<b>{p} Police vs. {g} Guerrillas</b>").format(precision=1)
| 4 - 4 | 5 - 3 | 6 - 2 | 7 - 1 | 8 - 0 | |
|---|---|---|---|---|---|
| 5 - 5 | 1 | 1 | 0 | 0 | 0 |
| 6 - 4 | 1 | 1/2 | 1/2 | 0 | 0 |
| 7 - 3 | 0 | 1/2 | 1/2 | 1/2 | 0 |
| 8 - 2 | 0 | 0 | 1/2 | 1/2 | 1/2 |
| 9 - 1 | 0 | 0 | 0 | 1/2 | 1/2 |
| 10 - 0 | 0 | 0 | 0 | 1/2 | 1/2 |
Example 2: Reduction by Dominance#
After seeing that Police 8 - 2 dominates 9 - 1 and 10 - 0, and then that Guerrillas 8 - 0 dominates 7 - 1 and 6 - 2, we are left with the follwing:
Police 5 - 5 dominates 6 - 4 and 7 - 3 which gives the following:
The Guerrillas now have \(2\) identical strategies and therefore we have the following:
Solution#
As we have seen before, the oddments are \(\frac{1}{3}\) and \(\frac{2}{3}\) for both players while the value is \(\frac{1}{3}\).
Example 3: 11P vs. 9G#
p = 11
g = 9
P = create_player_dict('P', p)
G = create_player_dict('G', g)
results = game_matrix(P,G)
for i in P['index']:
for j in G['index']:
results.loc[P['strat_name'][i],G['strat_name'][j]] = play(p,g, int(P['strat_name'][i][0]),int(G['strat_name'][j][0]))
results.style.set_caption(f"<b>{p} Police vs. {g} Guerrillas</b>").format(precision=1)
| 5 - 4 | 6 - 3 | 7 - 2 | 8 - 1 | 9 - 0 | |
|---|---|---|---|---|---|
| 6 - 5 | 1 | 1/2 | 0 | 0 | 0 |
| 7 - 4 | 1/2 | 1/2 | 1/2 | 0 | 0 |
| 8 - 3 | 0 | 1/2 | 1/2 | 1/2 | 0 |
| 9 - 2 | 0 | 0 | 1/2 | 1/2 | 1/2 |
| 10 - 1 | 0 | 0 | 0 | 1/2 | 1/2 |
| 11 - 0 | 0 | 0 | 0 | 1/2 | 1/2 |
The solution to 11P vs. 9G is quite similar to the work shown above.