LAST RULES UPDATE: See This Post Post for Live Tournament Info!MotivationRock-Paper-Scissors is a popular game all over the world. Let's have a competition where you get to build your own program that plays Rock-Paper-Scissors! If you don't know how the game works, you can read about it here. The interesting thing about this game is that if you play completely randomly, on average you will do as well as your opponent, regardless of what your opponent does (i.e. you will win 33% of the time, lose 33% of the time, and tie 33% of the time). However, in practice the game is usually not completely random, because human players don't play randomly, and try to psychologically out-smart their opponents. That way it's actually a fun game! But don't worry: we'll use a mechanism to prevent you from making a random bot to spoil the fun! So let's get to the specifics. The ProgramImagine you are playing rock, paper, scissors with someone, and you want to write a computer program to do your next move for you. You need to write a Python procedure (called
Competition RulesThe First TaskYour program will need to play against three programs I build that aren't very smart. It will play 1000 rounds against each of these bots, and we will let you test this (probably on an IDE quiz on our website before submitting your program). In other words, they will probably have patterns in what moves they do, and they won't try to take your program's moves into account. To get to the next level in the competition, your program will need to beat at least two of these programs with a win rate of at least 50% (if it played randomly, it would be around 33% of the time on average). Your code should take no more than 2 seconds to complete 1000 rounds. This is not a strict limit, but try to stay within that range. You can test your program against our bots here! (Note: This may have some bugs. If certain things aren't working, please tell us!) The Second TaskIf your program passes the first task, it will then enter a tournament with all of the other eligible programs. Each match will have approximately 1000 rounds that you won't see followed by a best 7 out of 13 match (i.e. whoever gets 7 wins first, wins the match). The first set of ~1000 rounds will give your algorithm a chance to learn your opponent's behavior. I haven't decided the logistics of the tournament, because it will depend on the number of submissions. Your code should be submitted here by Thursday July 26th at 17:00 UTC. You are allowed to submit two programs. (Thank our friend @areke from CS 253 for the awesome submission form!) There will be a live tournament on Saturday July 28th at 17:00 UTC. The tournament will be hosted on Cloud 9 IDE. I will give you a link to the workspace where you can join us on Saturday before the tournament begins. Check the forums before the tournament to get the link and instructions on what to do! You do not need to sign up for Cloud 9, you just open the link on your browser and enjoy! Final RemarksThis is very experimental. Let us know what you what you think of this tournament, and if you like this idea, and want similar competitions in the future, let us know by voting this post up. Thanks! If you want to test two different programs against each other, you can use the following code. Or you can write your own more elegant code.
showing 10 of 20
show 10 more comments
|
|
Seems like I heard about udacity's rock scissor paper tournament too late. But anyway there is a rock scissor paper tournament ongoing on the net for python programmers at http://www.rpscontest.com Everyone can try their luck there. Be warned though, the rsp bots over there are mean. Some use bayesian analysis, some neural nets, some markov chains, most use fancy meta strategies to decide which of their current strategies to choose... |
|
To make it even funnier, it should be the ˜Rock, Paper, Scissor, Lizard, Spock" game! :) |
|
Dan Egnor's Iocaine Powder is one of the strongest Roshambo bots ever written: The C source code is open sourced: I've always wanted to understand better how it works, so this contest has motivated be to invest a few hours into a Python port: However, there are one or more bugs in my port as I don't believe it is working properly (I don't really know C to begin with). It isn't regularly beating 'good ole rock'. I believe the port is extremely close, but I need one or more fresh set of eyes to find where I went wrong. I'd be grateful if someone could have a look and even submit a pull request to true it up. Thank you. I wrote a bot based on his idea (didn't actually look at the code). It's a shame that I can't use it for the contest seeing that we can't store state. But oh well, at least I learned some cool stuff. https://github.com/JFreegman/Udacity-Stuff/blob/master/buttdestroyer.py The bot sadly isn't allowed to store state so I don't think it will be allowed to be entered... If you managed to do it without it and within 2 seconds, you deserve to be the winner, even if you don't win. My code for this tournament is also based on the same idea as Iocaine Powder. It's choosing from a set of 16 strategies based on how they would have performed in the previous game. The time constraint together with not being allowed to store state was a real challenge. But with a few limitations I actually managed to let it run in just a few seconds for 1000 rounds. And it can even beat your bot @JFreegman, if not by much. ;-) I'm really curious whether it'll be any good in the tournament. @erdman, I've looked at your port and I have to admit I can't quite follow it. :-) I've never done a port myself, so I was wondering if it wouldn't have been easier to make a "word-by-word translation" and add Python idioms later, once you have a running version? Like this it looks highly elaborate and nicely Pythonic but I find it hard to always see the corresponding elements of the two codes, let alone verifying that they're doing the same thing. @Emil, thanks for taking a look. Here are the three biggest differences between my code and the original: (1) He sets off two general sections of the code with comment lines, the stats functions and data structures, and the predict functions and data structures. These fit very nicely into classes, so I just made them classes. (2) The C code relies on a lot of side-effects in his functions. I tried to remove side effects whenever I saw them, as I think they make code harder to understand and debug. You see this change most evident in in the do_history (I renamed match_history, sorry) and scan_predict functions. (3) Finally, I noticed the original do_history had repetitive copy-pasted code; I tried to follow DRY principle, and called the function three times instead. @Emil, btw, does your bot beat the original Iocaine Powder, or have you not been able to test that? @erdman: I haven't tested my bot against Iocaine Powder. I doubt it could beat it as it's really very limited. But if I've done everything right it should at least hold up in a direct match. 1
Actually, greenberg is stronger than iocaine (http://webdocs.cs.ualberta.ca/~darse/rsbpc.html , http://www.mathpuzzle.com/greenberg.c). It is based on Iocaine principle but extended a bit. 1
@Cabuzel, thanks for the link. I didn't know the greenberg source code had been published. I just completed a port of greenberg to Python and added it to the same github repo listed in OP, if anyone wants to mess around with the strongest Roshambo bot ever published. The source is even more opaque than IP, but this port seems to be bug-free. |
echo! echo! is tournament live? |
|
import random def choice(): def choice2(): def player(): |
Are multiple entries per person allowed?
I would also want you to consider setting a given number of iterations for the match and make it public. This is, if both players will play 1000 times as in the previous example, or 1e4 / 1e6 / 1e9 etc.
That would allow as to know (by input's length) how far we are in the match.
I would compare it to human vs human RPS tournaments where they play agains the other i.e. 10 times, or to any sports when they are given i.e. 90 minutes (scoccer) or a given structure of set and games (tennis).
@Jin You are allowed two submissions. This is updated in the post.
@Marcos Manuel When you play against the bots in the first task it will be 1000 rounds. When you play against programs your peers have built, it will be best 5 out of 9 (i.e. first to 5 wins). This is to build excitement, but if people strongly disagree with this, I can change it. Sorry for not being clear on rules earlier! This is very experimental!
I strongly disagree with the 5 out of 9 aspect. See my answer below.
Is there a time limit? Since we're not allowed to store state, my agent has to re-do a lot of work each move, which takes a while...
@Johannes the rules have been updated, so your agent is given his set of previous moves. There is also a time limit of 2 seconds for 1000 rounds.
What should we name our program? 'player', or whatever we choose?
There seems to be a bug with the submission form. Both the 'View your first entry' and 'View your second entry' buttons link to the second entry. As a result of this, I cannot edit my first entry. Am I the only one with this problem? Please fix this!
I'm sorry about this problem, but I don't think it was because of me... My deployed version at arekelive.appspot.com doesn't seem to have this problem. @Shayan, @Anthony Try making sure that both your_entry, and your_entry2 are passed into the template and that the url for the first one is "/{{your_entry}}" and the second is "/{{your_entry2}}". It shouldn't be too hard of a fix.
can we use functions inside of our function player()? and why aren't we allowed to store state? Not doing so requires redoing tons code and makes it take a while... Storing state makes it much, much quicker...
Saturday, July 24th 21:28 UTC? Should be Tuesday!! or July 21th!!
@areke @Manuel Vidaurre You cannot keep state. I'm sorry about this, but it's too late to change that now. I'll update the rules to make it more obvious. You can use functions inside of
player. All of your code should be inside ofplayer.@Manuel Vidaurre Thanks for pointing that out!
Does it have to be within 2 seconds? Without storing state it takes much longer... Maybe even 15-20 seconds...
@areke I would say that's too long. Try to get it down to less than 4 seconds or so. You might have to sacrifice your program's ability, but everyone has the same limitations. Sorry! You should keep your program though, in case we have a discussion about the best programs later on.
Ok, I'll try my best.
Are you able to say what the range of the number of games are? Like 750-1250 where the number of games won't go below 750, and won't go above 1250.
@Shayan Doroudi: You said that all code should be inside of player. If my program has additional functions and imports outside of player(), and passes Task 1, will it be accepted? And if not, why?
Really, what should we name our function, 'player', or whatever we want? I need to know before it is due!
I named it player like in the quiz... I don't know if this is correct because there were no specifications.