A full-featured Java chess application supporting both local and online play, with robust game analysis, persistence, and multiplayer capabilities.
- SQLite JDBC driver should be present in the
lib/directory.
- Open a terminal in your project root.
- Compile the project:
mvn clean compile
- Run the application:
mvn exec:java -Dexec.mainClass="Main"
- Compile all Java files:
javac -cp lib/sqlite-jdbc.jar -d out $(find src/main/java -name "*.java") - Run the application:
java -cp lib/sqlite-jdbc.jar:out Main
On Windows, use
;instead of:in the classpath:java -cp lib/sqlite-jdbc.jar;out Main
- Import the project (as a Maven project or standard Java project).
- Make sure
lib/sqlite-jdbc.jaris included as a library/dependency. - Set the main class to
Mainand run the project.
- Complete Chess Rules:
- All standard chess rules implemented, including special moves (castling, promotion), check/checkmate, and draw conditions. Note: En passant is not fully implemented or may not work correctly.
- Modern GUI:
- Interactive chessboard, move highlighting, turn/status display, move history, and responsive design.
- Game Analysis:
- Move validation with detailed error messages, game review with move-by-move replay, and PGN import validation.
- Persistence:
- SQLite database for saving/loading games, move history, and metadata (players, results, dates).
- PGN Support:
- Full import/export of games in Portable Game Notation (PGN) format.
- Multiplayer:
- Online play via client-server architecture, with real-time move synchronization and chat.
- Computer Opponent:
- Basic AI with random legal move selection and configurable difficulty.
- Time Controls:
- Configurable clocks, per-player time management, and timeout detection.
- Separation of Concerns: Game logic, data, and presentation are clearly separated.
- Event-Driven: User interactions trigger appropriate controller actions.
- User interacts with View components
- View notifies Controller of actions
- Controller updates Model state
- Model notifies View of changes
- View updates display accordingly
- Database: Centralized data management (
server/Database/) - GM: Game analysis and validation logic (
server/GM/) - Model: Maintains piece positions and board state (
client/NewGUI/Model/) - Controller: Mediates between model and view (
client/NewGUI/Controller/) - View: Swing-based UI components (
client/NewGUI/View/) - PGN Handling: Full import/export and parsing (
shared/PgnAnalyzers/) - Legacy: Previous implementations and compatibility (
shared/LegacyCore/,LegacyGUI/)
GameStateclass tracks board positions, turn order, and game status.- Implements all chess rules including:
- Basic piece movements
- Special moves (castling, promotion; en passant not fully implemented)
- Check/checkmate detection
- Draw conditions (stalemate, insufficient material)
- Each piece type (Pawn, Knight, etc.) implements its own movement logic.
ChessControllervalidates moves against game rules.- Legal move highlighting in the UI.
- Full Portable Game Notation import/export.
- Move logging in PGN format.
- Game metadata (player names, result, date) storage.
GameWindow: Main application frameChessBoardUI: Interactive chess board with piece renderingSquareView: Individual board square implementationStartMenu: Game configuration dialog
- Piece highlighting for selection
- Legal move indicators
- Turn and game status display
- Move history panel
- Configurable game modes (human/computer players)
- Adjustable time controls
- Game over detection and result display
- SQLite database for game persistence
- Tables for games and individual moves
- Metadata storage (players, results, dates)
- Operations:
- Save/load complete games
- Query game history
- Import/export to PGN format
- Game review functionality
- Implementation:
DatabaseManagerhandles all DB operations- JDBC for database connectivity
- Transaction support for data integrity
- Client-server model
- TCP sockets for communication
- Object serialization for message passing
- Protocol:
- Custom message format (
Messageclass) - Defined operations (move, chat, etc.)
- Game state synchronization
- Custom message format (
- Features:
- Player matching system
- Move validation on server
- Real-time chat
- Game result recording
- Game Analysis:
- Move validation with detailed error messages
- Game review system with move-by-move replay
- PGN import validation
- Computer Opponent:
- Random legal move selection
- Concurrency:
- Multithreaded server
- Background game clock
- Asynchronous move processing
- Error Handling:
- Comprehensive validation
- Custom exceptions
- Error logging system
Board: Maintains piece positions and board statePiece: Abstract base class for all chess piecesPosition: Represents board coordinatesMove: Encapsulates move information with Builder pattern
ChessController: Mediates between model and viewGameMaster: Handles move validation and game rulesPGNReader: Parses PGN files into game data
- Swing-based UI components
- Custom rendering for chess pieces
- Responsive design for different window sizes
- Run
Main.java- The main GUI appears with options:
- Import PGN: Import chess games from PGN files
- Export to PGN: Export player games from the database into a PGN file
- Play Game: Start a new game with the modern GUI
- Open Game from DB: Browse and replay games from database
- Quit: Exit the application
- The main GUI appears with options:
- Click "Import PGN"
- Select a PGN file
- Use the Select button to import a specific game from the PGN file, or use Import All to database to import all games.
- Games are imported to the database for later review
- Click "Open Game from DB"
- Select a game from the database
- Use replay controls to step through moves
- Dependencies:
- Java 17+
- SQLite JDBC driver (included in
lib/)
- Compile:
- Use your preferred IDE or run:
javac -cp lib/sqlite-jdbc.jar src/main/java/**/*.java
- Use your preferred IDE or run:
- Run:
- From your IDE, run
Main.java, or use:java -cp lib/sqlite-jdbc.jar:src/main/java Main
- From your IDE, run
- Implementing all chess rules correctly
- Handling special cases like en passant
- Check detection without infinite recursion
- Maintaining consistent game state in network play
- Handling disconnections
- Turn management between players
- Efficient board representation
- Minimizing UI repaints
- Database query optimization
- Nani Chkhenkeli, Saba Danelia