# Scissors\_papers\_stone

**URL:** <https://www.ruby-forum.com/t/scissors-papers-stone/118603>\
**Category:** Ruby\
**Created:** [October 29, 2007, 12:06pm UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603 "2007-10-29T12:06:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [October 29, 2007, 12:06pm UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/1 "2007-10-29T12:06:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [October 29, 2007, 12:58pm UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/2 "2007-10-29T12:58:52Z")

</div>

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.  
> That depends on the implementation - are you playing against other  
> people on the network, at the same machine, against the CPU, or some  
> other manifestation?

---

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [October 29, 2007, 1:14pm UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/3 "2007-10-29T13:14:40Z")

</div>

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 Q. some time ago:

[Ruby Quiz - Paper Rock Scissors (#16)](http://www.rubyquiz.com/quiz16.html)

James Edward G. II

---

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [October 30, 2007, 2:10pm UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/4 "2007-10-30T14:10:06Z")

</div>

On Oct 29, 2007, at 7:53 PM, M. Edward (Ed) Borasky wrote:

> 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…

---

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [October 31, 2007, 1:33am UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/5 "2007-10-31T01:33:04Z")

</div>

John J. wrote:

> > > [Ruby Quiz - Paper Rock Scissors (#16)](http://www.rubyquiz.com/quiz16.html)  
> > > 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’s a similar Italian game (I’ve forgotten the name) that involves  
one, two or three fingers. That one I’m pretty sure is in “The Compleat  
Strategist”.

---

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [October 30, 2007, 1:57am UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/6 "2007-10-30T01:57:02Z")

</div>

James Edward G. II wrote:

> James Edward G. 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.

---

<div class="post-metadata">

**Author:** ![scissors\_papers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@scissors\_papers](https://www.ruby-forum.com/u/scissors_papers)\
**Post date:** [November 1, 2007, 5:55pm UTC](https://www.ruby-forum.com/t/scissors-papers-stone/118603/7 "2007-11-01T17:55:47Z")

</div>

-------- Original-Nachricht --------

> Datum: Tue, 30 Oct 2007 22:08:01 +0900  
> Von: John J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: removed\_email\_address@domain.invalid  
> Betreff: Re: scissors\_papers\_stone

> > > This was a Ruby Q. some time ago:  
> > > 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](http://groups.google.de/group/ruby-talk-google/browse_thread/thread/11f0a2029ad2bfd3)

Best regards,

Axel
