Python Forum
Two Dice Pig Game in Python 3.6 Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Two Dice Pig Game in Python 3.6 Help
#5
You really need two while loops. The first/outer while loop is for the game, and continues until one player gets over 100. Note that your current while loop doesn't do that. Your loop will keep playing until both players get over 100.

The second/inner loop is for the player's turn. That keeps going until they say "stop" or roll a 1. You want to roll the dice at the top of that loop, then check for the 1 and either break or add it to a variable keeping track of the turn score, then ask if they want to keep going. At the end of the loop update that player's total turn score.

How you handle the two players is up to you. You could have a copy of the second loop that handles the second player, or a for loop between the two while loops that loops through the two players. Although based on the instructions your teacher is expecting a for loop. Of course, you could eliminate the for loop and just change the turn variable each time through the outer while loop. You would then need a conditional to see whether to ask (for the human player) or just keep going (for the computer player).

Personally, I don't like this version of two-die pig. You have a 10 in 36 chance of losing the turn score, compared to a 6 in 36 chance in standard one-die pig. Plus the 1 in 36 chance of losing your whole score. But it's what your teacher chose.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Two Dice Pig Game in Python 3.6 Help - by ichabod801 - Oct-10-2018, 01:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need some help with Dice Game for daughter in school OptX 2 2,679 Feb-12-2021, 08:43 PM
Last Post: BashBedlam
  regarding dice game hola123 4 3,171 Feb-10-2021, 11:00 PM
Last Post: hola123
  Two dice Game of Pig help elliemehl 2 5,639 Feb-14-2019, 01:19 AM
Last Post: woooee
  help with while loop on dice game sean5 2 5,093 Dec-14-2017, 07:24 PM
Last Post: nilamo
  dice game im stuck sylerr 3 5,516 May-12-2017, 10:50 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020