Sunday 15 April 2012

python - "Sudden Death" function loops more than once before actually doing anything -


In my code there is a problem with a function and a loop; Actually the issue is that the "sundeeth" function is only a Run the bar and end the game. Although it loop approximately 3-5 times and then the game ends

Here is the pastebin link for the full code:.

However, this function is the cause of the problem:

  def suddendeath (): global charone_strength global chartwo_strength print "\ n =========== = "Print" sudden death "print" \ N "+ str (charone) + 'has been rolled:" PLAYER1 time.Sleep (0.5) print "\ n" + str (chart two) + "is rolled:", player 2 if player 1 == player 2 : Print "\ nIt's a draw!" Süddeath () if player 1 & gt; player 2: ChartVo_Strength = 0 alif player 2> Player1: charone_s And here's the loop:  
  while charone_strength> 0 or chart_stream> gt: if counter == 220: print " \ NThey reached deadline of 200 rupees! Suddendeath () and: mods () Action (charone_strength, chartwo_strength, charone_skill, chartwo_skill, strength_mod, skill_mod) and: charone_strength & lt if; = 0: "died "Print" \ n "+ str (charone) +, chartwo," wins! "Time.sleep (1) elif chartwo_strength & lt; = 0: Print "\ n" + str (chartwo) + "is dead!", Charon, "Win!" Execfile ("GCSE.") In ["yes", "y", "yeah", "y"] if play playing time.sleep (1) = raw_input ("you want to play y / n :?") again. Py ") Other: Print" Goodbye! Thank you for playing! "Exit ()  

I first recommend reading the full code, but any insights and further on solving this issue The assistance will be appreciated. Cheers :)

If suddendeath is considered to finish the game, So you should exit the loop after executing it, for example:

  ... if counter == 220: print "\ n router has reached 220, sudden death mode Active! "  

The problem is that the else of while will not be executed if break is where As far as I understand, this code should be executed in any case, so type it without while any else .

There are other problems, such as counter is not being defined or updated anywhere, but I think you are not posting a complete work code.

Edit: Ignore this answer, just leave it for history. The real problem appears in the situation

  while charone_strength & Gt; 0 or chart_stream and gt; 0:  

which should be

  while charone_strength & gt; 0 more char_streams & gt; 0:  

Therefore the players reach a power 0 and both of them.


No comments:

Post a Comment