-------- Original-Nachricht -------- > Datum: Tue, 30 Oct 2007 22:08:01 +0900 > Von: John Joyce <dangerwillrobinsondanger / gmail.com> > An: ruby-talk / ruby-lang.org > Betreff: Re: scissors_papers_stone > > On Oct 29, 2007, at 7:53 PM, M. Edward (Ed) Borasky wrote: > > > James Edward Gray II wrote: > >> On Oct 29, 2007, at 6:06 AM, Scissors Paper wrote: > >>> making a game for uni in ruby for the first time, called scissors > >>> papers > >>> stone and wanted to know if you can find out what method your > >>> oppenents > >>> are using before they use and and counter them. > >> This was a Ruby Quiz some time ago: > >> http://www.rubyquiz.com/quiz16.html > >> James Edward Gray II > > > > Hmmm ... reminds me of the old Claude Shannon penny matching > > machine. Isn't rock/paper/scissors the base-three equivalent of > > that? Anyhow, if you can find the Shannon paper, it will give you > > some clues on how to do rock/paper/scissors against a human opponent. > > > Oh but it is so much more than a number game. > It is about timing and has the x-factor of personality like in Poker. > Doesn't make a good computer game. > As "janken" in Japan it is frequently used to settle minor disputes > and make decisions by people of all ages. > Yet, I've never seen a video game version of it in Japan... There is a discussion of this game in the book "The Compleat Strategyst", by J.D. Williams, pp. 98 and following in my (Dover) edition. From the "payoff matrix" of this game, one finds that there is no dominant strategy and that players should play each strategy on a 1:1:1 basis, i.e. choose each of the three symbols with equal probability. But things change if you give different payoffs for different encounters (e.g. three dollars to a player if she or he wins in a stone/scissors encounter, two dollars to a player if she or he wins in a paper/stone encounter, and one dollar to a player if she or he wins in a scissor/paper encounter, ( that situation is discussed in the book "The mathematics of games" by John D. Beasley, Oxford University Press.) If you always chose the same object, your opponent can adapt to that and win over you. So you must mix your choices with some probabilities p_sci,p_sto,p_pap, so that p_sci+p_sto+p_pap=1. Your average gain will be (3*p_sto-p_pap) whenever your opponent shows scissors, (p_sci-2*p_sto) whenever your opponent shows paper, (2*p_pap-3*p_sci) whenever your opponent shows stone. Now, you can't make all these gains positive by choosing the values for p_pap,p_sci,p_sto, as this requires (3*p_sto>p_pap), (p_sci>2*p_sto), (2*p_pap>3p_sto), and thus 6p_sto>2p_pap>3p_sci>6p_sto, that's impossible. But you can achieve that none of the gains is negative, by setting p_sci=1/3, p_pap=1/2, p_sto=1/6. If you vary this strategy, at least one of your gains is negative, and your opponent wins. So it doesn't matter what your opponent does, as long as you play your optimal strategy. On the other hand, your opponent can play it the same way. Thus, nobody wins (on average). How to implement such a game for more general payoffs? Maybe you just use some external linear programming tool like glpk that has Ruby bindings http://groups.google.de/group/ruby-talk-google/browse_thread/thread/11f0a2029ad2bfd3 Best regards, Axel -- Psssst! Schon vom neuen GMX MultiMessenger geh?rt? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger