Advertisement
daichan21

20141126.py

Nov 27th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.22 KB | None | 0 0
  1. import random
  2. import time
  3. import string
  4. import math
  5.  
  6. theZone = [' '] * 10
  7.  
  8.  
  9. def twp(string, typewriterN):
  10.     listOfString = list(string)
  11.     indexOfString = list(range(len(listOfString)))
  12.     j = 0
  13.     while j < len(listOfString):
  14.         print(listOfString[j], end='')
  15.         j = j+1
  16.         time.sleep(1/typewriterN)
  17.  
  18. def cfnp(string, confusingN):
  19.     listOfString = list(string)
  20.     indexOfString = list(range(len(listOfString)))
  21.     while len(listOfString) >= 1:
  22.         k = random.randint(0, len(listOfString)-1)
  23.         print(listOfString[k], end='')
  24.         del listOfString[k]
  25.         time.sleep(1/confusingN)
  26.  
  27. def happyEnding():
  28.  
  29.     twp("Thank you for playing Brave New World by D. Zhang\n", 10)
  30.     twp("THE END", 5)
  31.  
  32. def sadEnding():
  33.  
  34.     twp("Thank you for playing Brave New World by D. Zhang\n", 10)
  35.     twp("THE END", 5)
  36.  
  37. def strikeZone(board):
  38.    
  39.     print('   |   |')
  40.     print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
  41.     print(' 1 | 2 | 3')
  42.     print('-----------')
  43.     print(' 4 | 5 | 6')
  44.     print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
  45.     print('   |   |')
  46.     print('-----------')
  47.     print(' 7 | 8 | 9')
  48.     print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
  49.     print('   |   |')
  50.  
  51. def chooseDifficulty():
  52.     twp("Please select difficulty: rookie, easy, hard, insane or god-like.\n", 50)
  53.     difficultyChooser = input()
  54.     while not(difficultyChooser == 'rookie' or difficultyChooser == 'easy' or difficultyChooser =='hard' or difficultyChooser =='insane' or difficultyChooser =='god-like'):
  55.         twp("Please enter a valid difficulty. Try again: \t", 15)
  56.         difficultyChooser = input()
  57.     else:
  58.         twp("Difficulty " + difficultyChooser + " registered.\n", 30)
  59.         twp("Constructing Arcade and Laboratory................\n", 30)
  60.         twp("Purchasing integrated circuits....................\n", 30)
  61.         twp("Initializing Strike Zone..........................\n", 30)
  62.         twp("Loading...........................................\n", 10)
  63.         time.sleep(1)
  64.         twp("Press Enter to start. \n", 30)
  65.         varEmpty6 = input()
  66.  
  67. def baseballIntro():
  68.            
  69.     twp("Press Enter to start your baseball battle. \n", 30)
  70.     varEmpty6 = input()
  71.     twp("Please choose your bat: Pine, aluminum, iron, Major League\n", 10)
  72.     bat = input()
  73.     twp("You pick up a " + bat + " bat, and proceed to the stadium.\n", 10)
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. twp("Please select language:\t ", 50)
  81. selectLanguage = input()
  82. while selectLanguage != "English":
  83.     twp("This game is currently under testing. English is the only option.\n", 50)
  84.     selectLanguage = input("Please select language:\t ")
  85. else:
  86.     chooseDifficulty()
  87.    
  88.     twp('How old are you? ', 50)
  89.     pAge = str(input('My age is '))    
  90.     if int(pAge) > 15:
  91.             twp('Minimum age requirement met.\n', 200)
  92.             twp('Initializing....................\n', 40)
  93.             twp('Loading....................\n', 40)
  94.             time.sleep(1)
  95.            
  96.     else:                              
  97.             twp('Minimum age requirement not met.\n', 200)
  98.             time.sleep(1)
  99.             twp('Initialize game in Guest Safety Mode.\n', 40)
  100.             twp('Initializing....................\n', 40)
  101.             twp('Loading....................', 40)
  102.    
  103.        
  104.     twp("""
  105.    ######  ######     #    #     # #######
  106.    #     # #     #   # #   #     # #      
  107.    #     # #     #  #   #  #     # #      
  108.    ######  ######  #     # #     # #####  
  109.    #     # #   #   #######  #   #  #      
  110.    #     # #    #  #     #   # #   #      
  111.    ######  #     # #     #    #    #######   \n""", 1600)
  112.  
  113.     twp(
  114.     """
  115.    #     # ####### #     #
  116.    ##    # #       #  #  #
  117.    # #   # #       #  #  #
  118.    #  #  # #####   #  #  #
  119.    #   # # #       #  #  #
  120.    #    ## #       #  #  #
  121.    #     # #######  ## ##      \n""", 1600)
  122.  
  123.     twp(
  124.     """
  125.    #     # ####### ######  #       ######  
  126.    #  #  # #     # #     # #       #     #
  127.    #  #  # #     # #     # #       #     #
  128.    #  #  # #     # ######  #       #     #
  129.    #  #  # #     # #   #   #       #     #
  130.    #  #  # #     # #    #  #       #     #
  131.     ## ##  ####### #     # ####### ######      \n""", 1600)
  132.  
  133.     twp("\n \n \t \t Python Project by 'daichan21' D. Zhang. November 2014. \n ", 100)
  134.     twp("\t \t Visit my blog DZ's Klavier @ http://daichan21.wordpress.com \n", 100)
  135.     twp("\t \t My GitHub: daichan21  My Pastebin: daichan21 \n", 100)
  136.     twp("\t \t Character names are based on Aldous Huxley's novel Brave New World \n", 100)
  137.     twp("\t \t Game concept and design by D. Zhang.", 100)
  138.  
  139.     initialization = input("\n \n Enter Enter Key to start game: \n")
  140.  
  141.     while initialization != '':
  142.         twp("Come on, you know where the Enter Key is. LOL \n", 100)
  143.         initialization = input("Press Enter Key to start game: \n")
  144.     else:
  145.         twp("Nice! Your adventure starts now!\n", 100)
  146.         birthPlace = input("Please input your place of birth.\n")
  147.  
  148.    
  149.     twp("What is your name, \n", 30)
  150.     playerName = input()
  151.     time.sleep(1.5)
  152.  
  153.     twp(".....Oh I didn't realize that you are capable of speaking, hmm.. English. \n", 30)
  154.     twp("Apologies, " + playerName + ".\n", 30)
  155.     time.sleep(1.5)
  156.     twp("May I know if you are male or female, " + playerName + "?\n", 30)
  157.     print("Please enter your gender here:\t")
  158.     playerSex = input()
  159.    
  160.     if playerSex == "Male" or playerSex == "male":
  161.         newPlayerName = "Mr. " + playerName
  162.     elif playerSex == "Female" or playerSex == "female":
  163.         newPlayerName = "Ms. " + playerName
  164.  
  165.     twp("So, " + newPlayerName + ", Welcome to the \n", 30)
  166.  
  167.     twp("""
  168.    #     # ####### ######  #       ######  
  169.    #  #  # #     # #     # #       #     #
  170.    #  #  # #     # #     # #       #     #
  171.    #  #  # #     # ######  #       #     #
  172.    #  #  # #     # #   #   #       #     #
  173.    #  #  # #     # #    #  #       #     #
  174.     ## ##  ####### #     # ####### ######  
  175.                                            
  176.     #####  #######    #    ####### #######
  177.    #     #    #      # #      #    #      
  178.    #          #     #   #     #    #      
  179.     #####     #    #     #    #    #####  
  180.          #    #    #######    #    #      
  181.    #     #    #    #     #    #    #      
  182.     #####     #    #     #    #    ####### \n""", 1800)
  183.  
  184.     twp("Stability, Community, Identity. \n", 50)
  185.     twp("Everyone belongs to everyone else. \n", 50)
  186.     twp("We are the WORLD STATE. Glory to us alone! \n", 45)
  187.     time.sleep(2)
  188.     twp("......\n", 30)
  189.     twp("Oh sorry, I forgot to introduce myself, " + newPlayerName + ".\n", 50)
  190.     twp("My name is Bernard Marx, the chief emotional engineer at the\n", 50)
  191.     twp("Central London Hatcheries and Development Centre in World State. \n", 50)
  192.     twp("......\n", 30)
  193.     twp("I understand that you grew up in the land of " + birthPlace + ",\n", 50)
  194.     twp("which lies in a country that is our loyal ally. Therefore I will lead you on an interactive tour so that \n", 50)
  195.     twp("you can learn more about our powerful country.\n", 50)
  196.     twp("This way please, " + newPlayerName + ". This will be really fun. \n \n \n \n", 100)
  197.     time.sleep(2)
  198.     twp("Press Enter to follow Bernard. \n", 50)
  199.     varEmpty7 = input()
  200.    
  201.  
  202.    
  203.  
  204.  
  205.  
  206.  
  207. print("____________________________________________________________________________________________________________________")
  208. possibleCharacters = string.ascii_lowercase + string.ascii_uppercase + string.digits + " .,!?;:'~@#$%^&*()_+\][/"
  209.  
  210. twp("Please enter a line of words that you have in mind:\n", 25)
  211. targetLine = input()
  212. attemptThis = ''.join(random.choice(possibleCharacters) for i in range(len(targetLine)))
  213. attemptNext = ''
  214.  
  215. completed = False
  216.  
  217. attemptTaken = 0
  218.  
  219. while completed == False:
  220.     print(attemptThis)
  221.     attemptNext = ''
  222.     completed = True
  223.     for i in range(len(targetLine)):
  224.         if attemptThis[i] != targetLine[i]:
  225.             completed = False
  226.             attemptNext += random.choice(possibleCharacters)
  227.         else:
  228.             attemptNext += targetLine[i]
  229.     attemptTaken += 1
  230.     attemptThis = attemptNext
  231.     time.sleep(0.1)
  232.  
  233. twp("The computer successfully guessed the line of words you had in mind!\n", 25)
  234. twp("What's more, we now have a set of data of your brain activity stored in our database!\n", 25)
  235. twp("It only took this computer " + str(attemptTaken) + " attempts to read your mind!", 35)
  236. time.sleep(2)
  237. twp("Congratulations! You survived this round of the Brave New World Laboratory! Keep going!\n", 40)
  238. twp("Press Enter to continue.\n", 40)
  239. varEmpty7 = input()
  240.  
  241. time.sleep(2)
  242. print("____________________________________________________________________________________________________________________")
  243.  
  244. my_dict =   {
  245.                 "In what year was Shakespeare born?" : "1564",
  246.                 "In what year did Shakespeare die?" : "1616",
  247.                 "How many sonnets did Shakespeare write?" : "154",
  248.                 "Did Shakespeare invent the word 'assassination'?" : "yes",
  249.                 "What was the name of Shakespeare's wife?" : "Anne Hathaway",
  250.                 "Of what Italian city is The Tempest's Prospero a duke?" : "Milan",
  251.                 "What play is also known as the Scottish play?" : "Macbeth",
  252.                 "What is Romeo's family name?" : "Montague",
  253.                 "What title is given to Macbeth after the traitor is executed?" : "Thane of Cawdor",
  254.                 "What is the theatre in which Shakespearean plays are shown?" : "The Globe",
  255.                 "Where was Shakespeare born?" : "Stratford-upon-Avon"
  256.             }
  257.  
  258. twp("SHAKESPEARE TRIVIAL QUIZ\n", 30)
  259. print("___________________________________________________________________________________________________________________")
  260. twp("BERNARD MARX: Shakespeare is the most-read writer in the World State. Here are some questions for you to answer.\n", 50)
  261.  
  262. playing = True
  263.  
  264. while playing == True:
  265.     score = 0
  266.     num = int(input("\nPlease enter the number of questions you want to answer: (<=10)\t "))
  267.     for i in range(num):
  268.         question = (random.choice(list(my_dict.keys())))
  269.         answer = my_dict[question]
  270.         twp("\nQuestion " + str(i+1) + " ", 50)
  271.         twp(question  + "\n", 50)
  272.         guess = input("> ")
  273.         if guess.lower() == answer.lower():
  274.             twp("That is CORRECT!", 50)
  275.             score += 1
  276.         else:
  277.             print("That is INCORRECT!", 50)
  278.  
  279.     print("\nYour final score was " + str(score))
  280.     break
  281.  
  282. time.sleep(2)
  283. twp("Congratulations! You survived this round of the Brave New World Laboratory! Keep going!\n", 40)
  284. twp("Press Enter to continue.\n", 40)
  285. varEmpty7 = input()
  286. print()
  287. print("____________________________________________________________________________________________________________________")
  288. twp("In this part of the tour, you will discover the true power of obedience and appreciate the real meaning of\n", 50)
  289. twp("a totalitarian society. There are some hand-on activities you can try out with our interactive screen.\n", 50)
  290. twp("In this section, you will simply type out the strings of letters you see on the screen. This is relatively simple,\n", 50)
  291. twp("but it's not as easy as you think it is. It will get quite tricky.\n", 50)
  292. twp("This activity greatly enhances your memorization capacity and strengthens your cognitive abilities.\n", 50)
  293. twp("Once you type out 5 strings of letters correctly, you can proceed to the next section.\n", 50)
  294. time.sleep(1.7)
  295. twp("Press Enter key to start this section.\n \n", 50)
  296. varEmpty9 = input()
  297.  
  298.  
  299. obstacle1 = ['John the Savage', 'Everyone belongs to everyone else', 'Director Tomakin', 'His Fordship Mond', 'World Controllers', 'Sleep teaching is the best', 'Alpha is superior', 'episilon half-morons', 'class struggle', 'we rely on each other', 'glorious World State', 'I choose happiness', 'I do not want to suffer', 'we take things for granted', 'we are superior', 'we should work hard', 'Ford is the greatest man', 'we are and should be humble']
  300. levelMemoryType = len(obstacle1)
  301. scoreCounter = 0
  302. alphabetCounter = 0
  303. possibleAlphabets = string.ascii_lowercase
  304. lengthOfAS = 3
  305.  
  306. while alphabetCounter < 5:
  307.     randomAlphabet =''.join(random.choice(possibleAlphabets) for i in range(lengthOfAS))
  308.     twp("\n" + randomAlphabet, 30)
  309.     time.sleep(1.5)
  310.     print("""
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368. """)
  369.     twp("Please type in the string of letters you just saw. All in lower case.\n", 120)
  370.     playerWord = input()
  371.     if playerWord == randomAlphabet:
  372.         alphabetCounter = alphabetCounter + 1
  373.         if lengthOfAS <= 5:
  374.             lengthOfAS = lengthOfAS + random.randint(1, 2)
  375.         else:
  376.             lengthOfAS = lengthOfAS + 1
  377.         twp("That is correct! Keep going! You already typed " + str(alphabetCounter) + " string(s) of letters correctly. \n", 50)
  378.     else:
  379.         twp("That is INCORRECT! Try again. You already typed " + str(alphabetCounter) + " strings(s) of letterss correctly. \n", 50)
  380.  
  381. twp("Nicely done! Your memorization skill is simply incredible!\n", 50)
  382. twp("Citizens of the World State start training like this when they are 2 years old.\n", 50)
  383. twp("The main purpose is to make them obedient workers that are orthodox and loyal.\n", 50)
  384. twp("In the next section, you will see how this training of memorization skill, incorporated with sleep teaching,\n is an excellent way of transmitting information.", 50)
  385. time.sleep(2)
  386. print()
  387. twp("In this section, you will type words and phrases instead of random letters. \n The words and phrases have actual meanings.\n", 50)
  388. twp("Once you type out 5 strings of words/phrases correctly, you can proceed to the next section.\n \n", 50)
  389. time.sleep(1.7)
  390. twp("Press Enter key to start this section.\n \n", 50)
  391. varEmpty9 = input()
  392.  
  393. while scoreCounter < 5:
  394.     randomWord = obstacle1[random.randint(0, levelMemoryType-1)]
  395.     twp("\n" + randomWord, 30)
  396.     time.sleep(1.5)
  397.     print("""
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456. """)
  457.     twp("Please type in the word/phrase you just saw. Case-sensitive.\n", 60)
  458.     playerWord = input()
  459.     if playerWord == randomWord:
  460.         scoreCounter = scoreCounter + 1
  461.         twp("That is correct! Keep going! You already typed " + str(scoreCounter) + " words correctly. \n", 50)
  462.     else:
  463.         twp("That is INCORRECT! Try again. You already typed " + str(scoreCounter) + " words correctly. \n", 50)
  464.  
  465. twp("Good work! As you can see, the brainwashing technique in World State society is very effective and unique.\n", 50)
  466. twp("We use excessive repetition to engrave our ideology in the minds of our subjects.\n", 50)
  467. twp("Because of this intense, forceful, one-way transmission of information, people lose individuality and accept\n", 50)
  468. twp("their roles in the society unconditionally.\n", 50)
  469. time.sleep(1.7)
  470. twp("Press Enter key to exit this part of the interactive tour.\n \n \n", 50)
  471. varEmpty9 = input()
  472. print("__________________________________________________________________________________________________________________")
  473.  
  474. twp("BERNARD MARX: 'Let's have some fun. Because baseball is the national sport of the World State, I would like to play\n", 50)
  475. twp("a game of baseball with you.\n", 50)
  476. twp("I will be the pitcher and you will be the batter.\n", 50)
  477. twp("Here's the strike zone. You see that each part of the Zone has a number on it.\n", 35)
  478. twp("As batter, you can pick 2 parts of the zone you are aiming to hit.\n", 35)
  479. twp("You also have the choice of letting the electromagnetic computer decide for you.\n", 35)
  480. twp("Don't worry. The computer algorithm is purely random.\n", 35)
  481. twp("Do you want to hit for yourself or let the computer hit for you?\n", 35)
  482. twp("Choose A if you want to hit the ball yourself. Choose B for automatic control.\n", 35)
  483. howToHit = input()
  484. while howToHit == 'B':
  485.       twp("The game is currently under testing. This function is not yet available.\n", 35)
  486.       howToHit = input("Press A please.")
  487. else:
  488.      
  489.   twp("BERNARD MARX: 'Great. I, as pitcher, can choose to pitch to any part of the strike zone.\n", 35)
  490.   twp("If one of the either numbers you choose matches my number, you will be able to hit it.\n", 35)
  491.   twp("However, if you swing 3 times and you miss all of them. You will be struck out.\n", 35)
  492.   twp("And this tour will come to an end.\n", 35)
  493.   twp("Let's get started!\n \n \n", 30)
  494.   time.sleep(0.76)
  495. print("""
  496. ______ _____  ________  ___ ___________  _____   __
  497. |  _  \ _  ||  _  |  \/  |/  ___|  _  \/ _ \ \ / /
  498. | | | | | | || | | | .  . |\ `--.| | | / /_\ \ V /
  499. | | | | | | || | | | |\/| | `--. \ | | |  _  |\ /  
  500. | |/ /\ \_/ /\ \_/ / |  | |/\__/ / |/ /| | | || |  
  501. |___/  \___/  \___/\_|  |_/\____/|___/ \_| |_/\_/
  502.  
  503. ______            _______  _      
  504. (  __  \ |\    /|(  ___  )( \    
  505. | (  \ )| )   ( || (   ) || (      
  506. | |   ) || |   | || (___) || |      
  507. | |   | || |   | ||  ___  || |      
  508. | |   ) || |   | || (   ) || |      
  509. | (__/  )| (___) || )   ( || (____/\
  510. (______/ (_______)|/     \|(_______/ \n \n""")
  511.  
  512. twp("""
  513.          .-""""""-.
  514.        .'         :'.
  515.       /           :  \
  516.      :`.          .   :
  517.      |  '          .  |
  518.      :   `          . :
  519.       \  :          /
  520.        '. .        .'
  521.          '-......-' \n \n
  522. """, 1700)
  523. print("""
  524. _____  ___   _____ ___________  ___   _      _    
  525. | ___ \/ _ \ /  ___|  ___| ___ \/ _ \ | |    | |    
  526. | |_/ / /_\ \\ `--.| |__ | |_/ / /_\ \| |    | |    
  527. | ___ \ _  | `--. \ __|| ___ \ _  || |    | |    
  528. | |_/ / | | |/\__/ / |___| |_/ / | | || |____| |____
  529. \____/\_| |_/\____/\____/\____/\_| |_/\_____/\_____/\t \t \t""")
  530.  
  531. strikeCount = 0
  532. while strikeCount < 3:
  533.         twp("\nPlease select your first number between 1 and 9:\t", 30)
  534.  
  535.         firstChoice = input()
  536.  
  537.         twp("\nPlease select your second number between 1 and 9:\t", 30)
  538.  
  539.         secondChoice = input()
  540.  
  541.         pitcherNumber = random.randint(1, 9)
  542.         ballBank = ['75 mph curveball', '50 mph eephus', '99 mph 4 seamer fastball', '88 mph backdoor slider', '62 mph knuckleball']
  543.         ballType = random.choice(ballBank)
  544.         twp("Bernard Marx winds up on the mound...\n", 27)
  545.         time.sleep(0.75)
  546.         twp("he stretches...\n", 23)
  547.         time.sleep(0.85)
  548.         twp("and pitches a " + ballType + " that flies toward...\n", 15)
  549.         time.sleep(1)
  550.         twp(str(pitcherNumber) + " part of the strike zone!", 10)
  551.  
  552.         if firstChoice == str(pitcherNumber):
  553.             break
  554.         elif secondChoice == str(pitcherNumber):
  555.             break
  556.         else:
  557.             strikeCount = strikeCount + 1
  558.             if strikeCount == 3:
  559.                 twp("That is a really nasty pitch. It's impossible to locate. You miss terribly again.\n", 15)
  560.                 twp("That's the 3rd strike, and you are out. The tour has come to an end.\n", 10)
  561.                 sadEnding()
  562.             else:
  563.                 twp("You try to locate the tricky pitch, but you miss it by inches. STRIKE!\n", 15)
  564.                 twp("Strike count: " + str(strikeCount), 19)
  565.  
  566. twp("And you aim carefully, and swing the bat with all your might!",15)
  567. twp("IT'S A HOMERUN!", 5)
  568. happyEnding()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement