From: Pi@Raspberry Date: Thu, 30 Oct 2014 21:49:09 +0000 (+0000) Subject: Added initial files X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;ds=inline;p=word-grid-game.git Added initial files --- 6d4889117dd25bd50bf82125f08c959e59e22081 diff --git a/word_grid_game.py b/word_grid_game.py new file mode 100644 index 0000000..e65ae2d --- /dev/null +++ b/word_grid_game.py @@ -0,0 +1,31 @@ +import random + +all_words=[i.strip() for i in open("words.txt").readlines()] + +def get_difficulty(): + game="fail" + while game!="EASY" and game != "HARD": + game=input("choose the difficulty easy or hard...").upper() + print("you have 30 seconds (45 if you picked 'hard') to memorise a grid of words. Good luck...") + return game == "EASY" + +def words_for_game(words, is_easy): + if is_easy: + return words[:10] + else: + return words[:] + +def print_grid(words): + print(words) + + +# random.shuffle(words) +# added_word=words.pop() +# for i in range(3): +# print(words[3*i],words[3*i+1],words[3*i+2]) + +def play_game(): + is_easy = get_difficulty() + words = words_for_game(all_words, is_easy) + random.shuffle(words) + print_grid(words) diff --git a/words.txt b/words.txt new file mode 100644 index 0000000..00af9b2 --- /dev/null +++ b/words.txt @@ -0,0 +1,17 @@ +XXXXA +XXXXB +XXXXC +XXXXD +XXXXE +XXXXF +XXXXG +XXXXH +XXXXI +XXXXJ +XXXXK +XXXXL +XXXXM +XXXXN +XXXXO +XXXXP +XXXXQ