Professional Documents
Culture Documents
/usr/bin/env python
# encoding: utf-8
"""
alice_file.py
import operator
def rank_words_from_File(f):
"""
Takes in a file, then ranks all the words within the file
Args: a file
return word_dict
def main():
# Title
print 'The Word Game'
print '='*30
print ""
# Game Setup
f = open('alice.txt', 'rU')
print 'Loading Words....'
orig_ranked_words_dict = rank_words_from_File(f)
f.close()
print 'Loading Complete!!!'
print 'Game Starting...'
print ""
#Game Loops
while True: # loop for each Game
# Determine what the round limit is
while True:
try:
round_limit = int(raw_input('Choose Game Length, how many Rounds?
[enter a number larger than 0]: '))
if int(round_limit) <= 0:
print 'Answer must be more than 0, Please try again!'
print ""
else:
break
except:
print 'An Error Occured, make sure you enter an Integer.'
print ""
if len(cur_word) > 0:
print ""
print ""
print (" "*5)+'Current String = "%s"' % cur_word
print ""
print ""
print ""
print '%s - will not make valid word, Player %d lost that
Round!!' % \
(cur_word,cur_player)
print ""
print "!#YAH#!"*10
print ""
print ""
print "!#YAH#!"*10
print ""
cur_word = ""
# Exit Round
break
else:
# Change the player
if cur_player == 1:
cur_player = 2
else:
cur_player = 1
# Back inside of the Rounds Loop
if cur_round == round_limit:
print ""
print 'Round Limit Reached'
print ""
print 'Player 1: %d Player 2: %d' % (points[0],points[1])
print ""
print ""
if points[0] > points[1]:
print 'Player 1 WINS !!!!'
elif points[0] < points[1]:
print 'Player 2 WINS !!!!'
else:
print "It's a TIE !!!!"
print ""
break
else:
round_over = False
cur_round += 1
if __name__ == '__main__':
main()