View source: R/extensive_form.R
extensive_form | R Documentation |
extensive_form
defines an extensive-form game and draws
a game tree.
extensive_form(
players,
actions,
payoffs = NULL,
payoffs_node = NULL,
show_tree = TRUE,
show_node_id = TRUE,
info_sets = NULL,
info_line = "solid",
direction = "down",
color_palette = "Set1",
family = NULL,
size_player = 4,
size_payoff = 4,
size_action = 4,
size_node_id = 4,
size_terminal = 2,
linewidth = 1,
scale = NULL
)
players |
A list of players. Each element of the list must be a
character string or a vector of character strings at a specific depth of
the tree. Terminal nodes, where payoffs are displayed, must be specified
as |
actions |
A list of actions. Each element of the list must be a vector of character strings that corresponds to a specific player node. |
payoffs |
A named list of payoffs. Each element of the list must be a
numeric vector of payoffs for a player. The names of the elements must
match the names of the players specified by |
payoffs_node |
A list of payoffs. Each element of the list must be a numeric vector of payoffs for a terminal node. |
show_tree |
A logical value. If |
show_node_id |
A logical value. If |
info_sets |
A list of information sets. |
info_line |
Line type to connect nodes in an information set. Either
|
direction |
The direction to which a game tree grows.
The value must be one of:
|
color_palette |
A color palette to be used. Default is "Set1". |
family |
A font family to be used in the tree. |
size_player |
Font size for the players' names. Default is 4. |
size_payoff |
Font size for the payoffs. Default is 4. |
size_action |
Font size for the action displayed by each edge. Default is 4. |
size_node_id |
Size of the node id. Default is 4. |
size_terminal |
Size of the terminal node. Default is 2. |
linewidth |
Line width of edges. Default is 1. |
scale |
Scale |
This function defines an extensive-form game and draws the game tree.
An object of "extensive_form" class, which defines an extensive-form (or sequential) game.
Yoshio Kamijo and Yuki Yanai yanai.yuki@kochi-tech.ac.jp
g1 <- extensive_form(
players = list("Kamijo",
rep("Yanai", 2),
rep(NA, 4)),
actions = list(c("U", "D"),
c("U'", "D'"), c("U''", "D''")),
payoffs = list(Kamijo = c(0, 2, 1, 3),
Yanai = c(0, 1, 2, 1)))
g2 <- extensive_form(
players = list("f",
c("m", "m"),
rep(NA, 4)),
actions = list(c("ballet", "baseball"),
c("ballet", "baseball"), c("ballet", "baseball")),
payoffs = list(f = c(2, 0, 0, 1),
m = c(1, 0, 0, 2)),
show_node_id = FALSE)
g3 <- extensive_form(
players = list("p1",
rep("p2", 3),
rep(NA, 6)),
actions = list(c("C", "D", "E"),
c("F", "G"), c("H", "I"), c("J", "K")),
payoffs = list(p1 = c(3, 1, 1, 2, 2, 1),
p2 = c(0, 0, 1, 1, 2, 3)),
direction = "down",
show_node_id = TRUE)
g4 <- extensive_form(
players = list("child",
c(NA, "parent"),
c(NA, NA)),
actions = list(c("give up", "keep asking"),
c("leave", "buy")),
payoffs = list(child = c(0, -10, 10),
parent = c(5, -10, 2)))
g5 <- extensive_form(
players = list("Kamijo",
c("Yanai", NA),
c("Kamijo", NA),
c(NA, NA)),
actions = list(c("P", "T"),
c("P'", "T'"),
c("P''", "T''")),
payoffs = list(Kamijo = c(0, 1, 5, 3),
Yanai = c(0, 2, 4, 1)),
direction = "horizontal")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.