How wilsoncespedes-dot/ajedrez- works
Purpose and execution surfaces
This repository models chess-piece movement in Java and provides a standalone browser visualizer of the same rules. It is a movement model, not a full chess engine: check, checkmate, castling, en passant, and pawn promotion are outside its scope.
Java console entry point: ModeladorAjedrez/src/ajedrez/features/juego/Main.java.
Browser entry point: ModeladorAjedrez/interfaz/index.html; it runs directly in a browser and is independent of the Java runtime.
Core domain model
ModeladorAjedrez/src/ajedrez/core/Color.java defines the two sides.
ModeladorAjedrez/src/ajedrez/core/Posicion.java represents board coordinates and chess notation (a1 through h8).
ModeladorAjedrez/src/ajedrez/core/Pieza.java is the abstract base contract for all pieces, carrying shared identity/state and the movement interface.
The central boundary is that piece-specific logic depends on the core abstractions, while core does not depend on concrete piece types.
Board state and move boundary
ModeladorAjedrez/src/ajedrez/core/Tablero.java owns the 8×8 board state and provides placement, movement, and piece lookup. It is the authoritative Java state container used by movement calculations.
Primary Java flow: a caller constructs/configures a Tablero, places Pieza instances, asks a selected piece for legal movement destinations against that board, then requests the board to move the piece. Captures are represented by replacing/removing the occupant at a destination rather than through a separate game-service layer.
Piece-rule polymorphism
Each chess type is a concrete Pieza implementation:
• ModeladorAjedrez/src/ajedrez/features/piezas/Peon.java
• ModeladorAjedrez/src/ajedrez/features/piezas/Torre.java
• ModeladorAjedrez/src/ajedrez/features/piezas/Caballo.java
• ModeladorAjedrez/src/ajedrez/features/piezas/Alfil.java
• ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java
• ModeladorAjedrez/src/ajedrez/features/piezas/Rey.java
Their defining responsibility is movimientosPosibles(Tablero): each evaluates destinations using position, color, board occupancy, and capture rules. Sliding pieces stop at blockers; movement validity is local to pieces and does not incorporate king-safety rules.
Console demonstration
ModeladorAjedrez/src/ajedrez/features/juego/Main.java composes the Java model into a deterministic demo: it initializes a board, displays it, queries the white queen’s moves, moves a pawn, and displays the resulting state. It is not an interactive game loop or service endpoint.
The Java runtime requires a JDK; compilation is performed directly over the source tree without a declared build system.
Independent HTML visualizer
ModeladorAjedrez/interfaz/index.html contains the interactive UI and a JavaScript translation of the Java movement rules. It initializes a standard board, tracks turns, highlights destinations, applies moves/captures, records moves, displays selected-piece metadata, and can reset state.
This is a behavioral duplication boundary: the HTML implementation does not call, compile, or embed the Java model. Rule changes must therefore be kept synchronized manually across src/ajedrez/features/piezas/ and interfaz/index.html.
External dependencies and infrastructure
There are no indicated databases, network APIs, backend services, package managers, or deployment infrastructure. Material runtimes are the JDK for the console model and any modern browser for the visualizer.
Main entry points: Pieza.java Pieza · Tablero.java Tablero · Reina.java Reina rules · Main.java Console demo
Components 14
Java movement model
- Console demo · Runs a deterministic board and move demonstration.
ModeladorAjedrez/src/ajedrez/features/juego/Main.java - Tablero · Owns the authoritative 8×8 Java board state and moves.
ModeladorAjedrez/src/ajedrez/core/Tablero.java - Pieza · Shared piece state and movement interface.
ModeladorAjedrez/src/ajedrez/core/Pieza.java - Posicion · Board coordinates and chess notation.
ModeladorAjedrez/src/ajedrez/core/Posicion.java - Color
ModeladorAjedrez/src/ajedrez/core/Color.java
Piece rules
- Peón rules
ModeladorAjedrez/src/ajedrez/features/piezas/Peon.java - Torre rules
ModeladorAjedrez/src/ajedrez/features/piezas/Torre.java - Caballo rules
ModeladorAjedrez/src/ajedrez/features/piezas/Caballo.java - Alfil rules
ModeladorAjedrez/src/ajedrez/features/piezas/Alfil.java - Reina rules
ModeladorAjedrez/src/ajedrez/features/piezas/Reina.java - Rey rules
ModeladorAjedrez/src/ajedrez/features/piezas/Rey.java
Browser visualizer
- Interactive visualizer · Standalone UI with translated movement rules and board state.
ModeladorAjedrez/interfaz/index.html - UI board and turns · Initializes pieces, tracks selection and turns, and applies captures.
ModeladorAjedrez/interfaz/index.html - JavaScript move rules · Independent translation of Java piece movement logic.
ModeladorAjedrez/interfaz/index.html
Connections 18
- Console demo → Tablero: creates and displays
- Console demo → Reina rules: queries moves
- Tablero → Pieza: places and moves
- Pieza → Posicion: uses
- Pieza → Color: uses
- Peón rules → Pieza: implements
- Torre rules → Pieza: implements
- Caballo rules → Pieza: implements
- Alfil rules → Pieza: implements
- Reina rules → Pieza: implements
- Rey rules → Pieza: implements
- Peón rules → Tablero: evaluates occupancy
- Torre rules → Tablero: evaluates blockers
- Alfil rules → Tablero: evaluates blockers
- Reina rules → Tablero: evaluates destinations
- Interactive visualizer → UI board and turns: runs
- UI board and turns → JavaScript move rules: requests legal moves
- JavaScript move rules → Pieza: manually mirrors · Changes must be synchronized; no runtime integration exists.