ManaClash {RMKdiscrete}R Documentation

The Mana Clash distributions (just for fun!)

Description

Density and random-number functions for distributions pertinent to "Mana Clash", a card from the Magic: The Gathering trading-card game. As of 08/29/2014, the official card text read: "You and target opponent each flip a coin. Mana Clash deals 1 damage to each player whose coin comes up tails. Repeat this process until both players' coins come up heads on the same flip."

Usage

dmanaclash.dmg(x,y,N=NULL,pA=0.25,pB=0.25,pC=0.25,pD=0.25,log=FALSE)
dmanaclash.xyN(x,y,N,pA=0.25,pB=0.25,pC=0.25,pD=0.25,log=FALSE)
dmanaclash.net(z,pA=0.25,pB=0.25,pC=0.25,pD=0.25,rel.eps=1e-8,log=FALSE)
rmanaclash(n,pA=0.25,pB=0.25,pC=0.25,pD=0.25,N=NULL)

Arguments

x

Numeric amount of damage dealt to opponent.

y

Numeric amount of damage dealt to Mana Clash's controller (hereinafter, "you").

N

Numeric. Number of rounds of coin-tossing that precede the last round, when double heads occurs. That is, N is the number of rounds of coin-tossing in which at least one player takes damage.

z

Numeric; net damage dealt to opponent; negative values are allowed.

n

Integer number of random vectors to generate.

pA

Numeric; probability that both players take damage in a round of coin-tossing (i.e., double tails).

pB

Numeric; probability that you take damage but opponent does not in a round of coin-tossing.

pC

Numeric; probability that opponent takes damage but you do not in a round of coin-tossing.

pD

Numeric; probability that neither player takes damage in a round of coin-tossing (i.e., double heads).

log

Logical; should the natural log of the probability be returned? Defaults to FALSE.

rel.eps

Numeric; when computing the sum of an infinite series, how small should the relative change in the sum get before stopping?

Details

The probability arguments–pA, pB, pC, and pD–are named as in a two-way contingency table. They cannot be negative, although rmanaclash accepts values of zero for pA, pB, and pC. If they do not sum to 1, they are automatically normalized. They default to the scenario of two independent fair coins.

Vectors of numeric arguments other than rel.eps are cycled, whereas only the first element of logical and integer arguments is used.

Function dmanaclash.dmg() is the bivariate PMF of the amount of damage dealt to opponent and you. If N = NULL (default), the probabilities are marginal with respect to the number of rounds of damage-dealing. Otherwise, the probabilities are conditioned upon the given value of N.

Function dmanaclash.xyN() is the trivariate joint PMF of the amount of damage dealt to opponent, the amount dealt to you, and the number of rounds of damage-dealing.

Function dmanaclash.net is the univariate PMF of the net amount of damage dealt to opponent, i.e. damage dealt to opponent minus damage dealt to you. This distribution has support on the set of integers–including negative values.

Function rmanaclash() generates random draws from the trivariate joint distribution of x, y, and N; if a non-NULL value for N is supplied, the random draws are generated conditionally on that number of damage-dealing rounds.

Value

dmanaclash.dmg(), dmanaclash.xyN(), and dmanaclash.net() all return numeric vectors of probabilities. rmanaclash() returns a numeric matrix, with n rows, and three columns, named "x", "y", and "N". Each row is a random draw.

Derivation

Note: This section is only displayed in the PDF of the package documentation.

Author(s)

Robert M. Kirkpatrick rkirkpatrick2@vcu.edu

References

Magic: The Gathering is a trademark of Wizards of the Coast, LLC, a subsidiary of Hasbro, Inc.

Examples

## Same outcome, with and without conditioning on N:
dmanaclash.dmg(x=1,y=1,N=1)
dmanaclash.dmg(x=1,y=1)

## Same damage amounts, with N fixed versus random:
dmanaclash.dmg(x=1,y=1,N=2)
dmanaclash.xyN(x=1,y=1,N=2)

## Net damage distribution is symmetric with defaults:
dmanaclash.net(z=c(-3,-2,-1,0,1,2,3))
## But if coins are biased against opponent...:
dmanaclash.net(z=c(-3,-2,-1,0,1,2,3),pA=0.1,pB=0.1,pC=0.7,pD=0.1)

## Random draws:
rmanaclash(n=10)
rmanaclash(n=10,pA=0.1,pB=0.1,pC=0.7,pD=0.1)
rmanaclash(n=10,N=5)

[Package RMKdiscrete version 0.2 Index]