Jun-14-2020, 11:58 PM
Hey everyone,
I'm trying to write the darts game "Cricket". If anyone is not familiar with the game it goes like this:
A player needs to hit 15 through 20 and the bullseye 3 times total. Each turn you get 3 darts. If you don't hit 15, 16, 17, 18, 19, 20, or a BE, the dart counts for nothing. If you have already hit one of these numbers 3 times and you hit it again, your player score increases by that number. (Ex: 20 has been hit 5 times, so the 20 block is "closed" out and the player would have 40 points so far).
I'm starting off easy and just using 20 and bullseye for now. The trouble I'm having is that when I run my code I get stuck in an infinite loop even after "closing out" 20 and BE. Any suggestions?
I'm trying to write the darts game "Cricket". If anyone is not familiar with the game it goes like this:
A player needs to hit 15 through 20 and the bullseye 3 times total. Each turn you get 3 darts. If you don't hit 15, 16, 17, 18, 19, 20, or a BE, the dart counts for nothing. If you have already hit one of these numbers 3 times and you hit it again, your player score increases by that number. (Ex: 20 has been hit 5 times, so the 20 block is "closed" out and the player would have 40 points so far).
I'm starting off easy and just using 20 and bullseye for now. The trouble I'm having is that when I run my code I get stuck in an infinite loop even after "closing out" 20 and BE. Any suggestions?
twenty = 0 bullseye = 0 player_score = 0 twenty_close = False bullseye_close = False while twenty_close is False and bullseye_close is False: dart1 = input("Enter dart 1 score: ") if dart1 == 20: twenty += 1 if twenty == 3: twenty_close is True if twenty_close is True and bullseye_full is True: break elif twenty > 3: player_score = player_score + 20 elif dart1 == "BE": bullseye += 1 if bullseye == 3: bullseye_full is True if twenty_close is True and bullseye_close is True: break elif bullseye > 3: player_score = player_score + 50 dart2 = input("Enter dart 2 score: ") if dart2 == 20: twenty += 1 if twenty == 3: twenty_close is True if twenty_close is True and bullseye_close is True: break elif twenty > 3: player_score = player_score + 20 elif dart2 == "BE": bullseye += 1 if bullseye == 3: bullseye_close is True if twenty_close is True and bullseye_close is True: break elif bullseye > 3: player_score = player_score + 50 dart3 = input("Enter dart 3 score: ") if dart3 == 20: twenty += 1 if twenty == 3: twenty_close is True if twenty_close is True and bullseye_full is True: break elif twenty > 3: player_score = player_score + 20 elif dart3 == "BE": bullseye += 1 if bullseye == 3: bullseye_close is True if twenty_close is True and bullseye_close is True: break elif bullseye > 3: player_score = player_score + 50 print("Winner!", player_score)