Reputation: 1306
In my school our teacher is holding a Rock, paper, scissors bot competition. I know how to program in Python, but I have no idea how to program a bot that would have a bigger chance of success than one that randomly selects its weapons. I think it is possible to store all previous moves and then look for patterns in order to defy attacks. Am I going in a right direction? Any ideas?
Upvotes: 10
Views: 7556
Reputation: 51284
Rock Paper Scissors Programming Competition site contains a large number of competing programs (they are even written in python).
If this is your school assignment, it may be considered cheating, because all submitted sources are publicly available. But, then again, they are available to other students too.
Upvotes: 3
Reputation: 178491
It is proven for rock-paper-scissors that a random bot will be at the median of each rank.
Therefore, I'd create a set of bots, each calculating one heuristic and running on the background on parallel. For each turn, each bot will virtually "draw" and check if he had won or lost - if it would have played this turn. Each bot will keep track on how many games it would have won if it played, and how many it would have lost.
One of these bots will be the random attacker.
Each time it is your turn: choose which bot won so far the most [greedy] - and use it.
Using this approach you are guaranteed to be at the top median of your class! [with enough rounds of games of course]
Upvotes: 7
Reputation: 5219
Where might be some potential profit in trying to figure out the strategies of the other bots, for instance, if it's a forced participation, there will be some lazy student who makes up a bot that would always throw up scissors.
I propose another strategy (I've heard about it on some similar competition, but can't track the source anymore), suppose that you could let several bots running (if not, cooperate with some of your classmates to run this strategy).
Let's say you have 4 bots A,B,C,D
Imagine each bot play 100 times against the others. Let your B,C,D bots play for the first let's say 10 times play a strategy that would let recognise it as a bot from your team, say 'RPPSPPSSRS', let your A bot play some other strategy that would let it be recognized by the bots B,C,D.
Then, in the next 90 round let the bots B,C,D lose ('paper') to the A and play random against the others. Let the bot A win ('scissors') from the B,C,D and play random against the others.
Thus, the bot A gets a huge advantage.
Upvotes: 0
Reputation: 3103
If you are playing against humans, you are on the right track. Storing previous moves is key. Here are two articles that will prove helpful to you. How to win at rock, paper, scissors. And wikipedia's entry on strategy and algorithms.
Upvotes: 3