Discreteproject
Discreteproject
March 3, 2024
[ ]: import random
from words import words
from hangman_visual import lives_visual_dict
import string
def WelcomeFunc():
print('\n')
print('Hello!!!')
print("Welcome to Taylor's Fun House!!!")
print("This Fun House gives you the option to play some of the best mini␣
↪games ever created and eat some great food!!")
print('First option of the Fun House is deciding if you would like to go␣
↪eat or play games!')
print("When selecting the game you want to play, next to it, it will have␣
↪(vs. CPU or vs. USER) CPU being computer and USER being against another␣
↪player")
print("Just make sure you pick the one thats best for you!!")
print("Each game will have its own rules and instrunctions upon entering␣
↪each one")
1
def FoodMenu():
print('\n')
print("Welcome to the Buffet at Taylor's Fun House!!!")
print("A menu will be presented to you, choose a drink, a main meal and␣
↪desert")
print("Remember you have $12 total to start, make sure you dont go over it!
↪")
print('\n')
print('---HERE IS OUR DRINK MENU---')
print('----------------------')
print('DRINKS: ')
print('1. Water $1.00 ')
print('2. Soda $2.50 ')
print('3. Coffee $2.00 ')
print('4. Tea $2.00 ')
print('5. Juice $2.00 ')
print('Please enter a number (1-5) of what drink you would like')
drink_choice = int(input("Drink Selection: "))
drink_var = ""
while drink_choice > 5 or drink_choice < 1:
drink_choice = int(input("You have entered a invalid option. Enter␣
↪valid input: "))
if drink_choice == 1:
print('You have selected: Water')
drink_bill = 1.00
print ("Total Bill: $ " + str(drink_bill))
drink_var = "Water"
elif drink_choice == 2:
print('You have selected: Soda')
drink_bill = 2.50
print ("Total Bill: $ " + str(drink_bill))
drink_var = "Soda"
elif drink_choice == 3:
print('You have selected: Coffee')
drink_bill = 2.00
print ("Total Bill: " + str(drink_bill))
drink_var = "Coffee"
elif drink_choice == 4:
print('You have selected: Tea')
drink_bill = 2.00
print ("Total Bill: " + str(drink_bill))
drink_var = "Tea"
elif drink_choice == 5:
2
print('You have selected: Juice')
drink_bill = 2.00
print ("Total Bill: " + str(drink_bill))
drink_var = "Juice"
else:
print("Please enter a valid input")
print('\n')
print('----------------------')
print('---HERE IS OUR FOOD MENU---')
print('FOOD: ')
print('1. Chicken Tenders $7.00 ')
print('2. Cheeseburger $8.50 ')
print('3. Pizza $6.00 ')
print('4. Mac and Cheese $5.50 ')
print('5. French Fries $3.00 ')
print('6. Salad $5.00 ')
print('7. Grilled Cheese $5.00 ' )
food_choice = int(input("Food Selection: "))
food_var = ""
while food_choice > 7 or food_choice < 1:
food_choice = int(input("You have entered a invalid option. Enter valid␣
↪input: "))
if food_choice == 1:
print('You have selected: Chicken Tenders')
food_bill = 7.00
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
food_var = "Chicken Tenders"
elif food_choice == 2:
print('You have selected: Cheeseburger')
food_bill = 8.50
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
food_var = "Cheeseburger"
elif food_choice == 3:
print('You have selected: Pizza')
food_bill = 6.00
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
food_var = "Pizza"
elif food_choice == 4:
print('You have selected: Mac and Cheese')
food_bill = 5.50
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
3
food_var = "Mac and Cheese"
elif food_choice == 5:
print('You have selected: French Fries')
food_bill = 3.00
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
food_var = "French Fries"
elif food_choice == 6:
print('You have selected: Salad')
food_bill = 5.00
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
food_var = "Salad"
elif food_choice == 7:
print('You have selected: Grilled Cheese')
food_bill = 5.00
total_bill = food_bill + drink_bill
print ("Total Bill: $ " + str(total_bill))
food_var = "Grilled Cheese"
else:
print("Please enter a valid input")
print('\n')
print('----------------------')
print('---HERE IS OUR DESSERT MENU---')
print('DESSERT: ')
print('1. Cake $4.00 ')
print('2. Cupcake $2.50 ')
print('3. Ice Cream $2.00 ')
print('4. Pie $2.00 ')
dessert_choice = int(input("Dessert Selection: "))
while dessert_choice > 7 or dessert_choice < 1:
dessert_choice = int(input("You have entered a invalid option. Enter␣
↪valid input: "))
if dessert_choice == 1:
print('You have selected: Cake')
dessert_bill = 4.00
total_bill = food_bill + drink_bill + dessert_bill
dessert_var = "Cake"
print ("Total Bill: $ " + str(total_bill))
elif dessert_choice == 2:
print('You have selected: Cupcake')
dessert_bill = 2.50
total_bill = food_bill + drink_bill + dessert_bill
print ("Total Bill: $ " + str(total_bill))
dessert_var = "Cupcake"
4
elif dessert_choice == 3:
print('You have selected: Ice Cream')
dessert_bill = 2.00
total_bill = food_bill + drink_bill + dessert_bill
print ("Total Bill: $ " + str(total_bill))
dessert_var = "Ice Cream"
elif dessert_choice == 4:
print('You have selected: Pie')
dessert_bill = 2.00
total_bill = food_bill + drink_bill + dessert_bill
print ("Total Bill: $ " + str(total_bill))
dessert_var = "Pie"
else:
print("Please enter a valid input")
print('\n')
print('----------------------')
if total_bill > 12:
print("You have exceded your funds, please start over. Remember you␣
↪only have $12!")
print('----------------------')
FoodMenu()
else:
print("HORRAYYY! You have successfully purchased everything withtin␣
↪your funds! ENJOY!!")
"""
print('\n')
print('----------------------')
print("You have selected: ")
5
print("Total Cost: ") + str(total_bill)
if total_bill > 15:
print("You have exceded your funds, please start over. Remember you␣
↪only have $15!")
FoodMenu()
else:
print("HORRAYYY! You have successfully purchased everything withtin␣
↪your funds! ENJOY!!")
def RPS():
print('\n')
print('Hello!!! Welcome to the game of Rock Paper Scissors!')
print('PROCEDURE:')
print('1. First, the game will start by the user getting the chance to pick␣
↪an option among rock paper and scissors')
print('2. After that, the computer will select a choice (randomly) from the␣
↪other two')
while True:
print("Enter choice: \n 1. for Rock \n 2. for Paper \n 3. for Scissor␣
↪\n")
6
# initialize value of choice_name variable
# corresponding to the choice value
if choice == 1:
choice_name = 'Rock'
elif choice == 2:
choice_name = 'Paper'
else:
choice_name = 'Scissor'
comp_choice = random.randint(1, 3)
7
else:
print("<== COMPUTER WINS ==>")
def print_tic_tac_toe(values):
print("\n")
print("\t | |")
print("\t {} | {} | {}".format(values[0], values[1], values[2]))
print('\t_____|_____|_____')
print("\t | |")
print("\t {} | {} | {}".format(values[3], values[4], values[5]))
print('\t_____|_____|_____')
print("\t | |")
players = list(score_board.keys())
print("\t ", players[0], "\t ", score_board[players[0]])
print("\t ", players[1], "\t ", score_board[players[1]])
print("\t--------------------------------\n")
8
# Function to check if any player has won
def check_win(player_pos, cur_player):
soln = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 4, 7], [2, 5, 8], [3, 6, 9],␣
↪[1, 5, 9], [3, 5, 7]]
for x in soln:
if all(y in player_pos[cur_player] for y in x):
return True
return False
try:
print("Player ", cur_player, " turn. Which box? : ", end="")
move = int(input())
except ValueError:
print("Wrong Input!!! Try Again")
continue
if move < 1 or move > 9:
print("Wrong Input!!! Try Again")
continue
values[move-1] = cur_player
9
player_pos[cur_player].append(move)
def TTToe():
print('\n')
print('----------------------')
print('Hello!!! Welcome to the game of Tic-Tac-Toe!!!')
print("You will be playing against another USER, make sure to enter the␣
↪names when asked")
print("You then keep counting in that left to right pattern for the rest of␣
↪the boxes")
print("Input what number you want to take as your box and then you're off!!!
↪")
print("HAVE FUN!")
print("Player 1")
player1 = input("Enter the name : ")
print("\n")
10
print("Player 2")
player2 = input("Enter the name : ")
print("\n")
try:
choice = int(input())
except ValueError:
print("Wrong Input!!! Try Again\n")
continue
if choice == 1:
player_choice['X'] = cur_player
if cur_player == player1:
player_choice['O'] = player2
else:
player_choice['O'] = player1
elif choice == 2:
player_choice['O'] = cur_player
if cur_player == player1:
player_choice['X'] = player2
else:
player_choice['X'] = player1
elif choice == 3:
print("Final Scores")
print_scoreboard(score_board)
11
break
else:
print("Wrong Choice!!!! Try Again\n")
winner = single_game(options[choice-1])
if winner != 'D' :
player_won = player_choice[winner]
score_board[player_won] = score_board[player_won] + 1
print_scoreboard(score_board)
if cur_player == player1:
cur_player = player2
else:
cur_player = player1
def get_valid_word(words):
word = random.choice(words)
while '-' in word or ' ' in word:
word = random.choice(words)
return word.upper()
def hangman():
word = get_valid_word(words)
word_letters = set(word)
alphabet = set(string.ascii_uppercase)
used_letters = set()
lives = 7
12
word_list = [letter if letter in used_letters else '-' for letter in␣
↪word]
print(lives_visual_dict[lives])
print('Current word: ', ' '.join(word_list))
else:
lives = lives - 1 # takes away a life if wrong
print('\nYour letter,', user_letter, 'is not in the word.')
else:
print('\nThat is not a valid letter.')
def hangman_Game():
print('Handle option \'Option 3\'')
hangman()
def GameInfo():
print('\n')
print('----------------------')
print ("Welcome to the GAME ROOOM")
print("You will have a choice to play any game you would like!")
print("Select an option down below to pick your game!")
print("WARNING: COMPUTER DOES NOT TAKE IT EASY FOR NEW COMERS")
13
menu_options = {
1: 'Rock, Paper, Scissors vs. CPU',
2: 'Tic-Tac-Toe (TWO Person game)',
3: 'Hangman vs. CPU',
4: 'Exit',
}
def print_game_menu():
for key in menu_options.keys():
print(key, '--', menu_options[key])
def Full_Game():
while(True):
GameInfo()
print_game_menu()
option = ''
try:
option = int(input('Enter your choice: '))
except:
print('Wrong input. Please enter a number ...')
#Check what choice was entered and act accordingly
if option == 1:
RPS()
elif option == 2:
TTToe()
elif option == 3:
hangman_Game()
elif option == 4:
print('Thank you for playing, you will be brougt back to the main␣
↪menu!')
WelcomeFunc()
else:
print('Invalid option. Please enter a number between 1 and 4.')
WelcomeFunc()
14