geekcomputers / geekcomputers/Python

I am stuck with my Rock, Paper, Scissors python game

Đang mở
#688 13 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
35.4k
Fork
12.9k
Merge trung bình
2 giờ 37 phút
Pull request đã merge (30 ngày)
1

Mô tả

I am new to GitHub so if I have posted this help request in the wrong place please let me know. I am trying to make rock, paper, scissors in python without googling the answer and I have come across an issue. I am playing around with it and the only option the computer is picking is Rock. It will not pick paper or scissors, no matter what the user inputs. Yesterday it was working fine and the computer would randomly pick something but now it only picks the number 1 or Rock, can anyone see why this is happening? Have I put some code in wrong which is causing this to happen? All help is grateful. This is my code, the def main(): and while True have not been added to the code area for some reason but in the python code they are indented properly and everything so I do not believe they are the problem.

import time
import random
def main():
while True:

    computer = random.randint(1,3)
    user = input("Rock, Paper, Scissors, SHOOT!  ")

    if computer == 1 and user == "Rock" or user == "rock":
        print("I pick Rock!")
        time.sleep(0.5)
        print("Tie")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif computer == 1 and user == "Paper" or user == "paper":
        print("I pick Rock!")
        time.sleep(0.5)
        print("You win")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif computer == 1 and user == "Scissors" or user == "scissors":
        print("I pick Rock!")
        time.sleep(0.5)
        print("I win!")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")

    elif computer == 2 and user == "Rock" or user == "rock":
        print("I pick Paper!")
        time.sleep(0.5)
        print("I win!")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif computer == 2 and user == "Paper" or user == "paper":
        print("I pick Paper!")
        time.sleep(0.5)
        print("Tie!")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif computer == 2 and user == "Scissors" or user == "scissors":
        print("I pick Paper!")
        time.sleep(0.5)
        print("You win")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")

    elif computer == 3 and user == "Rock" or user == "rock":
        print("I pick Scissors!")
        time.sleep(0.5)
        print("You win!")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif computer == 3 and user == "Paper" or user == "paper":
        print("I pick Scissors!")
        time.sleep(0.5)
        print("I win")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif computer == 3 and user == "Scissors" or user == "scissors":
        print("I pick Scissors!")
        time.sleep(0.5)
        print("Tie!")
        time.sleep(0.5)
        print("Either play again or type Finished to stop!")
    elif user == "Finished" or user == "finished":
        print("Okay!")
        break
    else:
        print("Sorry, that isn't an option I understand... yet.")

main()

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy script Python đã cung cấp từ main() và quan sát các nhánh sử dụng random.randint(1,3). Kiểm tra hành vi đối với các đầu vào Rock, Paper và Scissors ở cả hai dạng viết hoa. Hoàn thành khi trò chơi phản hồi nhất quán với mọi lựa chọn của máy tính và các đầu vào được hỗ trợ của người dùng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
cli
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
20/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.