This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library(rgamer)
library(utf8)
game0<- normal_form(players = c("S","s"),
s1=c("A","B"),
s2=c("A","B"),
cells = list(c(3,3),
c(0,1),
c(1,1),
c(2,3)),
byrow = T)
s_game0<- solve_nfg(game0,show_table = T,mixed = TRUE)
s_game0$br_plot
game01<- normal_form(players = c("S","s"),
s1=c("A","B"),
s2=c("a","b"),
cells = list(c(3,2),
c(5,5),
c(0,0),
c(7,4)),
byrow = T)
s_game01<- solve_nfg(game01,show_table = T)#mixed = TRUE)
Pure-strategy NE: [B, b]
s |
|||
|---|---|---|---|
| strategy | a | b | |
| S | A | 3^, 2 | 5, 5^ |
| B | 0, 0 | 7^, 4^ | |
s_game01$br_plot
game02<- normal_form(players = c("j1","j2"),
s1=c("Alto","Baixo"),
s2=c("Esquerda","Direita"),
cells = list(c(4,2),
c(-1,0),
c(0,-1),
c(1,3)),
byrow = T)
s_game02<- solve_nfg(game02,show_table = T,mixed = TRUE)
Pure-strategy NE: [Alto, Esquerda], [Baixo, Direita]
Mixed-strategy NE: [(2/3, 1/3), (1/3, 2/3)]
The obtained mixed-strategy NE might be only a part of the solutions.
Please examine br_plot (best response plot) carefully.
j2 |
|||
|---|---|---|---|
| strategy | Esquerda | Direita | |
| j1 | Alto | 4^, 2^ | -1, 0 |
| Baixo | 0, -1 | 1^, 3^ | |
s_game02$br_plot
game03<- normal_form(players = c("Mulher","Homem"),
s1=c("Jantar","Cinema"),
s2=c("Jantar","Cinema"),
cells = list(c(4,3),
c(1,1),
c(1,1),
c(3,4)),
byrow = T)
s_game03<- solve_nfg(game03,show_table = T,mixed = TRUE)
Pure-strategy NE: [Jantar, Jantar], [Cinema, Cinema]
Mixed-strategy NE: [(3/5, 2/5), (2/5, 3/5)]
The obtained mixed-strategy NE might be only a part of the solutions.
Please examine br_plot (best response plot) carefully.
Homem |
|||
|---|---|---|---|
| strategy | Jantar | Cinema | |
| Mulher | Jantar | 4^, 3^ | 1, 1 |
| Cinema | 1, 1 | 3^, 4^ | |
s_game03$br_plot
jogo4 <- normal_form(
players = c("A", "B"),
s1 = c("Producao_alta", "Producao_baixa"),
s2 = c("Producao_alta", "Producao_baixa"),
cells = list(c(8,8),
c(12,6),
c(6,12),
c(10,10)),
byrow = T)
s_jogo4 <- solve_nfg(jogo4,
mixed = TRUE,
show_table = T)
Pure-strategy NE: [Producao_alta, Producao_alta]
The payoff matrix is degenerate; No full support mixed-strategy NE exist (or infinitely many exist).
Please examine br_plot (best response plot).
B |
|||
|---|---|---|---|
| strategy | Producao_alta | Producao_baixa | |
| A | Producao_alta | 8^, 8^ | 12^, 6 |
| Producao_baixa | 6, 12^ | 10, 10 | |
s_jogo4$br_plot
politica<- normal_form(
players = c("AB","CD"),
s1=c("Moderado","Cinico","Agressivo"),
s2=c("Moderado","Cinico","Agressivo"),
payoffs1 = c(-0.7, 0.5, -0.4,0.5,-0.3,0,-0.3,0.2,0.7),
payoffs2 = c(-0.7,0.5,-0.3,0.5,-0.3,0.2,-0.4,0,0.7))
s_politica <- solve_nfg(politica, show_table = TRUE,mixed = T)
Pure-strategy NE: [Cinico, Moderado], [Moderado, Cinico], [Agressivo, Agressivo]
Mixed-strategy NE: [(55/196, 15/28, 9/49), (55/196, 15/28, 9/49)]
The obtained mixed-strategy NE might be only a part of the solutions.
CD |
||||
|---|---|---|---|---|
| strategy | Moderado | Cinico | Agressivo | |
| AB | Moderado | -0.7, -0.7 | 0.5^, 0.5^ | -0.3, -0.4 |
| Cinico | 0.5^, 0.5^ | -0.3, -0.3 | 0.2, 0 | |
| Agressivo | -0.4, -0.3 | 0, 0.2 | 0.7^, 0.7^ | |
s_politica
$psNE
[1] "[Cinico, Moderado]" "[Moderado, Cinico]"
[3] "[Agressivo, Agressivo]"
$msNE
$msNE$s1
[1] 0.2806122 0.5357143 0.1836735
$msNE$s2
[1] 0.2806122 0.5357143 0.1836735
$table
CD |
||||
|---|---|---|---|---|
| strategy | Moderado | Cinico | Agressivo | |
| AB | Moderado | -0.7, -0.7 | 0.5^, 0.5^ | -0.3, -0.4 |
| Cinico | 0.5^, 0.5^ | -0.3, -0.3 | 0.2, 0 | |
| Agressivo | -0.4, -0.3 | 0, 0.2 | 0.7^, 0.7^ | |
$br_plot
NULL
$msNE_df
$msNE_prob
$msNE_prob$p
[1] 0.2806122 0.5357143 0.1836735
$msNE_prob$q
[1] 0.2806122 0.5357143 0.1836735
s_politica$br_plot
NULL
supermercado<- normal_form(players = c("ABC","XYZ"),
s1=c("Preco_alto","Preço_baixo"),
s2=c("Agressivo","Conservador"),
payoffs1 = c(80000,45000,45000,40000),
payoffs2 = c(70000,30000,60000,80000))
#cells = list(c(80000,70000),
# c(45000,60000),
#c(45000,30000),
# c(40000,80000)),
#byrow = T)
s_super <- solve_nfg(supermercado,
mixed = TRUE,
show_table = T)
Pure-strategy NE: [Preco_alto, Agressivo]
The payoff matrix is degenerate; No full support mixed-strategy NE exist (or infinitely many exist).
Please examine br_plot (best response plot).
XYZ |
|||
|---|---|---|---|
| strategy | Agressivo | Conservador | |
| ABC | Preco_alto | 80000^, 70000^ | 45000^, 60000 |
| Preço_baixo | 45000, 30000 | 40000, 80000^ | |
s_super$br_plot
s_super
$psNE
[1] "[Preco_alto, Agressivo]"
$msNE
NULL
$table
XYZ |
|||
|---|---|---|---|
| strategy | Agressivo | Conservador | |
| ABC | Preco_alto | 80000^, 70000^ | 45000^, 60000 |
| Preço_baixo | 45000, 30000 | 40000, 80000^ | |
$br_plot
$msNE_df
$msNE_prob
$msNE_prob$p
[1] 0.8333333 0.1666667
$msNE_prob$q
[1] -0.1666667 1.1666667
game1<- normal_form(
players = c("A","B"),
s1=c("Confessar","calar"),
s2=c("Confessar","calar"),
cells = list(c(5,5),
c(0,10),
c(10,0),
c(2,2)),
byrow = T)
s_game1 <- solve_nfg(game1, show_table = T)
s_game1
jogo1 <- normal_form(
players = c("Bonnie", "Clyde"),
s1 = c("Confessar", "Não Confessar"),
s2 = c("Confessar", "Não Confessar"),
cells = list(c(-8, -8),
c(0, -15),
c(-15, 0),
c(-1, -1)),
byrow = T)
s_jogo1 <- solve_nfg(jogo1, show_table = T)
jogo2 <- normal_form(
players = c("OilFlex", "EconoGas"),
s1 = c("Manter Preço", "Reduzir Preço"),
s2 = c("Manter Preço", "Reduzir Preço"),
payoffs1 = c(50, 60, 30, 40),
payoffs2 = c(50, 30, 60, 40))
s_jogo2 <- solve_nfg(jogo2, show_table = TRUE)
s_jogo2
jogo4 <- normal_form(
players = c("Governo", "Pobre"),
s1 = c("Ajuda", "Não Ajuda"),
s2 = c("Trabalha", "Vadia"),
payoffs1 = c(3, -1, -1, 0),
payoffs2 = c(2, 1, 3, 0))
s_jogo4 <- solve_nfg(jogo4,
mixed = TRUE,
show_table = T)
s_jogo4$br_plot
jogo5 <- normal_form(
players = c("cidade_A", "Cidade_B"),
s1 = c("Apoia", "Rejeita"),
s2 = c("Apoia", "Rejeita"),
payoffs1 = c(8, -1, 9, 0),
payoffs2 = c(8, 9, -1, 0))
s_jogo5 <- solve_nfg(jogo5,
mixed = TRUE,
show_table = T)
s_jogo5$br_plot
jogo4 <- normal_form(
players = c("A1", "A2"),
s1 = c("Ajuda", "Não Ajuda"),
s2 = c("Ajuda", "Não Ajuda"),
payoffs1 = c(3, 4,5,1),
payoffs2 = c(3, 4,5,1))
s_jogo4 <- solve_nfg(jogo4,
mixed = TRUE,
show_table = T)
s_jogo4$br_plot
game4 <- normal_form(
players = c("A1","A2"),
s1 = c("Futebol", "Filmes","Auditorio"),
s2 = c("Futebol", "Filmes","Auditorio"),
payoffs1 = c(7,5,2,9,3,4,2,4,6),
payoffs2 = c(7,5,2,9,3,4,2,4,6))
s_game4 <- solve_nfg(game4,
mixed = TRUE,
show_table = T)
Pure-strategy NE: [Futebol, Filmes], [Auditorio, Auditorio]
Mixed-strategy NE: [(1/6, 1/2, 1/3), (7/18, 1/18, 5/9)]
The obtained mixed-strategy NE might be only a part of the solutions.
A2 |
||||
|---|---|---|---|---|
| strategy | Futebol | Filmes | Auditorio | |
| A1 | Futebol | 7^, 7 | 9^, 9^ | 2, 2 |
| Filmes | 5, 5^ | 3, 3 | 4, 4 | |
| Auditorio | 2, 2 | 4, 4 | 6^, 6^ | |
s_game4
$psNE
[1] "[Futebol, Filmes]" "[Auditorio, Auditorio]"
$msNE
$msNE$s1
[1] 0.1666667 0.5000000 0.3333333
$msNE$s2
[1] 0.38888889 0.05555556 0.55555556
$table
A2 |
||||
|---|---|---|---|---|
| strategy | Futebol | Filmes | Auditorio | |
| A1 | Futebol | 7^, 7 | 9^, 9^ | 2, 2 |
| Filmes | 5, 5^ | 3, 3 | 4, 4 | |
| Auditorio | 2, 2 | 4, 4 | 6^, 6^ | |
$br_plot
NULL
$msNE_df
$msNE_prob
$msNE_prob$p
[1] 0.1666667 0.5000000 0.3333333
$msNE_prob$q
[1] 0.38888889 0.05555556 0.55555556
game5 <- normal_form(
players = c("A1","A2"),
s1 = c("Musica", "Filmes","series"),
s2 = c("Musica", "Filmes","series"),
payoffs1 = c(2,1,-1,-1,4,1,-2,-3,1),
payoffs2 = c(2,1,-1,-1,4,1,-2,-3,1))
s_game5 <- solve_nfg(game5,
mixed = TRUE,
show_table = T)
Pure-strategy NE: [Musica, Musica], [Filmes, Filmes], [series, series]
The payoff matrix is degenerate; No full support mixed-strategy NE exist (or infinitely many exist).
It might be useful to check 'msNE_df'.
A2 |
||||
|---|---|---|---|---|
| strategy | Musica | Filmes | series | |
| A1 | Musica | 2^, 2^ | -1, -1 | -2, -2 |
| Filmes | 1, 1 | 4^, 4^ | -3, -3 | |
| series | -1, -1 | 1, 1^ | 1^, 1^ | |
s_game5$br_plot
NULL
s_game5
$psNE
[1] "[Musica, Musica]" "[Filmes, Filmes]" "[series, series]"
$msNE
NULL
$table
A2 |
||||
|---|---|---|---|---|
| strategy | Musica | Filmes | series | |
| A1 | Musica | 2^, 2^ | -1, -1 | -2, -2 |
| Filmes | 1, 1 | 4^, 4^ | -3, -3 | |
| series | -1, -1 | 1, 1^ | 1^, 1^ | |
$br_plot
NULL
$msNE_df
$msNE_prob
$msNE_prob$p
[1] 0.38888889 -0.05555556 0.66666667
$msNE_prob$q
[1] 0.4722222 0.1666667 0.3611111
game5 <- normal_form(
players = c("Tijolos","Chuva"),
s1 = c("T1", "T2","T3"),
s2 = c("C1", "C2","C3"),
payoffs1 = c(80,60,80, 30,90,80,75,70,50),
payoffs2 = c(80,60,80, 30,90,80,75,70,50))
s_game5 <- solve_nfg(game5,
mixed = TRUE,
show_table = T)
Pure-strategy NE: [T1, C1], [T3, C1], [T2, C2]
Mixed-strategy NE: [(18/55, 6/11, 7/55), (5/11, 2/11, 4/11)]
The obtained mixed-strategy NE might be only a part of the solutions.
Chuva |
||||
|---|---|---|---|---|
| strategy | C1 | C2 | C3 | |
| Tijolos | T1 | 80^, 80^ | 30, 30 | 75^, 75 |
| T2 | 60, 60 | 90^, 90^ | 70, 70 | |
| T3 | 80^, 80^ | 80, 80^ | 50, 50 | |
s_game5$br_plot
NULL
s_game5
$psNE
[1] "[T1, C1]" "[T3, C1]" "[T2, C2]"
$msNE
$msNE$s1
[1] 0.3272727 0.5454545 0.1272727
$msNE$s2
[1] 0.4545455 0.1818182 0.3636364
$table
Chuva |
||||
|---|---|---|---|---|
| strategy | C1 | C2 | C3 | |
| Tijolos | T1 | 80^, 80^ | 30, 30 | 75^, 75 |
| T2 | 60, 60 | 90^, 90^ | 70, 70 | |
| T3 | 80^, 80^ | 80, 80^ | 50, 50 | |
$br_plot
NULL
$msNE_df
$msNE_prob
$msNE_prob$p
[1] 0.3272727 0.5454545 0.1272727
$msNE_prob$q
[1] 0.4545455 0.1818182 0.3636364
game1<- normal_form(
players = c("Ladrao","Policia"),
s1=c("Assaltos_noturnos","Assaltos_diurnos"),
s2=c("Ronda_Noturna","Ronda_diurna"),
payoffs1 = c(5,8,10,6),
payoffs2 = c(5,8,10,6))
s_game1 <- solve_nfg(game1,
mixed = TRUE,
show_table = T)
Pure-strategy NE: [Assaltos_diurnos, Ronda_Noturna], [Assaltos_noturnos, Ronda_diurna]
Mixed-strategy NE: [(2/7, 5/7), (4/7, 3/7)]
The obtained mixed-strategy NE might be only a part of the solutions.
Please examine br_plot (best response plot) carefully.
Policia |
|||
|---|---|---|---|
| strategy | Ronda_Noturna | Ronda_diurna | |
| Ladrao | Assaltos_noturnos | 5, 5 | 10^, 10^ |
| Assaltos_diurnos | 8^, 8^ | 6, 6 | |
s_game1
$psNE
[1] "[Assaltos_diurnos, Ronda_Noturna]"
[2] "[Assaltos_noturnos, Ronda_diurna]"
$msNE
$msNE$s1
[1] 0.2857143 0.7142857
$msNE$s2
[1] 0.5714286 0.4285714
$table
Policia |
|||
|---|---|---|---|
| strategy | Ronda_Noturna | Ronda_diurna | |
| Ladrao | Assaltos_noturnos | 5, 5 | 10^, 10^ |
| Assaltos_diurnos | 8^, 8^ | 6, 6 | |
$br_plot
$msNE_df
$msNE_prob
$msNE_prob$p
[1] 0.2857143 0.7142857
$msNE_prob$q
[1] 0.5714286 0.4285714
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.