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