Rock, Paper, Scissors, Lizard, Spock 石头、剪刀、布、蜥蜴、史波克

This is the first game I built in my Python class. It’s classic Rock-Paper-Scissors, plus two extra moves — Lizard and Spock (from The Big Bang Theory). With five moves, each one beats two others and loses to two others, so ties are rare.

How to play: pick your move below; the computer plays one at random; see who wins. Tap 👁 to read the Python code I wrote — it runs for real, right here in your browser.

Each move beats exactly two others:

  • Rock crushes Scissors & Lizard
  • Paper covers Rock & disproves Spock
  • ✌️ Scissors cut Paper & decapitate Lizard
  • 🦎 Lizard eats Paper & poisons Spock
  • 🖖 Spock smashes Scissors & vaporizes Rock

这是我在 Python 编程课上写的第一个游戏。经典的石头剪刀布,多加了两个手势——蜥蜴和史波克(出自美剧《生活大爆炸》)。五种手势,每一种都赢两种、也输给两种,所以很难打平。

怎么玩: 在下面选你的手势,电脑会随机出一个,看谁赢。点 👁 可以看我亲手写的 Python 代码,代码就在浏览器里真的跑起来。

每种手势正好赢两种:

  • 石头 砸碎剪刀、压扁蜥蜴
  • 包住石头、反驳史波克
  • ✌️ 剪刀 剪开布、斩首蜥蜴
  • 🦎 蜥蜴 吃掉布、毒死史波克
  • 🖖 史波克 砸烂剪刀、汽化石头

选一个手势,电脑随机出一个: Pick a move — the computer plays one at random:

👁 看代码 👁 View the code
import random

print("Welcome to Rock, Paper, Scissors")
print("1: Rock")
print("2: Paper")
print("3: Scissors")
print("4: lizard")
print("5: Spock")
Player_Move = int(input("What is your move: "))

if int(Player_Move) == 1:
    print("You played rock!")

elif int(Player_Move) == 2:
    print("You played paper!")

elif int(Player_Move) == 3:
    print("You played scissors!")

elif int(Player_Move) == 4:
    print("You played lizard!")

elif int(Player_Move) == 5:
    print("You played Spock!")
else:
    print("Error check your input")

Computer_Move=random.randint(1,5)

if int(Computer_Move) == 1:
    print("CPU played rock!")

elif int(Computer_Move) == 2:
    print("CPU played paper!")

elif int(Computer_Move) == 3:
    print("CPU played scissors!")

elif int(Computer_Move) == 4:
    print("CPU played lizard!")

else:
    print("CPU played Spock!")

win_state = "Lose"

if Computer_Move == 1:
    if Player_Move == 2:
        win_state = "win"
    if Player_Move == 5:
        win_state = "win"

elif Computer_Move == 2:
    if Player_Move == 3:
        win_state = "win"
    if Player_Move == 4:
        win_state = "win"

elif Computer_Move == 3:
    if Player_Move == 1:
        win_state = "win"
    if Player_Move == 5:
        win_state = "win"

elif Computer_Move == 4:
    if Player_Move == 1:
        win_state = "win"
    if Player_Move == 3:
        win_state = "win"

elif Computer_Move == 5:
    if Player_Move == 4:
        win_state = "win"
    if Player_Move == 2:
        win_state = "win"


# elif Computer_Move == 3 and Player_Move == 1:
#    win_state = "win"




# -------------------------------
if win_state == "win":
    print("you win")

else:
    print("Ha Ha Loser")

评论 Comments 加载中… LOADING…