Код:
from random import choice
YourScore = 0
ComputerScore = 0
MOVES = "камень", "ножницы", "бумага"
while ((YourScore != 3) and (ComputerScore != 3)):
print(f"Текущий счет - Игрок: {YourScore} - Компьютер: {ComputerScore}")
while True:
YourMove = input(
"Ваш ход, введите камень/ножницы/бумага ").strip().lower()
if YourMove in MOVES:
break
ComputerMove = choice(MOVES)
print(f"\nВаш ход: {YourMove}\nХод компьютера: {ComputerMove}\n")
if YourMove == ComputerMove:
print("У вас ничья!")
# Не выйгрывает никто
elif (YourMove == MOVES[0] and ComputerMove == MOVES[1]): # Камень VS Ножницы
print("Вы победили компьютер!")
YourScore += 1
elif (YourMove == MOVES[1] and ComputerMove == MOVES[2]): # Ножницы VS Бумага
print("Вы победили компьютер!")
YourScore += 1
elif (YourMove == MOVES[2] and ComputerMove == MOVES[0]): # Бумага VS Камень
print("Вы победили компьютер!")
YourScore += 1
else:
print("Компьютер вас победил!")
ComputerScore += 1
print()
Могу ещё дать ссылку на PasteBIN
import random
pc1 = int()
pc2 = int()
# 1 - Камень, 2 - Ножници, 3 - Бумага
part_numbers = int(input('Введите количество партий: '))
part_number_default = 0
pc1_count = 0
pc2_count = 0
draw_count = 0
while part_number_default != part_numbers:
rock_paper_scissors = random.randint(1,3)
guess_pc1 = random.randint(1,3)
guess_pc2 = random.randint(1,3)
if rock_paper_scissors == guess_pc1:
pc1_count +=1
elif rock_paper_scissors == guess_pc2:
pc2_count +=1
elif rock_paper_scissors != guess_pc1 and rock_paper_scissors != guess_pc2:
draw_count += 1
part_number_default += 1
# Выводим счет
if pc1_count > pc2_count:
print('Первый компьтер победил!')
elif pc2_count > pc1_count:
print('Второй компьютер победил!')
elif pc1_count == pc2_count:
print('Ничья')
print(pc1_count, ': ', pc2_count, '(Ничей в партиях:', draw_count, ')')
Объяснение:
Выполнены все условия кроме второй компьютер всегда выигрывал( не вижу смысла тогда этой игры) но если нужно то это просто сделать, оставить вывод только выиграша второго пк, убать счет.