Simple RPS plus RNGFloatatiom

AuthorElectraMiner
Submission date2018-04-07 16:04:23.480070
Rating4628
Matches played291
Win rate45.7

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

Source code:

import random
def b(m, o):
    s = m + o
    if s == "RS" or s == "PR" or s == "SP":
        return 1
    if m == o:
        return 0.5
    return 0
if input == "":
    wgw = 0
    tgw = 0
    rgw = 0
    pgw = 0
    wc = 0.9
    gr = True
    m = "R"
else:
    wgw *= wc
    tgw *= wc
    rgw *= wc
    pgw *= wc
    tgw += 1
    wgw += b(m,input)
    rgw += input == "R"
    pgw += input == "P"
    a = wgw / tgw
    gr = random.uniform(0,1) > a
    sgw = tgw - rgw - pgw
    if rgw > pgw and rgw > sgw:
         m = "P"
    elif pgw > sgw:
         m = "S"
    else:
         m = "R"
output = m
if gr:
    output = random.choice(["R","P","S"])