Python Forum
please help me improve this minigame
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
please help me improve this minigame
#1
Hi, i made this minigame for learning purposes it works fine, but it's too long and i guess there are much more improvements i can make , i am a total beginner
THANK YOU!
in this gamemode (duogame) each player needs to guess the random number between 0 and 10, the player who, guesses the number gains 2 points, the player who guessed a number near the random number gets 1 point, expl: the random number is 7 but you guessed 6 or 8 you have a point, the player who didn't guess the number gain no points
import random


def duogame():
    round = 0
    scores = {}
    n = int(input("plz type the number of rounds you want to play: "))
    roundsleft = [n]
    player1name = input("first player, please enter your name: ")
    player2name = input("second player, please enter your name: ")
    scores[player1name] = 0
    scores[player2name] = 0

    while True:
        Dice = random.randint(0, 10)
        print(player1name, 'turn: ')
        player1 = int(input())
        print(player2name, "turn: ")
        player2 = int(input())
        round += 1
        roundsleft[0] -= 1
        if (player1 and player2) == 911:
            print("Thank you for playing :)")
            print("scores list: ", scores)
            break
        if roundsleft[0] == 0:
            print("game over!, Thanks for playing!")
            print("scores list: ", scores)
            break

        print("round 0")
        if (player1 or player2) > 10:
            print('please enter a number between 0 and 10', player1name or player2name)
        elif player1 == Dice:
            print("you are so lucky", player1name)
            scores[player1name] += 2
        elif player1 == Dice + 1 or player1 == Dice - 1:
            print("too close :)", player1name)
            scores[player1name] += 1
        elif player1 > Dice + 1 or Dice - 1 < player1 < Dice + 1 or player1 < Dice - 1:
            print("better luck next time", player1name)
        if player2 == Dice:
            print("you are so lucky", player2name)
            scores[player2name] += 2
        elif player2 == Dice + 1 or player2 == Dice - 1:
            print("too close :)", player2name)
            scores[player2name] += 1
        elif player2 > Dice + 1 or Dice - 1 < player2 < Dice + 1 or player2 < Dice - 1:
            print("better luck next time", player2name)
        print("the random number is :", Dice)
        print("round", round, "!", roundsleft, "rounds left!")


def normalgame():
    print(" see if you  are lucky or not")
    print(" system will generated a random number between 0 and 10 try to guess the generated number")
    print(" if you want to quit type 911")
    round = 1
    while True:
        Dice = random.randint(0, 10)
        playernumchoise = int(input("guess the number: "))
        round += 1
        if playernumchoise == 911:
            print("Thank you for playing :)")
            break
        if playernumchoise > 10:
            print('please enter a number between 0 and 10')
        elif playernumchoise == Dice:
            print("you are so lucky")
            print("the random number is :", Dice)
        elif playernumchoise == Dice + 1 or playernumchoise == Dice - 1:
            print("too close :)")
            print("the random number is :", Dice)
        elif playernumchoise > Dice + 1 or Dice - 1 < playernumchoise < Dice + 1 or playernumchoise < Dice - 1:
            print("better luck next time")
            print("the random number is :", Dice)

        print("round", round, "!")


try:
    print(" see if you  are lucky or not")
    print(" system will generated a random number between 0 and 10 try to guess the generated number")
    print(" if you want to quit type 911 (for 2 players mode please type both 911)")
    yesno = input("are you going to play alone or with someone else? answer by yes or no: ")
    if yesno == "yes".lower():
        print("in this gamemode each player needs to guess the random number between 0 and 10, ")
        print("the player who guesses the number gains 2 points")
        print("the player who guessed a number near the random number gets 1 point ")
        print("expl: the random number is 7 but you guessed 6 or 8 you have a point")
        print("the player who didn't guess the number gain no points")
        duogame()
    if yesno == "no".lower():
        normalgame()

except ValueError:
    print("you must put a integer nor a character or floats")
except Exception:
    print("something went wrong")
Reply


Messages In This Thread
please help me improve this minigame - by Naito - Jan-21-2019, 10:31 AM
RE: please help me improve this minigame - by Naito - Jan-21-2019, 11:28 AM
RE: please help me improve this minigame - by Naito - Jan-21-2019, 11:47 AM
RE: please help me improve this minigame - by Naito - Jan-21-2019, 03:31 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Minigame Collection with Menu textmonster404 1 3,430 Feb-20-2017, 02:11 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020