ROULETTE
First step was to see what type of bet the player wanted to make by setting bet_type equal to input(pick a bet)
- Each type of bet is given a number 1 through 6 (red/black, even/odd, row number, sets of 12, sets of 18, and specific number).
- Once a number 1 through 6 is entered it will ask the player another question of what bet is made after the type is chosen. This is achieved by using an if else statement. For example if bet_type = 1; evenodd = input(1 for odd 2 for even). This is true for all 6 of the bet types. The other variables for types of bets are: redblack, num_pick, set12, set18, rownum.
- All the variables are first set to 0 so that when a bet is picked it can change to a different number.
- Once the bet is made and the variables are set to zero except the variable where the bet was made. The roulette number (roulette_num) is randomly generated between 0 and 36.
- After the number is generated it will go through an if else statement of every number 0 through 36 until it finds the number the roulette wheel generated.
- Once the if else line is found with the number of the roulette number it will test to see if the bet is the same number as the roulette number spun.
- If the numbers match up it will fprintf “You win.”
- If the numbers do not match up it will fprintf “You lose”.
HANGMAN
- A game for the play to guess a word by guessing each letter
- A text file named “engmix.txt was used to in the generation of this game. The text file has over 84,000 words which makes the game very interactive and mind challenging because the player does not see the same words everytime they play
- A while loop was created so the player keeps playing until they chose not to play again
- A variable “dictionary was created to convert data into strings
- A variable was created to get a random word for the player to guess
- The variable “guesses” counts the number of letters in the word for the player to guess
- The variable “Turns” gives the number of times the player can guess the letters in a generated word. the least number of turns is 10 guesses. the player has 10 guesses or turns to guess a word that has 5 letters or less. For any word above 5 letters, the player gets the number / length of the word + 5 guesses.
- Example if the word generated is a 7 letter word. the player has 12 turns to guess(7+5) and if its a 10 letter word the player has 15 turns to guess.
- the game welcomes the player to hangman.
- the code tells the player the number of turns the have to guess the specified letter word. ” you have 13 guesses to this 8 letter word”
- The loop makes sure the player can keep playing whiles they are not out of turns(guesses) and still have letters of the word to reveal.
- A function “disp-words “was created to check the input of the player and to identify the index or the location of the guess letter in the word and show it to the player
- Call the function to check If the player guess a right letter the game displays right guess and displays the output of the word with the right letters in the right location
- if the input was wrong, the game displays wrong guess and does not change the output of the word the player is supposed to guess
- After every guess, the number of turns left to guess is shown to the player. After every guess the number of turns decreases by 1 and tells the player
- The player loses if the number of turns left to guess the word is zero and there are still some characters for the player to guess
- the game prints “Game Over! You Lost! Hangman” and tells the player the word.
- if player guesses all the letters of the word and before running out of turns then the game displays “Congratulations! You won. and tells the player the word by using fprint statements.
OVER 7, UNDER 7 OR 7
- The game was created by the function called “diceGame”
- the game starts by asking the player to input the amount they have in a variable called PayOut
- Player is then asked for the amount the want to bet on from their original amount and stored in the variable “bet”
- Exist conditions are created. if PayOut value which becomes the amount the player will be using as the games continues becomes less than 0 and ex is equal to 1 then game ends
- if the bet amount is greater than PayOut . the game displays “Not enough money, try a smaller amount using fprint
- to place their wager, the games ask players to choose 1 for Under 7 , 2 for over 7 and 3 or any number at all
- fprint states are used to display the type of bet the player choses
- the die are rolled using two random row vectors and added to get the total and stored in “Outcome”.
- if the outcome is <7 and the player chose 1( under 7), the PayOut is the original amount in the beginning + the bet amount and displays the amount and player wins by fprint statement .If the player loses PayOut is the original amount in the beginning – the bet amount. The same applies for over 7 when the Outcome is >7
- For Exactly 7 , the PayOut is the original amount in the beginning +4 times the bet amount and displays the amount and player wins by fprint statement .If the player loses PayOut is the original amount in the beginning – the bet amount.
- After each outcome , the game displays the PayOut, the player has now with fprint f statements
- if Payout is greater than zero then game asks the player if they want to continue or end the game using input function.
- if the PayOut is <= 0, the game over!
- if player ends game. Game Displays Thank you for playing .
CRAPS
- the game is run in a way such the Run button on Matlab serves as the play button
- whenever the player hits run it counts as the player rolling the die
-
If the sum is 7 or 11 on the first throw, the player wins.(ii) If the sum is 2, 3, or 12 on the first throw, the player loses.(iii) If the sum is 4, 5, 6, 8, 9 or 10 on the first throw, the sum becomes the player’s point. To win, you must continue rolling the dice until you make your point. However, the player loses by rolling a 7 before making the point”
- the row vector for die are created in D1 and D2
- n stores the sum if the output of the roll
- if the out is 7or 11 on the first run then You won is displayed by fprint statement
- if the outcome is 2,3, or 12 on the first run(roll) then the “You lost is displayed by fprintf statements.
- otherwise any other value from 1 to 12 , the wininng number is displayed an dplayer is asked to keep rolling
- if player wins on first run, the game ends and player needs to run the the game again to play.