Click or drag to resize
TwoPersonZeroSumGame Class

The TwoPersonZeroSumGame class represents a data type for computing optimal row and column strategies to two-person zero-sum games.

This implementation solves an M-by-N two-person zero-sum game by reducing it to a linear programming problem. Assuming the payoff matrix A is strictly positive, the optimal row and column player strategies x* and y* are obtained by solving the following primal and dual pair of linear programs, scaling the results to be probability distributions.

(P)  max  y^T 1         (D)  min   1^T x
     s.t  A^T y <= 1         s.t   A x >= 1
              y >= 0                 x >= 0

If the payoff matrix A has any negative entries, we add the same constant to every entry so that every entry is positive. This increases the value of the game by that constant, but does not change solutions to the two-person zero-sum game.

This implementation is not suitable for large inputs, as it calls a bare-bones linear programming solver that is neither fast nor robust with respect to floating-point roundoff error.

Inheritance Hierarchy
SystemObject
  Algs4NetTwoPersonZeroSumGame

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class TwoPersonZeroSumGame

The TwoPersonZeroSumGame type exposes the following members.

Constructors
  NameDescription
Public methodTwoPersonZeroSumGame
Determines an optimal solution to the two-sum zero-sum game with the specified payoff matrix.
Top
Methods
  NameDescription
Public methodColumn
Returns the optimal column strategy of this two-person zero-sum game.
Public methodStatic memberMainTest
Demo test the ZeroSumGameToLP data type.
Public methodRow
Returns the optimal row strategy of this two-person zero-sum game.
Public methodValue
Returns the optimal value of this two-person zero-sum game.
Top
Remarks

For additional documentation, see Section 6.5Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class TwoPersonZeroSumGame implementation by the respective authors.

See Also