[Tutor] Rock, Paper, Scissors

Jesus Rodriguez foxandxss at gmail.com
Sat Aug 12 19:00:29 CEST 2006


Hi, i used a list with R, P, S like:

rps = ["Rock", "Paper", "Scissors"]
random.shuffle(rps)
computerObject = rps[0]

Then, the computer pick a random object and i compare my object with
computer's object.

;)

2006/8/11, wesley chun <wescpy at gmail.com>:
>
> > This looks like a fun project to work on.  From
> > reading the description, I feel this would be pretty
> > straight forward game to program.  However, I have no
> > idea how the computer would decide if it wanted a
> > rock, paper, or a pair of scissors.  Any hints?
>
>
> christopher,
>
> this is indeed a *great* exercise... i've been using it since i can't
> remember when... i had it as an exercise in BASIC and Pascal when i
> was in high school, then turned it into an exercise for my C and
> Python courses.  naturally it's also in Core Python.
>
> others have said it and given code already, but this problem breaks
> down into 3 discrete steps:
>
> 1. give values to R, P or S, i.e., an int, char, or some constant
> 2. have the user choose one via its constant
> 3. have the computer choose another -- you will need to randomly pick
> one of the 3 constants
> 4. logic to determine who the "winner" is of if it is a draw
>
> good luck!
> -- wesley
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> "Core Python Programming", Prentice Hall, (c)2007,2001
>     http://corepython.com
>
> wesley.j.chun :: wescpy-at-gmail.com
> python training and technical consulting
> cyberweb.consulting : silicon valley, ca
> http://cyberwebconsulting.com
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060812/dd3294d1/attachment.htm 


More information about the Tutor mailing list