cds2.game_theory
Two-player games: Nash equilibria, dominance, iterated prisoner's dilemma.
Two-player game theory: dominance, Nash equilibria, zero-sum LP solving, iterated PD.
EliminationResult
dataclass
Surviving original action indices after iterated dominance elimination.
Source code in src/cds2/game_theory.py
44 45 46 47 48 49 50 | |
MixedEquilibrium
dataclass
Mixed-strategy equilibrium of a zero-sum game.
Source code in src/cds2/game_theory.py
53 54 55 56 57 58 59 | |
PDResult
dataclass
Scores and move histories of an iterated prisoner's dilemma match.
Source code in src/cds2/game_theory.py
62 63 64 65 66 67 68 69 | |
strictly_dominated_actions(payoffs, player='row')
Indices of actions beaten everywhere by some rival action of the same player.
Source code in src/cds2/game_theory.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
iterated_elimination(payoff_row, payoff_col, max_rounds=50)
Repeatedly delete strictly dominated actions until stable or max_rounds.
Source code in src/cds2/game_theory.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
pure_nash_equilibria(payoff_row, payoff_col)
Cells where each action is a weak best response to the other player's action.
Source code in src/cds2/game_theory.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
zero_sum_mixed(payoff_row)
Solve a zero-sum game for the maximin mixed strategy via linear programming.
Source code in src/cds2/game_theory.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
expected_payoff(payoff_row, row_strategy, col_strategy)
Expected payoff r^T A c of mixed strategies over the row player's matrix.
Source code in src/cds2/game_theory.py
177 178 179 180 181 182 183 184 185 186 187 188 | |
play_iterated_pd(strategy_a, strategy_b, rounds=100, temptation=5.0, sucker=0.0, punishment=2.5, reward=3.0, seed=None)
Play the iterated prisoner's dilemma between two built-in strategies.
Source code in src/cds2/game_theory.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |