Learn to Program with Python 3: A Step-by-Step Guide to Programming by Irv Kalb

Learn to Program with Python 3: A Step-by-Step Guide to Programming by Irv Kalb

Author:Irv Kalb [Irv Kalb]
Language: eng
Format: epub
Publisher: Apress
Published: 2018-09-25T00:00:00+00:00


Playing a Game Multiple Times

In most computer games, when one round of the game is over, you get the option to play again. In the output at the beginning of this chapter, I showed this option for our Guess the Number game. On a conceptual level, playing a game multiple times can be thought of as each round of the game in a loop. That is, we can build an outer loop to play multiple games, and an inner loop that plays a round within each game.

There are two possible implementations. If the game is simple enough, you can build a loop within a loop. Here is the pseudocode:#

Playing multiple games loop

Play multiple rounds of the current game

Play a round or move within a game

Ask if the user wants to play again, if not, exit



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.