best_move_4

This program has been disqualified.


Authorjfp
Submission date2011-06-09 21:56:03.106439
Rating0
Matches played2
Win rate0.0

Source code:

import random

if input == "":
  # Initialization.
  stats = { 
      "R": {"W": 1, "L": 1, "D": 1}, 
      "P": {"W": 1, "L": 1, "D": 1}, 
      "S": {"W": 1, "L": 1, "D": 1}
      }   
  rounds = 0 
else:
  # Update statistics based on previous move.
  stat = stats[output]
  if output == "R":
    if input == "S":
      stat["W"] += 1
    elif input == "P":
      stat["L"] += 1
    else:
      stat["D"] += 1
  elif output == "P":
    if input == "R":
      stat["W"] += 1
    elif input == "S":
      stat["L"] += 1
    else:
      stat["D"] += 1
  elif output == "S":
    if input == "P":
      stat["W"] += 1
    elif input == "R":
      stat["L"] += 1
    else:
      stat["D"] += 1
  rounds += 1

algo = random.choice([0, 1, 2])
if  algo == 0:
  # Play randomly.
  output = random.choice(["R", "P", "S"])
elif algo == 1:
  # Play the move that would have won last time.
  if input == "R":
    output = "P"
  elif input == "P":
    output = "S"
  else:
    output = "R"
elif algo == 2:
  # Play the same move again.
  output = output