Example #1
0
def executeHangman(): #the main method, runs the game
    while 1 > 0: #loops the game infinitely unless the user wants to quit
        file = csv.reader(open("words.csv", "rU"), dialect=csv.excel_tab)
        newlist = UtilityFunctions.formatHangmanData(file)
        word = UtilityFunctions.create_word(newlist)
        whichMode = int(raw_input("User or AI game? (0 for User, 1 for AI) ")) #0 for user, 1 for AI
        if whichMode == 0:
            playHangman(word)
            cont = raw_input('Type y to play again. Type n to quit\n ')
            if (cont == 'n'):
                return
        elif whichMode == 1:
           autoPlayHangman(word)
           cont = raw_input('Type y to play again. Type n to quit\n ')
           if (cont == 'n'):
                return
        word = UtilityFunctions.create_word(newlist)