D. Final Algorithm, Flowchart, or Pseudocode

For Black Jack Dawg

For the Yahtzee Dawg:

1. Start Game:

Display: “Welcome to Yahtzee!”

2. Initialize Game Environment:

Clear MATLAB environment: clc; clear; close all;
Set sprite size, zoom factor, and background color.
Initialize game engine with sprite sheet: simpleGameEngine(‘retro_dice.png’, spriteSize, spriteSize, zoomFactor, backgroundColor);
Define variables for dice faces (faceSprites = 11:16;), selected/unselected dice sprites (unselectedDieSprite = 2; selectedDieSprite = 7;), current player, total rounds (13), scoring categories, and their descriptions.

3. Player Setup:

Prompt for number of players: numberOfPlayers = input(‘Enter the number of players: ‘);
Validate input: Ensure it’s a positive integer.
Initialize score tracking: playerScores = zeros(numberOfPlayers, totalRounds);
Initialize categories chosen tracking: categoriesChosen = zeros(numberOfPlayers, totalRounds);

4. Main Game Loop (For Each Round):

For currentRound = 1 to totalRounds:
For currentPlayer = 1 to numberOfPlayers:
Display current round and player’s turn.

5. Player’s Turn:

Roll dice: diceRolls = randi(6, 1, 5);
Map dice roll numbers to their corresponding face sprites.
Set dice backgrounds to indicate unselected state.
Update game display with dice and scoring categories.

6. Dice Rolling and Re-rolling:

Allow up to two additional re-rolls per player.
For each re-roll:
Ask player if they want to re-roll any dice.
If “no”, highlight all dice and proceed to scoring.
If “yes”, ask which dice to keep and validate input.
Re-roll unkept dice and update display.

7. Scoring the Roll:

Display scoring categories in the command window.
Prompt player to choose a scoring category.
Validate category choice.
Calculate and update score based on chosen category and dice outcome.

8. End of Player’s Turn:

Check if all players have played in the current round.
If yes, proceed to the next round.
If no, continue with the next player’s turn.

9. End of Game:

After all rounds are completed:
Calculate total scores for each player, including bonuses.
Determine the winner(s) based on the highest score.
Announce the winner(s).
Ask players if they want to play another game.

10. Game Conclusion:

If players choose to play again, restart the game.
If not, end the game session.

11.End of Algorithm:

Display: “Thank you for playing Yahtzee!”