From 2572b512a69842a490d5ba3039c20daf423b8115 Mon Sep 17 00:00:00 2001 From: Dave LeCompte Date: Thu, 4 Mar 2021 09:41:04 -0800 Subject: [PATCH] port SYNONYM to Python maintained the effect of the original logic without all the crazy array manipulations. --- 85 Synonym/README.md | 10 ++++ 85 Synonym/python/synonym.py | 100 +++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 85 Synonym/python/synonym.py diff --git a/85 Synonym/README.md b/85 Synonym/README.md index 4f723858..b9a5b79f 100644 --- a/85 Synonym/README.md +++ b/85 Synonym/README.md @@ -5,3 +5,13 @@ https://www.atariarchives.org/basicgames/showpage.php?page=164 Downloaded from Vintage Basic at http://www.vintage-basic.net/games.html + + +## Known Issues + + - Each time the player asks for HELP, one of the synonyms is shown + and discarded. There is no protection against the player using up + all of the help. + + - The player can ask for HELP and then submit that answer. Is it + meant to be a clue, or just giving a correct answer to the player? \ No newline at end of file diff --git a/85 Synonym/python/synonym.py b/85 Synonym/python/synonym.py new file mode 100644 index 00000000..02ac24e6 --- /dev/null +++ b/85 Synonym/python/synonym.py @@ -0,0 +1,100 @@ +""" +SYNONYM + +Vocabulary quiz + +Ported by Dave LeCompte +""" + +import random + + +PAGE_WIDTH = 64 + + +def print_centered(msg): + spaces = " " * ((PAGE_WIDTH - len(msg)) // 2) + print(spaces + msg) + + +def print_header(title): + print_centered(title) + print_centered("CREATIVE COMPUTING MORRISTOWN, NEW JERSEY") + print() + print() + print() + + +def print_instructions(): + print("A SYNONYM OF A WORD MEANS ANOTHER WORD IN THE ENGLISH") + print("LANGUAGE WHICH HAS THE SAME OR VERY NEARLY THE SAME MEANING.") + print("I CHOOSE A WORD -- YOU TYPE A SYNONYM.") + print("IF YOU CAN'T THINK OF A SYNONYM, TYPE THE WORD 'HELP'") + print("AND I WILL TELL YOU A SYNONYM.") + print() + + +right_words = ["RIGHT", "CORRECT", "FINE", "GOOD!", "CHECK"] + +synonym_words = [ + ["FIRST", "START", "BEGINNING", "ONSET", "INITIAL"], + ["SIMILAR", "ALIKE", "SAME", "LIKE", "RESEMBLING"], + ["MODEL", "PATTERN", "PROTOTYPE", "STANDARD", "CRITERION"], + ["SMALL", "INSIGNIFICANT", "LITTLE", "TINY", "MINUTE"], + ["STOP", "HALT", "STAY", "ARREST", "CHECK", "STANDSTILL"], + ["HOUSE", "DWELLING", "RESIDENCE", "DOMICILE", "LODGING", "HABITATION"], + ["PIT", "HOLE", "HOLLOW", "WELL", "GULF", "CHASM", "ABYSS"], + ["PUSH", "SHOVE", "THRUST", "PROD", "POKE", "BUTT", "PRESS"], + ["RED", "ROUGE", "SCARLET", "CRIMSON", "FLAME", "RUBY"], + ["PAIN", "SUFFERING", "HURT", "MISERY", "DISTRESS", "ACHE", "DISCOMFORT"], +] + + +def print_right(): + print(random.choice(right_words)) + + +def ask_question(question_number): + words = synonym_words[question_number] + clues = words[:] + base_word = clues.pop(0) + + while True: + question = f" WHAT IS A SYNONYM OF {base_word}? " + response = input(question).upper() + + if response == "HELP": + clue = random.choice(clues) + print(f"**** A SYNONYM OF {base_word} IS {clue}.") + print() + + # remove the clue from available clues + clues.remove(clue) + continue + + if (response != base_word) and (response in words): + print_right() + return + + +def finish(): + print() + print("SYNONYM DRILL COMPLETED.") + + +def main(): + print_header("SYNONYM") + print_instructions() + + num_questions = len(synonym_words) + word_indices = list(range(num_questions)) + random.shuffle(word_indices) + + for word_number in word_indices: + ask_question(word_number) + + finish() + + +if __name__ == "__main__": + main()