1
+ # Submission for the Magic 8-ball challenge, July 6th 2022
2
+ # - Ehkso
3
+
4
+
5
+ import random # Random Responses
6
+ import time # Waiting
7
+ import os # Clearing screen
8
+ # Neither the time nor the os libraries are acutally necessary, however I use them to make my program pretty
9
+
10
+ #https://magic-8ball.com/magic-8-ball-answers/
11
+ # List of 8 ball answers for reference, I just took all the possible responses and wrote them into a list
12
+ # I alternated Affirmative/Noncommital/Negative, but due to the 8-ball having 20 responses in a 2:1:1 (10-5-5)
13
+ # split, the list has 5 consecutive affirmative answers at the end.
14
+
15
+ response = ["It is certain" , "Reply hazy, try again" , "Don't count on it" , "It is decidedly so" , "Ask again later" ,
16
+ "My reply is no" , "Without a doubt" , "Better not tell you now" , "My sources say no" , "Yes definitely" ,
17
+ "Cannot predict now" , "Outlook not so good" , "You may rely on it" , "Concentrate and ask again" ,
18
+ "Very doubtful" , "As I see it, yes" , "Most likely" , "Outlook good" , "Yes" , "Signs point to yes" ]
19
+
20
+ def eb (num ): # My 8-ball function, just makes the triangle flip to simulate the ball shaking and "thinking"
21
+ if (num == 0 ):
22
+ print ("::::::::::::::::::::::::::::::::::::::::" )# 40 (counting just for myself)
23
+ print ("::::::::::::::::::::::::::::::::::::::::" )
24
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
25
+ print ("::::::::::::::oo % oo:::::::::::::::" )
26
+ print ("::::::::::::oo %%% oo:::::::::::::" )
27
+ print (":::::::::::o %%%%% o::::::::::::" )
28
+ print (":::::::::::o %%%%%%% o::::::::::::" )
29
+ print (":::::::::::o %%%%%%%%% o::::::::::::" )
30
+ print ("::::::::::::o%%%%%%%%%%%%%o:::::::::::::" )
31
+ print ("::::::::::::::oo oo:::::::::::::::" )
32
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
33
+ print ("::::::::::::::::::::::::::::::::::::::::" )
34
+ print ("::::::::::::::::::::::::::::::::::::::::" )
35
+ elif (num == 1 ) or (num == 3 ):
36
+ print ("::::::::::::::::::::::::::::::::::::::::" )
37
+ print ("::::::::::::::::::::::::::::::::::::::::" )
38
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
39
+ print ("::::::::::::::oo oo:::::::::::::::" )
40
+ print ("::::::::::::oo oo:::::::::::::" )
41
+ print (":::::::::::o o::::::::::::" )
42
+ print (":::::::::::o o::::::::::::" )
43
+ print (":::::::::::o o::::::::::::" )
44
+ print ("::::::::::::o o:::::::::::::" )
45
+ print ("::::::::::::::oo oo:::::::::::::::" )
46
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
47
+ print ("::::::::::::::::::::::::::::::::::::::::" )
48
+ print ("::::::::::::::::::::::::::::::::::::::::" )
49
+ elif (num == 2 ):
50
+ print ("::::::::::::::::::::::::::::::::::::::::" )
51
+ print ("::::::::::::::::::::::::::::::::::::::::" )
52
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
53
+ print ("::::::::::::::oo oo:::::::::::::::" )
54
+ print ("::::::::::::oo%%%%%%%%%%%oo:::::::::::::" )
55
+ print (":::::::::::o %%%%%%%%% o::::::::::::" )
56
+ print (":::::::::::o %%%%%%% o::::::::::::" )
57
+ print (":::::::::::o %%%%% o::::::::::::" )
58
+ print ("::::::::::::o %%% o:::::::::::::" )
59
+ print ("::::::::::::::oo % oo:::::::::::::::" )
60
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
61
+ print ("::::::::::::::::::::::::::::::::::::::::" )
62
+ print ("::::::::::::::::::::::::::::::::::::::::" )
63
+ elif (num == 4 ): # Magic 8-ball is watching you
64
+ print ("::::::::::::::::::::::::::::::::::::::::" )
65
+ print ("::::::::::::::::::::::::::::::::::::::::" )
66
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
67
+ print ("::::::::::::::oo % oo:::::::::::::::" )
68
+ print ("::::::::::::oo %%% oo:::::::::::::" )
69
+ print (":::::::::::o %% %% o::::::::::::" )
70
+ print (":::::::::::o %% o %% o::::::::::::" ) # pranked
71
+ print (":::::::::::o %% %% o::::::::::::" )
72
+ print ("::::::::::::o %%% o:::::::::::::" )
73
+ print ("::::::::::::::oo % oo:::::::::::::::" )
74
+ print ("::::::::::::::::ooooooo:::::::::::::::::" )
75
+ print ("::::::::::::::::::::::::::::::::::::::::" )
76
+ print ("::::::::::::::::::::::::::::::::::::::::" )
77
+
78
+ fin = 0 # Checks if the while loop should 'finish', basically an empty variable though since I just
79
+ first = 1 # Just checks if it's the first question, not really important but once again just a nicety.
80
+ while fin != 1 :
81
+ os .system ("cls" ) # Clears screen
82
+ eb (0 )
83
+ print ("" ) # I do these instead of beginning a sentence with a newline because I want to.
84
+ if (first == 1 ): # Yeah that's all I used it for lol, I could've done fin and first as one variable but for clarity
85
+ inp = input ("Ask your question: " )
86
+ else : # Because I'd be looking at something else while the ball spins and then miss the prediction
87
+ print ("Previous question: " + inp )
88
+ print ("Previous answer: " + response [rnum - 1 ] + "\n " )
89
+ inp = input ("Ask your question, or say 'Thank you 8' to exit.\n \n " )
90
+
91
+ if (inp == "Thank you 8" ): # Exit clause
92
+ fin = 1
93
+ else : # Do the stuff
94
+ rnum = random .randint (1 , 21 )
95
+ for i in range (1 , (rnum * 5 )): # Cycles 8-ball, range can be whatever but I like the idea of it possibly taking longer for a different answer
96
+ for j in range (0 ,4 ): # Counts 0-3 inclusive
97
+ os .system ("cls" )
98
+ eb (j )
99
+ print ("\n " + inp )
100
+ print ("\n Pondering..." )
101
+ #print(rnum) # Troubleshooting, to cross reference with list to make sure
102
+ time .sleep (0.1 ) # Adjustable, I feel like this is fast enough but you can always shorten it
103
+
104
+ os .system ("cls" )
105
+ eb (2 )
106
+ print ("\n " + inp + "\n \n " + response [rnum - 1 ])
107
+ time .sleep (5 )
108
+ first = 0 # No longer the first question after this
109
+
110
+ os .system ("cls" )
111
+ eb (4 ) # spoopy prenk
112
+ print ("\n End." )
0 commit comments