Computer Science Canada Rock Paper Scissors Contest |
Author: | Martin [ 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: Turing:
Java:
etc. 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. Here's an example to get you started.
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. |
Author: | codemage [ Wed Nov 09, 2005 10:54 am ] |
Post 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. |
Author: | beard0 [ Wed Nov 09, 2005 2:45 pm ] |
Post subject: | Re: Rock Paper Scissors Contest |
Martin wrote: 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. |
Author: | Tony [ Wed Nov 09, 2005 4:07 pm ] |
Post subject: | |
good idea, but one could flood other ports... so you'd also need to send in some authentication hash |
Author: | Martin [ Wed Nov 09, 2005 6:56 pm ] |
Post 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). |
Author: | Martin [ Thu Nov 10, 2005 3:41 am ] |
Post subject: | |
Yes, the AI's are running against each other. 0 entries so far. |
Author: | beard0 [ Thu Nov 10, 2005 9:24 am ] | ||
Post subject: | |||
Martin wrote: 0 entries so far.
|
Author: | codemage [ Thu Nov 10, 2005 10:15 am ] | ||
Post subject: | |||
Just to bring the psychological element into the game, you guys should know that I'll be going rock every single time.
|
Author: | Tony [ Thu Nov 10, 2005 10:19 am ] | ||
Post subject: | |||
just to screw with your AI's mind, I'll be throwing "none" once in a while
|
Author: | MysticVegeta [ Fri Nov 11, 2005 11:37 am ] | ||
Post 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"?
|
Author: | Tony [ Fri Nov 11, 2005 11:43 am ] |
Post 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 "none" "rock" You also know that you opponent knows "none" "paper" 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? |
Author: | codemage [ Fri Nov 11, 2005 1:02 pm ] |
Post 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. |
Author: | Tony [ Fri Nov 11, 2005 1:24 pm ] |
Post 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? |
Author: | codemage [ Fri Nov 11, 2005 2:24 pm ] |
Post 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. |
Author: | Tony [ Fri Nov 11, 2005 2:32 pm ] |
Post subject: | |
well if they are going random, you could try to figure out their seed ![]() ![]() |
Author: | MysticVegeta [ Fri Nov 11, 2005 7:19 pm ] |
Post subject: | |
this is... impossible.... in 1 function ![]() |
Author: | rizzix [ Fri Nov 11, 2005 9:08 pm ] |
Post subject: | |
well not with a function of that signature.. (string -> string) |
Author: | Hikaru79 [ Sat Nov 12, 2005 7:53 pm ] |
Post subject: | |
Randomness is often the best way to go, at least against human competitors! In the 2003 Paper-scisors-rock World Championship, which was held that year in Jerusalem, a 13-year-old boy won the $300,000 grand prize. How'd he do it? Everyone else was coming up with l33t mind-reading strategies and double-think. The little boy did something simpler -- he converted Pi to base-3, and memorized the consecutive digits up until a point, and then used those as his throws (starting where he left off from the last game). The trick is that we humans are never *truly* random, and we can be double-guessed. The kids strategy was, however, random (for anyone who didn't know about his trick), and he won. ![]() |
Author: | MysticVegeta [ Sat Nov 12, 2005 9:18 pm ] |
Post subject: | |
Hold on a second, There are Rock-Paper-Scissors contests?? hmm randomization (i dont think its a word) wusing pies, i can only think about eating pies right now lol. Yeah, Also i agree that random strings is the only way to go, but I read Hacker Dan's post before about how the computers have algorithms to generate random #s, is it ever possible to decode that? |
Author: | Hikaru79 [ Sat Nov 12, 2005 10:08 pm ] |
Post subject: | |
MysticVegeta wrote: Hold on a second, There are Rock-Paper-Scissors contests??
Oh, yeah. They have world championships, leagues, professional players, the works ![]() |
Author: | Tony [ Sun Nov 13, 2005 2:44 am ] |
Post subject: | |
MysticVegeta wrote: the computers have algorithms to generate random #s, is it ever possible to decode that?
computers don't generate random numbers. There are algorithms that generate numbers from a seed that appear to be random. Though if the same seed was to be supplied to the function, identical output will be produced. The seed is usually taken from system's time variable, and modified by the generated output of the previous number. I would imagine that it could be possible to guess at the seed, over a very large output sample, requiring massive processing power. One would have to know the process of seeding though. Of course if the program was to reset its seed to system's time during the run, the attempt will be pointless. |
Author: | Hikaru79 [ Sun Nov 13, 2005 10:57 am ] |
Post subject: | |
True, but there used to be computers that WERE able to produce truly random numbers, until manufacturers stopped implementing the technology. Smells of an NSA conspiracy, but whatever. Read this blog post to see what I mean. |
Author: | MysticVegeta [ Sun Nov 13, 2005 12:54 pm ] | ||
Post subject: | |||
hmm i have a doubt about turing random # generation algorithm. try this :
Now Keep on pressing F1 fast. There are so many times when the Random #s are same. I think that has something to do with the milliseconds taken to execute or some value that doesnt change on a quick basis. Try it, dont you think? |
Author: | Martin [ Sun Nov 13, 2005 8:37 pm ] |
Post subject: | |
http://en.wikipedia.org/wiki/Rock,_Paper,_Scissors Presents from above. |
Author: | md [ Sun Nov 13, 2005 10:08 pm ] |
Post subject: | |
From what I remember reading in the linux kernel config intel (and someone else) do indeed put hardware random number generators in some of their products (I happen to have one... I think... I should really check). Besides even if you don't have a computer that comes stalk with a random number generator it's not like it's hard... just point a webcam at teh sky, and use a hash of whatever it captures as your seed; reset the seed 30 times a second and you're done! |
Author: | Martin [ Mon Nov 21, 2005 7:58 pm ] |
Post subject: | |
Alright guys, give me another week. I'll have the results for monday. My computer didn't come through yet, so yeah. |
Author: | Mazer [ Mon Nov 21, 2005 10:06 pm ] | ||
Post subject: | |||
MysticVegeta wrote: hmm i have a doubt about turing random # generation algorithm.
try this :
Now Keep on pressing F1 fast. There are so many times when the Random #s are same. I think that has something to do with the milliseconds taken to execute or some value that doesnt change on a quick basis. Try it, dont you think? I've explained it many times over the years. Try looking up "random number seeds", it has to do with what time it is when you run the program. |
Author: | Martin [ Sat Nov 26, 2005 9:47 am ] |
Post subject: | |
Alright guys, tomorrow's the day. Although I have a few entries, there aren't nearly enough. It's incredibly easy to make a program, anyone can join. So please. Have fun. ![]() |
Author: | Martin [ Mon Nov 28, 2005 6:59 pm ] |
Post subject: | |
If nobody else is going to enter, I'm posting the results tonight. |
Author: | Hikaru79 [ Mon Nov 28, 2005 10:13 pm ] | ||
Post subject: | |||
Hm, I kinda missed out on this one ![]()
![]() |
Author: | Martin [ Mon Nov 28, 2005 11:31 pm ] |
Post subject: | |
Ah, good idea. Alright, we'll do that then. This contest's off. Thanks to both of the entrants... |
Author: | Hikaru79 [ Tue Nov 29, 2005 4:08 pm ] |
Post subject: | |
Martin wrote: Ah, good idea. Alright, we'll do that then. This contest's off. Thanks to both of the entrants...
Oops ![]() |