This project implements a two-player Scrabble game where a human player competes against a computer opponent. The game features a graphical user interface built with JavaFX and includes separate components for score checking and move solving.
- Two-player game: Human vs. Computer
- Graphical user interface using JavaFX
- Customizable computer player difficulty (Easy, Medium, Hard)
- Score tracking and display
- Tile placement with drag-and-drop functionality
- Word validation using a provided dictionary
- Special tile effects (double/triple letter/word scores)
- Separate solver component for finding optimal moves
- Score checking component for validating plays
- Ensure you have Java 8 or higher installed on your system.
- Clone this repository or download the source code.
- Compile the Java files or use the provided JAR files.
The project consists of three main components, each with its own JAR file and specific way to provide input:
To run the score checker:
java -jar scorechecker.jar sowpods.txt < example_score_input.txt > your_output.txt
sowpods.txt: The dictionary file to use for word validation.- Input is redirected from
example_score_input.txt. - Output is redirected to
your_output.txt.
To run the main Scrabble game with GUI:
java -jar scrabble.jar sowpods.txt scrabble_board.txt
sowpods.txt: The dictionary file to use for word validation.scrabble_board.txt: The initial board configuration file.
To run the solver:
java -jar solver.jar sowpods.txt scrabble_tiles.txt example_input.txt > your_solver_output.txt
sowpods.txt: The dictionary file to use for word validation.scrabble_tiles.txt: The file containing tile configurations and scores.example_input.txt: The input file with the board state and available tiles.- Output is redirected to
your_solver_output.txt.
Note: If you don't provide an input file for the solver, it will read from standard input.
- Run the main Scrabble game as described above.
- The game board will be displayed along with your tile rack.
- To make a move:
- Click the "Place Tiles" button.
- Choose the play direction (Horizontal or Vertical).
- Click on a tile in your rack, then click on the board to place it.
- Repeat for each tile you want to play.
- Click "Make Move" to submit your word.
- Use the "Undo Last Move" button to remove the last placed tile.
- Click "Forfeit Turn" if you can't make a move (not allowed on the first turn).
- The computer will automatically make its move after you.
- The game ends when all tiles are used or no more valid moves can be made.
You can adjust the computer player's difficulty using the dropdown menu:
- Easy: The computer will play suboptimal moves.
- Medium: The computer will play moderately strong moves.
- Hard: The computer will always try to play the highest-scoring move possible.
- The game uses a Trie data structure for efficient word lookup and validation.
- A backtracking algorithm is employed to generate possible moves for the computer player.
- The
ScrabbleMoveGeneratorclass handles move generation and scoring. - The GUI is implemented using JavaFX, with custom components for the game board and tile rack.
GameGui.java: Main class for the graphical user interfaceGameManager.java: Manages the game state and flowGameBoard.java: Represents the Scrabble boardComputerPlayer.java: Implements the AI for the computer playerDictionary.java: Handles word validationScrabbleMoveGenerator.java: Generates and evaluates possible movesSolver.java: Standalone component for finding optimal movesScoreChecker.java: Validates and scores plays
- There are some issues with solver.jar that I don't have energy or time to fix. Sometimes my solver finds a better move though... 8-)
- The game currently does not support loading custom dictionaries at runtime.
- There is no option to exchange tiles during a turn.
- Implement network play for human vs. human matches
- Add support for custom dictionaries
- Improve the GUI with animations and sound effects