Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. print('==============================')
  2. print('-----------Игра Ним-----------')
  3. print('==============================')
  4. print('Сколько камней у вас, столько камней и у бота')
  5. print('Введите изначальное кол-во камней')
  6. nim = int(input())
  7. botnim = nim
  8. step = 0
  9. if nim <= 3:
  10.     print('Вам нужно хотя-бы 4 камня нужно для подолжения игры')
  11.     nim = nim - 9999999999
  12. print('Первый ходит бот')
  13. while nim != 0 or botnim != 0:
  14.     step = step + 1
  15.     if nim == botnim and step == 1:
  16.         nim = nim - 3
  17.         print('Ход ИИ. У вас осталось:', nim)
  18.     elif nim > botnim:
  19.         nim = nim - 3
  20.         print('У вас осталось:', nim)
  21.     else:
  22.         if nim == 1:
  23.             nim = nim - 1
  24.             print('Бот выйграл')
  25.         nim = nim - 2
  26.         if nim <= 0:
  27.             print('Бот выйграл')
  28.     print('Ваш ход')
  29.     nimMinus = int(input())
  30.     if nimMinus > 3:
  31.         print('Можно не больше 3 камней убирать из кучи противника')
  32.         print('Введте число от 1 до 3')
  33.         nimMinus = int(input())
  34.         if nimMinus < 0 or nimMinus > 3:
  35.             print('Я сказал так нельзя')
  36.             print('Введте число от 1 до 3')
  37.             nimMinus = int(input())
  38.             if nimMinus < 0 or nimMinus > 3:
  39.                 print('Ошибка')
  40.                 print('Игра окончена')
  41.                 nim = nim - 9999999999999
  42.     botnim = botnim - nimMinus
  43.     if botnim <= 0:
  44.         print('Вы выиграли')
  45.         break
  46.     print('У бота осталось:', botnim)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement