still having problems with "Nim". using python 2.6.4
Steve Holden
steve at holdenweb.com
Sun Feb 7 10:46:34 EST 2010
Jordan Uchima wrote:
> I have attached the file that the game is on. feel free to modify it to
> make it better. all suggestions are welcome. if you don't want to
> download the file then here's the code:
>
[...]
>
> my problem is that i can't get it to make the players have more than 1
> turn each, it accepts any value for playerChoice, (it is only supposed
> to accept values from 1 to 4), and "x" resets after each turn. i can get
> it to subtract playerChoice from "x", and display the result, which
> should be "x", but, then, "x" resets... by the way, i need this program
> finished by wednesday, Feb. 10, 2010. Please help me!!!
>
The deadline implies an even higher probability that this is homework. I
don't know whether you declared this in your earlier post, but it's
always as well to do so. You've made a substantial effort to solve the
problem though, so I don't mind trying to help. I hope you regard the
following as helpful.
You need a program structure that keeps going until the required
termination condition is reached. One such structure would be:
while sticks_remaining > 1:
taketurn(next_player())
So now you only need a next_player() function that returns alternate
values on successive calls and a taketurn() function that reduces the
number of sticks according to the instructions form the given player.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/
More information about the Python-list
mailing list