zlib_compression

AuthorToblich
Submission date2016-04-05 08:58:56.665740
Rating3350
Matches played411
Win rate33.82

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

Source code:

from random import choice
from zlib import compress

if input == "":
	anteriores = ""
	output = choice(["R", "P", "S"])
else:
	anteriores += input
	r = len(compress(anteriores + "R"))
	p = len(compress(anteriores + "P"))
	s = len(compress(anteriores + "S"))
	if r < p and r < s:	# Shorter length means higher probability
		output = "P"	# Paper beats Rock
	elif p < s:
		output = "S"	# Scissors beats Paper
	else:
		output = "R"	# Rock beats Scissors