Author | zdg |

Submission date | 2011-10-23 05:13:32.563303 |

Rating | 4996 |

Matches played | 1213 |

Win rate | 46.58 |

Use rpsrunner.py to play unranked matches on your computer.

```
# beats beat last and constant and all the ones in between
# --------------------- initialization -----------------------------
if not input:
import random, math
import itertools, operator, collections
R, P, S = 0, 1, 2
RPS = [R, P, S]
T, W, L = R, P, S
PAYOFFS = [T, W, L]
scorep = [0, 1, -1]
to_win = [W, T, L]
convert = {'R':R, 'P':P, 'S':S, R:'R', P:'P', S:'S'}
subh = [[T, L, W], [W, T, L], [L, W, T]]
addh = [[R, P, S], [P, S, R], [S, R, P]]
ties, beats, loses = addh[T], addh[W], addh[L]
POWER3 = [3 ** n for n in xrange(10)]
op_hands = []
my_hands = []
payoffs = []
op_payoffs = []
output = convert[random.choice(RPS)]
# --------------------- turn -----------------------------
else:
last_input, last_output = convert[input], convert[output]
my_hands.append(last_output)
op_hands.append(last_input)
payoffs.append(subh[last_output][last_input])
op_payoffs.append(subh[last_input][last_output])
hands_played = len(op_hands)
# bot initialization after first turn
if hands_played == 1:
switch = False
elif payoffs[-1] == L:
switch = True
if switch:
next_hand = beats[last_input]
else:
next_hand = loses[last_output]
output = convert[next_hand]
```