Как мне сделать цикл повторного воспроизведения игры? Могут ли игроки не видеть ответы друг друга или добавлять одновременно? Это ремейк Strategy Steps, Wii Party, и я хочу спросить (в конце), хочет ли игрок снова сыграть в эту игру.
import time
def game():
welcome = input("Welcome to Wii Party: Strategy Steps! Would you like to know how to play this game? Type 'yes' or 'no': ")
if welcome == "Yes" or welcome == "yes":
time.sleep(1)
print("Two players choose between three numbers (1,3,5).\nIf a player selects the same number as another player, both players stay where they are.\nIf both numbers are different, the players will move up in accordance to the number they have selected.\nFor example, if players 1-3 (in 4 player situation) choose 3 and player 4 chooses 5, player 4 will move up by 5 steps but players 1-3 will stay where they are.\nThere are 20 steps altogether.\nThe first player to reach the top of the staircase is the winner.")
else:
time.sleep(1)
print("Let's move on!")
totalsteps = 20
player1position = 0
player2position = 0
options = [1, 3, 5]
while player1position < totalsteps and player2position < totalsteps:
player1choice = int(input("Player 1, choose a number between 1, 3 and 5: "))
while player1choice not in options:
print("That is not one of the options. Try again.")
player1choice = int(input("Player 1, choose a number between 1, 3 and 5: "))
if player1choice in options:
break
else:
pass
time.sleep(1)
player2choice = int(input("Player 2, choose a number between 1, 3 and 5: "))
while player2choice not in options:
print("That is not one of the options. Try again.")
player2choice = int(input("Player 2, choose a number between 1, 3 and 5: "))
if player2choice in options:
break
else:
pass
if player1choice != player2choice:
player1position += player1choice
player2position += player2choice
print("Player 1 has moved up ", player1choice, "steps and is now on step", player1position,"!")
time.sleep(1)
print("Player 2 has moved up ", player2choice, "steps and is now on step", player2position,"!")
else:
time.sleep(1)
print("The same number was picked so no one moved")
if player1position >= totalsteps:
print("Player 1 wins!")
break
elif player2position >= totalsteps:
print("Player 2 wins!")
break
game()
Подробнее здесь: https://stackoverflow.com/questions/791 ... ing-a-game
Повтор игры ⇐ Python
Программы на Python
1729532284
Anonymous
Как мне сделать цикл повторного воспроизведения игры? Могут ли игроки не видеть ответы друг друга или добавлять одновременно? Это ремейк Strategy Steps, Wii Party, и я хочу спросить (в конце), хочет ли игрок снова сыграть в эту игру.
import time
def game():
welcome = input("Welcome to Wii Party: Strategy Steps! Would you like to know how to play this game? Type 'yes' or 'no': ")
if welcome == "Yes" or welcome == "yes":
time.sleep(1)
print("Two players choose between three numbers (1,3,5).\nIf a player selects the same number as another player, both players stay where they are.\nIf both numbers are different, the players will move up in accordance to the number they have selected.\nFor example, if players 1-3 (in 4 player situation) choose 3 and player 4 chooses 5, player 4 will move up by 5 steps but players 1-3 will stay where they are.\nThere are 20 steps altogether.\nThe first player to reach the top of the staircase is the winner.")
else:
time.sleep(1)
print("Let's move on!")
totalsteps = 20
player1position = 0
player2position = 0
options = [1, 3, 5]
while player1position < totalsteps and player2position < totalsteps:
player1choice = int(input("Player 1, choose a number between 1, 3 and 5: "))
while player1choice not in options:
print("That is not one of the options. Try again.")
player1choice = int(input("Player 1, choose a number between 1, 3 and 5: "))
if player1choice in options:
break
else:
pass
time.sleep(1)
player2choice = int(input("Player 2, choose a number between 1, 3 and 5: "))
while player2choice not in options:
print("That is not one of the options. Try again.")
player2choice = int(input("Player 2, choose a number between 1, 3 and 5: "))
if player2choice in options:
break
else:
pass
if player1choice != player2choice:
player1position += player1choice
player2position += player2choice
print("Player 1 has moved up ", player1choice, "steps and is now on step", player1position,"!")
time.sleep(1)
print("Player 2 has moved up ", player2choice, "steps and is now on step", player2position,"!")
else:
time.sleep(1)
print("The same number was picked so no one moved")
if player1position >= totalsteps:
print("Player 1 wins!")
break
elif player2position >= totalsteps:
print("Player 2 wins!")
break
game()
Подробнее здесь: [url]https://stackoverflow.com/questions/79111121/replaying-a-game[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия