🚀 Basics Day 3: In-Class Exercises 🚀

Pre-Class In-Class

Base: Secret Word

Create a game where a player must correctly guess secret words to win.

The computer chooses a random word from a set of three words. Feel free to use whatever words you'd like, but we will be using the words "banana", "chisel", and "faucet".

To win the game the player must guess correctly twice in total; but is allowed to guess wrongly in between their two correct guesses.

For each guess, output all information such as the guessed word, the secret word, and how many correct guesses the player still needs until she wins.


Guess the secret word:


Output:

Comfortable: Secret Word Twice in a Row

Update Secret Word with an additional rule: The player must guess correctly twice in a row to win.


Guess the secret word:


Output:

Comfortable: Secret Word X in a Row

Update Secret Word game such that the number of times the player needs to guess correctly in a row changes between rounds.

We define "round" as all gameplay until a player wins. The number of times the player needs to guess correctly is a number from 2 to 4, randomly chosen at the start of the round.

When the player wins, the computer updates the number of times the player needs to guess correctly in a row for the next round.


Guess the secret word:


Output:

More Comfortable: Dice Within

Create a new version of our Coding Basics dice game (where the player guesses the dice roll) that randomly becomes easier or harder. At the beginning of the game and each time the player wins, the computer selects a random number from 1 to 3, which we call the "within number". If any of the player's guesses fall within the dice roll plus or minus the within number, the player wins.

For example: the app randomly chooses 3 as the within number. The player can guess within 3 of the dice roll to win the game. The player guesses 2 and the dice roll is 5. The guess is within 3 of the dice roll so the player wins the game. At this point, the computer adjusts the difficulty of the game by choosing a new within number.


Guess a number:


Output:

More Comfortable: Dice Within with 2 Dice

Update our dice game to include an additional dice. With each player guess, the computer rolls 2 dice. If the player guess is within either of the 2 dice rolls plus or minus the within number, the player wins.


Guess a number:


Output:

More Comfortable: Dice 4D

Update our dice game to allow the player to play a round of 4D every 2 times the player wins the dice roll guess. Verify our 4D game logic such that it is possible to win this 4D game.


Guess a number:


Output:

More Comfortable: Secret Word Twice in a Row 2

Update Secret Word with the following additional rules.

  1. The player must guess correctly twice in a row to win
  2. Secret words cannot be repeated 2 guesses in a row. E.g. the secret word cannot be "banana" for 2 player guesses in a row. If the secret word for the 1st guess were "banana", the secret word for the 2nd guess would have to be either "chisel" or "faucet".

Guess the secret word:


Output: