Created
March 23, 2014 22:12
-
-
Save SensibleJames/9730646 to your computer and use it in GitHub Desktop.
When I run the randomize mode all it does is tell me that answer is wrong when the input (answer variable) is exactly the same as the answer(words[wordloc] list entry)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################### | |
#James Manning # | |
#Typing game # | |
#V 1.7 # | |
################### | |
from numpy import * | |
from random import * | |
words = [""] | |
i = 0 | |
f = open("Word Strings.txt", "r") | |
for i, line in enumerate(f): | |
pass | |
f.close() | |
LINENUM = i + 1 | |
f = open("Word Strings.txt", "r") | |
for wp in range(LINENUM): | |
words.append(f.readline()) | |
f.close() | |
words.remove("") | |
statistics = zeros ( (LINENUM), dtype=str ) | |
import time | |
gameon = True | |
while gameon == True: | |
print "would you like to play Classic or Randomiser?\n1) Classic 2) Randomiser(in testing)\n" | |
userchoice = raw_input(str("Choose: ")) #user will pick the gamemode | |
#Classic Game--------------------------------------------------------------------- | |
if userchoice == "1": #If it is one they are playing Classic | |
classicon = True | |
while classicon == True: | |
print "this is the typing game, press enter to start" | |
null = raw_input(str("")) #this will let the user start typing | |
gameon2 = True | |
starttime = time.clock () | |
while gameon2 == True: | |
print "I love cleaning windows" | |
answer = raw_input(str("")) | |
if answer == "I love cleaning windows": | |
endtime = time.clock() | |
gameon2 = False | |
print "That took you : ","%gs" % (endtime - starttime) | |
elif answer == "I love men": | |
print "you do, don't you" | |
elif answer == "stop": | |
classicon = False | |
gameon2 = False | |
else: | |
print "wrong try again" | |
starttime = time.clock () | |
#Randomiser Game------------------------------------------------------------------ | |
if userchoice == "2": | |
gameon2 = True | |
while gameon2 == True: | |
print "Welcome to the randomiser mode" | |
print "Good Luck\nHave fun." | |
print "You will get", LINENUM,"Different sentences" | |
print "press enter and type the one that appears" | |
rightanswers = 0 | |
null = raw_input(str("")) | |
starttime = time.clock () | |
while rightanswers < LINENUM: | |
wordloc = randint(0,LINENUM-1) | |
while statistics[wordloc] == 1: | |
wordloc = randint(0,LINENUM-1) | |
coranswer = False | |
while coranswer == False: | |
print words[wordloc], | |
answer = raw_input(str("")) | |
if answer == words[wordloc]: | |
print "correct" | |
statistics[wordloc] = statistics[wordloc] + 1 | |
rightanswers = rightanswers + 1 | |
coranswer = True | |
else: | |
print answer | |
print words[wordloc] | |
print "wrong try again" | |
endtime = time.clock() | |
print "You win" | |
print "That took you : ","%gs" % (endtime - starttime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I love cleaning windows | |
I want to get the right stuff | |
You won't have what I got | |
It's simple, we kill the batman | |
and Jack said "It is not the beast in the man." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment