Author | JustinF |
Submission date | 2011-06-15 03:19:45.419770 |
Rating | 5183 |
Matches played | 5148 |
Win rate | 47.59 |
Use rpsrunner.py to play unranked matches on your computer.
if input == "":
oppStack = ""
myStack = ""
cycle = [0, 0, 0]
leastProb = 'RSSRRPSPRSRPPSSPPRRRSPSRPRPPPRSSSRSPSPPSRRRPRRSRSSPRPSSSPPPSRPSSRRSPRRPPRPRSRRRRPPPSPSSSRPRSPPRPSRSRSPRRSSPSPSRRPRPPRRSSSSPSSRPPPPRSRRSRPSPPSPRRRRSSRSSPPSSSSRPSRSPRPRRPSRRPPSPPPRPRSPSSPRSSRRRSRPRRRPSPPPPSSRSRSSSPRPPRSPPSRPPRRPRSSPSRSRRSPPRRPSSPSPRPSRRRRSRSPPPPRPPSSSRRPRPSPSPRSSSSRSRPRRSPSSRPPSRSSPRRRPPPRRSPRSRRPSSPPSPSRPSSSPRSPRPPPPSRRSSRPRPRRRRRPRSRSRPPRSSPPRPSPSSSSPPPSPRRSRRSSRSPSRSPPSSRRRPPRPSRPRSSSPSPPRSRPSRRSPPPRRPPSSRPSPRPRPRRRSSSRRRSPSPSSPSRSSRPPPSRSRRPRRPPPPPRSPRSPSSSSSPRRPSRPPSPPRPRPSSRSSRRSRRRRRSPRPPSPRSRSSPPPRRRPSSPRPRSRPSPSRRSRSRPRPPSRSPPRSSSSSRRPPSPSPPPSSPRRSSRPSSPPRSPSRRRPRPSRPPPRRRSRSPRSSPSSRSPPSPPSSSRPRRPRRSSPRSRRPPRRRRPSRSSSPPSRPRSPRRPSPPPPPSSSPSRPPRPPRSRSRRRSSPSPRPSPRRSPPPSRRPRSSRSRPSSRRPPPRPRPPSSPSSSRSSSRRSPSPRRRSRPPRPSPPRRSRRRPSRSPSSPPPPSPRPRSSRPRRRRSPPSRSSSSPRSPSRPSRRPSSRSRRSSSPPRPPPSPSPSSRRSRPRPRSPRSSRPPRRPPPPRRPRPSSSSRSPRRRRRPPSRPSPSPPRSPPPRSRSSRSRSPSSPRPPSRRRSSPRRPRSRPRSSPPSSPSRRPSPSRSRPPPPPSSSSSRRRRPRRSPRPSPRSPPRPPRPRRSRRPSRPSSPSSRSSSPSPPSPPRRSSRRSSPPPRPSRRSRSPR'
turn = 0
else:
oppStack += input
turn += 1
output = leastProb[turn]
# Win, draw, lose
if myStack and oppStack:
if (myStack[-1] == 'R' and oppStack[-1] == 'S') or (myStack[-1] == 'P' and oppStack[-1] == 'R') or (myStack[-1] == 'S' and oppStack[-1] == 'P'):
cycle[0] += 1
elif (myStack[-1] == 'R' and oppStack[-1] == 'R') or (myStack[-1] == 'P' and oppStack[-1] == 'P') or (myStack[-1] == 'S' and oppStack[-1] == 'S'):
cycle[1] += 1
else:
cycle[2] += 1
myStack += output
if cycle[1] >= cycle[0] and cycle[1] >= cycle[2]:
output = {'R': 'P', 'P': 'S', 'S': 'R'}[output]
elif cycle[2] >= cycle[0] and cycle[2] >= cycle[1]:
output = {'R': 'S', 'P': 'R', 'S': 'P'}[output]