normal_form() defines a normal-form game and creates an object of "normal_form" class.

normal_form(
  players = NULL,
  s1 = NULL,
  s2 = NULL,
  payoffs1 = NULL,
  payoffs2 = NULL,
  cells = NULL,
  discretize = FALSE,
  discrete_points = c(6, 6),
  symmetric = FALSE,
  byrow = FALSE,
  pars = NULL,
  par1_lim = NULL,
  par2_lim = NULL,
  cons1 = NULL,
  cons2 = NULL,
  cons_common = NULL
)

Arguments

players

A character vector of the name (label) for the players.

s1

A character vector of pure strategies for Player 1 (row player). Required only when the player has discrete-choice strategies.

s2

A character vector of pure strategies for Player 2 (column player). Required only when the player has discrete-choice strategies.

payoffs1

The payoff of Player1. This argument can be specified in three different ways. First, it can be a numeric vector of payoffs. Second, it can be a character string of the payoff function (e.g., payoffs1 = "x^2 - y"). Third, it can be an R function of payoff.

payoffs2

The payoff of Player 2. See the explanation of payoffs1 for detail.

cells

A list of vectors to specify the payoff for each cell. Each element of the list should be a numeric vector of two players' payoffs.

discretize

A logical value. Set this TRUE to evaluate payoff functions at some discrete values of strategies s1 and s2. Default is FALSE.

discrete_points

A numeric vector of length 2 to set how many discrete points should be used to discretize the game defined by payoff functions. Default is c(6, 6), which shows equally spaced 6 values from the range of the strategies par1_lim and par2_lim. Instead of setting this parameter, you can specify the vectors of arbitrary strategies by setting s1 and s2.

symmetric

A logical value. Set this TRUE when the payoffs for two players are symmetric as in the prisoners' dilemma. Then, payoffs1 is recycled for payoffs2. Default is FALSE.

byrow

A logical value. If TRUE, payoffs will be lined up by row. Default is FALSE. Only used when both s1 and s2 are provided.

pars

A character vector of parameters that are selected by players 1 and 2, respectively. Only used when payoffs1 and payoffs2 are specified by payoff functions (either as character strings or R functions).

par1_lim

A numeric vector of length 2, which defines the range of parameters from which Player 1 chooses her strategy.

par2_lim

A numeric vector of length 2, which defines the range of parameters from which Player 2 chooses his strategy.

cons1

A named list of parameters contained in payoffs1 that should be treated as constants, if any.

cons2

A named list of parameters contained in payoffs2 that should be treated as constants, if any.

cons_common

A named list of parameters contained in payoffs1 and payoffs2 that should be treated as constants, if any. If cons1 and cons2 are exactly same, you can specify cons_common instead of both cons1 and cons2.

Value

An object of "normal_form" class, which defines a normal-form (or strategic-form) game.

Details

Creates an object of "normal_form" class, which can be passed to functions in order to find solutions of the game.

Author

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

Examples

game1 <- normal_form(
  s1 = c("T", "B"),
  s2 = c("L", "R"),
  payoffs1 = c(4, 2, 3, 1),
  payoffs2 = c(4, 3, 2, 1),
  players = c("Row Player", "Column Player"))

game1b <- normal_form(
  s1 = c("T", "B"),
  s2 = c("L", "R"),
  cells = list(c(4, 4),
               c(2, 3),
               c(3, 2),
               c(1, 1)),
  players = c("Row Player", "Column Player"))

game2 <- normal_form(
   players = c("A", "B"),
   payoffs1 = "-x1^2 + (28 - x2) * x1",
   payoffs2 = "-x2^2 + (28 - x1) * x2",
   par1_lim = c(0, 30),
   par2_lim = c(0, 30),
   pars = c("x1", "x2"))

fx <- function(x, y, a, b) -x^a + (b - y) * x
fy <- function(x, y, s, t) -y^s + (t - x) * y
game3 <- normal_form(
  payoffs1 = fx,
  payoffs2 = fy,
  pars = c('x', 'y'),
  par1_lim = c(0, 30),
  par2_lim = c(0, 30))

if (FALSE) {
  ## This throws an error because payoffs1 and payoffs2 are in different forms.
  game4 <- normal_form(
    payoffs1 = fx,
    payoffs2 = "-y^2 + (28 - x) * y",
    pars = c('x', 'y'),
    par1_lim = c(0, 30),
    par2_lim = c(0, 30)
  )
}