Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rock paper Scissors bot algorithm

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?

like image 951
JanLikar Avatar asked Jan 11 '12 22:01

JanLikar


2 Answers

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]

like image 109
amit Avatar answered Oct 04 '22 18:10

amit


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.

like image 30
john Avatar answered Oct 04 '22 18:10

john