CSC108-Fall-2022-A1
README.md

CSC108 (Intro to Computer Programming) -Fall-2022-A1

Assignment 1 of CSC108 University of Toronto 2022 Goals of this Assignment:

  • Use the Function Design Recipe Download Function Design Recipeto plan, implement, and test functions.
  • Write function bodies using variables, numeric types, strings, and conditional statements. (You can do this whole assignment with only the concepts from Weeks 1, 2, and 3 of the course.)
  • Learn to use Python 3, Wing 101, provided starter code, a checker module, and other tools.

Mystery Message Game: In this assignment, you'll be writing functions to complete a Mystery Message game. To see how the game is played, please watch this video demo (https://web.microsoftstream.com/video/81adfd34-8a6d-4ee2-93e4-c2af7d26a804) The video demonstrates playing the one-player version of the game, but your code will eventually also have a two-player human vs. human version and also a human vs. computer version.

Starter code: For this assignment, we are giving you some files, including Python starter code files. Please download the Assignment 1 Files Download Assignment 1 Filesand extract the zip archive. There are three starter code Python files, two sample text input files, and a Python program that helps you check (not fully test!) your solutions for Python style violations:

  • mm_functions.py : This file contains some code that sets up your use of constants from constants.py, a helper function for you to use, as well as the header and the complete docstring (but not body) for the first function you are to write. Your job is to complete this file.
  • constants.py : This file contains some useful constants that you should use in your solution. You will not modify this file.
  • mystery_message_game.py: This is the main program. You will not modify this file. Rather, you will run this file to play the Mystery Message game. Please note that mystery_message_game.py depends on functions you will write in mm_functions.py, so this program won't run properly until you've implemented the functions.
  • messages_small.txt and messages.txt: ach of these files contains mystery messages used by mystery_message_game.py to select a message for a game and also to provide a pool of messages that the computer player "knows". You may want to use messages_small.txt when you are in the beginning of developing and debugging your solution, and messages.txt to play the game.
  • a1_checker.py: This is a checker program that you should use to check your code.

More about the Mystery Message program:

  • Two strings are used to represent information about a Mystery Message:

    • message is made up of alphabetic and non-alphabetic characters (e.g. spaces, punctuation, and digits). An example message string is 'e-mail inbox'.
    • view is the current view of the message as seen by the players. In it, the alphabetic characters are either displayed (if they have been revealed) or hidden (using a special character (a caret '^' by default), if they have not yet been revealed). Non-alphabetic characters (spaces, punctuation, and digits) are always displayed. For example, at the beginning of the game, the view string for the message above would be (with a caret to represent a hidden character): '^-^^^^ ^^^^^'. As the game progresses and players guess letters to be revealed, the view is updated. Continuing with the example above, if the player guesses "m", the view becomes '^-m^^^ ^^^^^' and then if "i" is guessed, it becomes '^-m^i^ i^^^^'.
  • There are three types of games that your program will play: human, human vs human, and human vs computer. We will use the constants HUMAN, HUMAN_HUMAN, and HUMAN_COMPUTER respectively, to represent the type of game being played.

  • When a player guesses a consonant, each occurrence of that consonant in the message earns a certain number of points for that player: the value of the constant CONSONANT_POINTS. If a player correctly guesses a consonant, they play again in the next turn. If the guess is incorrect, the turn goes to the next player (in a two-player game).

  • Players have to pay to guess a vowel. The cost does not depend on the number of occurrences of the vowel, and is always equal to the value of the constant VOWEL_COST. Thus, guessing a vowel decreases the player's points. A player is not allowed to guess a vowel if they do not have sufficient points to pay for it. If the vowel occurs in the message, then the player plays again. Otherwise, the turn goes to the next player (in a two-player game).

  • When a player finishes the game by correctly guessing the message, CONSONANT_BONUS bonus points are added to their score for each occurrence of a consonant that is still HIDDEN.

  • All messages are always lower-case. That is, the messages will not contain any upper-case letters.

  • You should read the file constants.py carefully to understand the purpose of each defined constant. You must use these constants in your code and not the literal values. For example, you must use HIDDEN instead of '^'.

This project was completed using Wing IDE.