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
)

Arguments

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 NA.

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 players.

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 TRUE, the game tree will be displayed. Default is TRUE.

show_node_id

A logical value. If TRUE, the node numbers are displayed in the figure. Default is TRUE.

info_sets

A list of information sets.

info_line

Line type to connect nodes in an information set. Either "solid" or "dashed". Default to "solid".

direction

The direction to which a game tree grows. The value must be one of: "right", "up", "down", "bidirectional" (temporarily disabled), "horizontal", and "vertical". Default is "down".

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 player_size, payoff_size, action_size, noden_size, terminal_size, and linewidth. It must be a positive number.

Value

An object of "extensive_form" class, which defines an extensive-form (or sequential) game.

Details

This function defines an extensive-form game and draws the game tree.

Author

Yoshio Kamijo and Yuki Yanai yanai.yuki@kochi-tech.ac.jp

Examples

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")