Skip to content

A clean, modular implementation of chess in Java using JavaFX for the GUI with a simple AI opponent, FEN-based game logic and a puzzle system.

License

Notifications You must be signed in to change notification settings

hadiranadev/java-chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess

A clean, modular implementation of chess in Java using JavaFX for the GUI.

Includes a simple AI opponent, FEN-based game logic, and an integrated puzzle system with support for mate-in-1 and mate-in-2 solutions.

Demo

Built with JavaFX – real-time move animation, theme support, and puzzle interaction.


Overview

This is a full chess engine and GUI written entirely in Java with a big emphasis on expandability:

  • The engine is rule-complete: legal move generation, checkmate/stalemate detection, and repetition tracking.
  • The AI uses a lightweight heuristic-based evaluation for fast local play.
  • Puzzles are JSON-driven and support forced mates, hints, and move-order validation.
  • The UI is fully themeable, supporting multiple board and piece styles (Classic and Neo are added already). Could easily be expanded with a directory with a CSS file and PNGs for Pieces.
  • Everything is modular – logic and rendering layers are fully separated.

The goal here wasn't to make Stockfish, it was to make my own chess environemnt that behaves predictably, runs anywhere, and can grow with future features like better AI, board setup tools, and improved puzzles.

Demo


Running & Setup

This project uses Maven, so no manual JavaFX installation/config is required

To run the project, use:

mvn -DskipTests exec:java

Note: Java 17+ required. Java 21 is recommended since that's what development and testing were done on.


Features

  • Full chess rules with check, checkmate, stalemate, and repetition detection.
  • Puzzle mode with forced mates, hints, and step-by-step validation.
  • Two board themes (Classic & Neo) with easy extensibility.
  • Lightweight AI for casual play.
  • Keyboard & button-based control flow.
  • JSON-based puzzle definitions — easy to expand or modify.
  • Simple and fast: no external engines, no dependencies beyond JavaFX.

Demo


Project Structure

.
├── LICENSE                 # MIT license.
├── pom.xml                 # Mavn + JavaFX config.
├── assets/                 # Images/GIFs.
├── src/
│   ├── main/
│   │   ├── java/com/dev/chess/
│   │   │   ├── ai/         # simple AI opponent.
│   │   │   ├── engine/     # core rules, evaluation, repetition.
│   │   │   ├── logic/      # move generation and rule checking.
│   │   │   ├── model/      # data structures: board, move, piece, etc.
│   │   │   ├── puzzles/    # puzzle model + loader
│   │   │   └── ui/         # JavaFX UI and command-line mode
│   │   └── resources/
│   │       ├── puzzles/    # puzzles.json file.
│   │       └── themes/     # board and piece themes
│   └── test/               # empty placeholder for now.
└── target/                 # maven build output

Developer Notes

This project evolved naturally from earlier text-based simulaotrs into a fully visual chess platform.

Some key design decisions that I made included:

  • Everything is pure Java with no external engines or libraries which gives full portability and control.
  • FEN-based architecture where any position can be serialized.
  • Puzzle integration with a JSON loader which will allow for easy importing with ELO and other motifs later (i.e. capture sequence, mate in four, etc).
  • Theme system with board style additions being as easy as dropping a /theme.css and piece set folder under /resources/themes/.
  • UI independence with the engine perfect for both CLI, testing or AI-only stuff in the future.

This marks version one of this project, though. Future expansions will include:

  • Better AI depth, possibly evaluation.
  • Theme-tagged puzzles with larger pool and motifs.
  • Visual board setup and play.
  • Puzzle pipeline: Position -> FEN -> new puzzle with minimal changes in puzzles.json.
  • UX polish, stats tracking.

License

MIT (see LICENSE)


Credits

Designed and written by Hadi Rana

UI refined via ChatGPT as a collaborative programming assistant used for architecture feedback, not raw code generation.

About

A clean, modular implementation of chess in Java using JavaFX for the GUI with a simple AI opponent, FEN-based game logic and a puzzle system.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published