Posted: Wed Nov 09, 2005 2:36 am Post subject: Rock Paper Scissors Contest
Okay guys, here it is. Make an AI to play Rock-Paper-Scissors using one of the following languages: Java, C++, C, or Turing. I will convert all of the entries into either Java or C++ depending on my mood (simply so I can run all of the tests fairly efficiently.If anyone has a better way of doing this, I'd be more than happy to allow other languages.
Write a function that does the following:
function doRockPaperScissors (last : String) : String
String doRockPaperScissors (String last);
The parameter last will be one of "rock" "paper" "scissors" "none" representing your opponants previous move. The function returns one of "rock" "paper" "scissors", representing your move. 200 games will be played each round, round robin style.
If you choose, you may write to a single in the run directory called "<username>.txt".
It doesn't have to be fancy, complicated or pretty. The winner'll get some bits. There is strategy to rock paper scissors though, I promise.
Submit your entries to me via PM with the subject containing "rock paper scissors". Make sure you tell me what language you're using too. Post here saying that you've submitted (although don't post your entry). You may submit as many times as you want, but only your latest entry will be used for the contest.
The contest will be run on Friday, November 18.
After the contest, I will post all of the source code for the entries. If you don't want your source code posted, don't enter the contest.
Posted: Wed Nov 09, 2005 10:54 am Post subject: (No subject)
Clarification - the AIs are running against each other then?
Too bad that the whole thing is in a function; makes it kind of prohibitive to use neural nets to break the opponent's algorithm.
Posted: Wed Nov 09, 2005 2:45 pm Post subject: Re: Rock Paper Scissors Contest
If anyone has a better way of doing this, I'd be more than happy to allow other languages.
How about if you write a program that listens for a connection on the port whose value is your compsci user number. Whenever a connection is made, you read in one of "rock" "paper" "scissors" "none", and reply with one of "rock" "paper" "scissors", and close the connection, and listen again. That way any language could be used, and you just need to write a program to comunicate with the entrants.
Posted: Wed Nov 09, 2005 4:07 pm Post subject: (No subject)
good idea, but one could flood other ports... so you'd also need to send in some authentication hash
Posted: Wed Nov 09, 2005 6:56 pm Post subject: (No subject)
Alright, you can write as many functions as you want. doRockPaperScissors is the one that'll be called by the test machine (if it calls other functions, that's cool).
Posted: Thu Nov 10, 2005 3:41 am Post subject: (No subject)
Yes, the AI's are running against each other.
0 entries so far.
Posted: Thu Nov 10, 2005 9:24 am Post subject: (No subject)
0 entries so far.
Posted: Thu Nov 10, 2005 10:15 am Post subject: (No subject)
Just to bring the psychological element into the game, you guys should know that I'll be going rock every single time.
%Bart method. "Good ol' rock. Nuthin' beats that! "
function doRockPaperScissors2 (last : string) : string
Posted: Thu Nov 10, 2005 10:19 am Post subject: (No subject)
just to screw with your AI's mind, I'll be throwing "none" once in a while
function doRockPaperScissors2 (last :string):string if Rand.Int (0, 10)=10then result"none" else result"paper"%because paper beats codemage's rock endif end doRockPaperScissors2
Posted: Fri Nov 11, 2005 11:37 am Post subject: (No subject)
I am sorry I dont get it. I think its either really easy or really hard. Pardon my code if its stupid because I dont understand the problem clearly. By the ways, what beats "none"?
fcn doRockPaperScissors3 (last :string):string if Rand.Int (1, 20)=14then result"NONE" elsifStr.Upper(last)="ROCK"then result"PAPER" elsifStr.Upper(last)="PAPER"then result"SCISSORS" else result"ROCK" endif end doRockPaperScissors3
Posted: Fri Nov 11, 2005 11:43 am Post subject: (No subject)
I think you misunderstood the purpose of :last -- it is the value from the last match, and it could be used for statistics.
So in the first game every function is passed "none", since no previous moves were made. During the 2nd game, :last will be what your opponent chose in game 1.
So your running statistic is like
You also know that you opponent knows
because "paper" is what you chose in game 1. You opponent lost, you have 1 win. Based on all of this information, what will you choose now?
Posted: Fri Nov 11, 2005 1:02 pm Post subject: (No subject)
Think of the real life game. Most players choose the symbol for the current round based on the results of the last round, especially what the other player picked.
ie, common move is to pick the thing would've been beaten by your opponent's last symbol - b/c people don't repeat symbols as often as they pick new ones.
You picked rock last round, I'm picking scissors b/c I don't think you're going to go rock twice in a row.
Unless you're like me and always pick rock, because rock always wins.
RPS is all about psychology (and trash talk) unless you're picking things completely at random.
Posted: Fri Nov 11, 2005 1:24 pm Post subject: (No subject)
it is all about psychology. With a little bit of luck of some reasoning I once beat my brother in RPS 5~6 times in a row. He was getting really frustrated over such an outcome, and I think that was contributing to me being able to guess at what he was more likely to choose.
now here's the thing -- when its all computers, there's no psychology. There are no facial expressions, or trashtalk or funny costumes. Can't watch a player for a tell, or perform fancy hand gestures to confuse an opponent.
chances are that half the submissions will be as simple as Rand.Int() what then?
Posted: Fri Nov 11, 2005 2:24 pm Post subject: (No subject)
Right you are. Angry people, for instance, tend to throw rock. (It's an aggressive move; who would contemplate throwing a paper as a sign of rage).
With computers, assuming an opponent isn't going random, it's possible to do better than 30% if you can figure out and break their algorithm.
Posted: Fri Nov 11, 2005 2:32 pm Post subject: (No subject)
well if they are going random, you could try to figure out their seed that would require a very large sample though