This is an assignment for BU's CS611 course on "Object-oriented Software Principles and Design."
I implemented games including Tic Tac Toe, Super Tic Tac Toe, Order and Chaos, Quoridor utilizing Java and Object-Oriented Design (OOD) principles.
All of the games are extensions of BoardGame class.
- Display the row and column of the board
- User can enter either the 1-d index or 2-d position
- For some case (player name), user can press "Enter" for convenience and use the default value
- Display whose turn it is and what to do
- For some case (player name), user can press "Enter" for convenience and use the default value
- For some case (input int), user needs to keep entering contents until a valid input received
- For some case (position input), regular expression is utilized to accept different input style.
- Start from
pos
to eight directions formin(min_len_to_win, farthest_legal_pos)
steps, - Calculate the offset of consecutive positions which satisfy the
condition
.
- For judge-win,
pos
: newly entered positioncondition
: same symbol with that of the newly placed position
- For judge-stalemate,
- Consider possible winning scenarios:
pos
: all empty positionscondition
: same symbol of empty- Meanwhile, consider all symbols
- Analysis:
- When there are many empty spaces, very easy to win.
- When there are few empty spaces, no need to traverse the entire board.
- Consider possible winning scenarios:
- Tic Tac Toe, set or use the default width and height
- Order and Chaos, cannot set
- 2 or more teams, team members come on stage in turn
- Can play many rounds.
- Record results and display performance every round
- Can add more strategies in the future
- Add comments
- Add Factory Pattern
- Add color
- Clearer input instruction
- Enter "quit" or "exit" at any time to quit
- Rules: except for the common rules of TTT, for the SuperTTT, a winning occurs when there are win_len(default=3) continuous pieces, which have same symbols or at most 1 stalemate.
- Player can choose different colors as their representation
- Walls on the board are displayed in red, which is easier to distinguish.
- Available moves are shown in different color, which is easier for player to choose their action.
- Tile index are shown in color other than base board.
- Heuristic path finding techniques is used in the game to determine possible success, which took reference to A* algorithm and DFS. This prevents player from blocking the opponent permanently, which is according to the game rules.
- Similar to this, available move positions are calculated with jump considered.(jump over the opponent)
- Player can easily input their decisions by simply typing an index for player action, or four indexes for placing a wall.
- Created base classes like TileObject and Wall, which may be extended in future games without modification of existent structures.
- Created interfaces like GameFactories and JudgeFactories, which is encapsulated tightly for future use.
- The game can be easily scaled to other sizes.
- The team can contain multiple players.
- Color can be chosen by players.
|--Main
|--Engine
|--Board
|--Tile
|--TileObject
|--TilePiece
|--TileTTT
|--TilePieceWithWall
|--Piece
|--Wall
|--Color
|--GameFactory (interface)
|--BaseGame
|--TTT
|--OC
|--SuperTTT
|--Quoridor
|--JudgeFactory (interface)
|--BaseJudge
|--JudgeTTT
|--JudgeOC
|--JudgeSuperTTT
|--JudgeQuoridor
|--Team
|--Player
|--Performance
Run the following instructions:
mkdir out
javac *.java -d out
java -cp ./out Main