Skip to content

Atseiro/Java_Chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Chess Game

A JavaFX-based chess game implementation with both standard chess rules and a custom variant mode.

Features

Game Modes

  • Standard Chess: Traditional chess with classic rules and piece movements
  • Variant Mode: Custom chess variant with additional piece types and modified rules

Gameplay Features

  • ✅ Interactive GUI built with JavaFX
  • ✅ Turn-based gameplay (White vs Black)
  • ✅ Legal move validation
  • ✅ Check detection and highlighting
  • ✅ Move highlighting (selected piece and valid moves)
  • ✅ Surrender options for both players
  • ✅ Visual piece representation with custom images

Piece Types

Standard Pieces

  • King (K/k)
  • Queen (Q/q)
  • Rook (R/r)
  • Bishop (B/b)
  • Knight (N/n)
  • Pawn (P/p)

Variant Pieces

  • VAR1 (V/v)
  • VAR2 (S/s)
  • VAR3 (M/m)

Technical Specifications

  • Language: Java 20
  • Framework: JavaFX 20
  • Build Tool: Maven
  • Testing: JUnit 5.9.2
  • Architecture: MVC Pattern

Project Structure

src/
├── main/
│   ├── java/
│   │   ├── board/           # Chess board logic
│   │   │   ├── Board.java
│   │   │   ├── FictiveBoard.java
│   │   │   ├── Rules.java
│   │   │   └── Tile.java
│   │   ├── main/            # Application entry and controllers
│   │   │   ├── ChessApplication.java
│   │   │   └── ChessController.java
│   │   ├── pieces/          # Piece definitions and move logic
│   │   │   ├── Move.java
│   │   │   ├── Piece.java
│   │   │   └── PieceType.java
│   │   └── module-info.java
│   └── resources/
│       └── main/
│           └── chess.fxml   # JavaFX UI layout

Prerequisites

  • Java Development Kit (JDK) 20 or higher
  • Maven 3.6+ for build management
  • JavaFX 20 runtime (handled by Maven dependencies)

Installation & Setup

  1. Clone the repository:

    git clone <repository-url>
    cd Java_Chess
  2. Build the project:

    mvn clean compile
  3. Run the application:

    mvn javafx:run

    Or using the wrapper:

    # Windows
    .\mvnw.cmd javafx:run
    
    # Unix/Linux/macOS
    ./mvnw javafx:run

How to Play

  1. Launch the game - A welcome window will appear with game mode selection
  2. Choose game mode:
    • Mode Normal: Standard chess rules
    • Mode Variant: Custom variant with special pieces
  3. Game Controls:
    • Click on a piece to select it (only pieces of the current player's turn)
    • Valid moves will be highlighted in green
    • Click on a highlighted square to move the piece
    • Click elsewhere to deselect the current piece
  4. Surrender Options:
    • A surrender window allows either player to forfeit the game
    • Choose "Abandon blancs" (White surrenders) or "Abandon noirs" (Black surrenders)

Game Rules

Standard Mode

  • Follows traditional chess rules
  • All standard piece movements and special moves
  • Check detection with red highlighting
  • Turn-based play alternating between white and black

Variant Mode

  • Modified starting position: msvbkvsm/p1pppp1p/1pp2pp1/8/8/1PP2PP1/P1PPPP1P/MSVBKVSM
  • Includes three special piece types (VAR1, VAR2, VAR3)
  • Different win condition: Game ends when a player is in check (inverse of checkmate)

Board Representation

The game uses FEN (Forsyth-Edwards Notation) for initial board setup:

  • Standard: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
  • Variant: msvbkvsm/p1pppp1p/1pp2pp1/8/8/1PP2PP1/P1PPPP1P/MSVBKVSM

Visual Elements

  • 8x8 chessboard with alternating light (240,217,181) and dark (181,136,99) squares
  • Piece images with transparent backgrounds
  • Green highlighting for selected pieces and valid moves
  • Red highlighting for pieces in check
  • 80x80 pixel tile size for optimal visibility

Development

Building from Source

mvn clean compile

Running Tests

mvn test

Creating Distribution

mvn clean package

Dependencies

  • JavaFX Controls & FXML (v20): UI framework
  • JUnit Jupiter (v5.9.2): Testing framework
  • Maven Compiler Plugin (v3.11.0): Java 20 compilation
  • JavaFX Maven Plugin (v0.0.8): JavaFX application execution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages