D. Final Algorithm, Flowchart, or Pseudocode

Othello: Pseudocode

Yu-Shiang Jeng

Play

DO Initialize

WHILE (DO IsGameOver)
  DO DisplayStatus
  DO MakePlayerMove
  DO SetNextPlayerTurn
ENDWHILE

WRITE winner = DO GetWinningPlayer
DO AnnounceWinner

Initialize

WRITE playerWantsToQuit = false
WRITE noPlayersCanMove = false

DO InitializeBoard

IsGameOver

IF playerWantsToQuit
  RETURN true
ENDIF

IF noPlayersCanMove
  RETURN true
ENDIF

RETURN false

MakePlayerMove

IF (NOT (DO CanPlayersMove))
  WRITE noPlayersCanMove = true
  RETURN
END

IF (NOT (DO CanPlayerMove))
  PRINT "You have no available moves"
  PRINT "Your turn will be passed"
  RETURN
END

REPEAT
  WRITE move = DO GetPlayerMove;

  IF (move == quitFlag)
    WRITE playerWantsToQuit = true
    RETURN
  ENDIF

UNTIL (DO IsLegalMove)

DO SetSpaceWithFlanks

CanPlayersMove

FOREACH player
  IF (DO CanPlayerMove)
    RETURN true
  END
ENDFOREACH

RETURN false

CanPlayerMove

FOREACH spaceOnBoard
  IF (DO IsLegalMove)
    RETURN true
  END
ENDFOREACH

IsLegalMove

IF (NOT (DO IsOnBoard))
  RETURN false
END

IF (NOT (DO IsEmptyPiece))
  RETURN false
END

IF (NOT (DO IsFlankingMove))
  RETURN false
END

RETURN true

IsFlankingMove

WRITE endpoints = DO GetFlankEndpoints
RETURN (DO IsEmpty(endpoints))

GetFlankEndpoints

flankSteps = DO GenerateFlankSteps
READ originalPos

FOREACH flankStep
  WRITE stepPos = originalPos + flankStep

  IF (DO IsOnBoard || DO IsEmptyPiece || DO IsSamePiece)
    WRITE endpoint = NULL
    CONTINUE
  ENDIF

  REPEAT
    WRITE stepPos = originalPos + flankStep
  UNTIL (NOT (DO IsOnBoard) || DO IsEmptyPiece || DO IsSamePiece)

  IF (NOT (DO IsOnBoard) || DO IsEmptyPiece)
    WRITE endpoint = NULL
  ELSEIF (DO IsSamePiece)
    WRITE endpoint = stepPos
  ENDIF

  APPEND endpoint TO endpoints
ENDFOREACH

RETURN endpoints

Craps: Algorithm

Shawn Berry, Mikey Zedan

  1. Clear variables and screen
  2. Load the dice images from the file
  3. Suppress all warnings from MATLAB
  4. Shuffle all random number generator possibilities
  5. Ask the user to input how much money they have to spend
  6. If funds are above 0, move to step 7, if not, the game ends
  7. Ask how much the user wants to bet on the game, do not let user bet a negative amount or more than they have
  8. Tell the user to press enter to roll the dice
  9. Display the roll on-screen as a picture
  10. Pause the program
  11. Check if the roll adds up to 7 or 11, if yes, jump to step 18, if no, continue to step 12
  12. Check if the roll adds up to 2,3 or 7, if yes, jump to step 19, if no, continue to step 13
  13. Tell the user to roll again
  14. Repeat steps 9-10
  15. If the roll adds up to 7, jump to step 19, if no continue to step 16
  16. If the roll is equal to the first roll, jump to step 18, if roll is not equal, continue to step 17
  17. Keep rolling, if new roll is equal to first roll, continue to step 18, if not, skip to step 19
  18. Display that the user wins and add their bet to their available funds, go to step 20
  19. Display that the user wins and subtracts their bet from their available funds, go to step 20
  20. Display the user’s funds
  21. Tell user to press enter if they want to play again, and loop starts again