Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

SpeedChess for QNX Neutrino RTOS

SpeedChess is a high-performance, ultra-low-latency real-time multiplayer chess engine and application built for competitive tournaments on QNX Neutrino RTOS (x86_64 / aarch64) using C++17, powered by the Stockfish AI engine.

SpeedChess P2P UDP Multiplayer Demo


🚀 Features

  • Bitboard Move Engine: Hyper-fast 64-bit bitboard representation with ray-casting attack generation, FEN parsing/serialization, and Perft verification suite.
  • Authoritative State Machine: Deterministic game state manager (IDLE, PLAYING, PAUSED, GAME_OVER) controlling turn transitions, legal move filtering, move history, and checkmate/stalemate/50-move rule detection.
  • Stockfish AI Integration: UCI subprocess bridge communicating with Stockfish via posix_spawn and POSIX pipes. Supports 1-20 difficulty levels and asynchronous thinking.
  • Real-Time Chess Clock: High-resolution, drift-free 10ms chess clock using POSIX microkernel timers with Fischer increment support.
  • Peer-to-Peer UDP Multiplayer: Low-latency networking protocol built directly on UDP with custom sequence reliability, automated handshake, and live RTT latency monitoring.
  • Rich ANSI Terminal Interface: Feature-rich interactive console UI with ANSI background colors, Unicode/ASCII chess piece rendering, side-by-side captured material panel, and setup wizard.
  • Graphical User Interface (GUI) (Under Active Development): Hardware-accelerated SDL2 graphical chessboard featuring drag-and-drop piece movement, piece sliding lerp animations, and sound effects.

🛠️ Requirements & Environment

  • Target OS: QNX Neutrino RTOS 8.0 / 7.x (x86_64 / aarch64)
  • Host Compiler: QNX SDP 8.0 (qcc / q++ targeting GCC 12.2)
  • Standard: C++17
  • IDE: QNX Momentics IDE (Eclipse-based)

📁 Directory Structure

SpeedChess_Using_QNX/
├── plan                           # Architecture specification document
├── README.md                      # Project documentation
├── .gitignore                     # Git ignore rules
└── SpeedChess/                    # Application source root
    ├── Makefile                   # QNX recursive Makefile
    ├── docs/
    │   └── multiplayer_demo.png   # Terminal screenshot
    └── src/
        ├── common/                # Core types, move logic & bitboard engine
        │   ├── types.h
        │   ├── move.h
        │   ├── board_state.h / .cpp
        │   ├── move_generator.h / .cpp
        │   └── protocol.h
        ├── game_manager/          # State machine & game lifecycle
        │   ├── game_state.h / .cpp
        │   └── game_manager.h / .cpp
        ├── clock_manager/         # Real-time chess clock
        │   └── chess_clock.h / .cpp
        ├── stockfish_bridge/      # Stockfish UCI process bridge
        │   ├── engine_config.h
        │   └── uci_engine.h / .cpp
        ├── network_manager/       # UDP P2P multiplayer engine
        │   ├── udp_socket.h / .cpp
        │   ├── network_protocol.h
        │   └── network_manager.h / .cpp
        ├── terminal_ui/           # ANSI Terminal interface
        │   └── terminal_ui.h / .cpp
        └── main.cpp               # Test suite & main application entry

🛠️ Building the Project

Command Line (QNX Environment)

Open a terminal with QNX SDP environment variables sourced (qnxsdp-env.bat on Windows):

# Navigate to the application source directory
cd SpeedChess

# Build debug profile for QNX x86_64
make PLATFORM=x86_64 BUILD_PROFILE=debug

# Rebuild from scratch
make rebuild PLATFORM=x86_64 BUILD_PROFILE=debug

The output binary will be created at: build/x86_64-debug/SpeedChess.

Via QNX Momentics IDE

  1. Open QNX Momentics IDE.
  2. Select File → Import → C/C++ → Existing Code as Makefile Project.
  3. Point to d:\Projects\SpeedChess_Using_QNX\SpeedChess.
  4. Right-click project → Build Project.
  5. Select Run As → QNX C/C++ Application to deploy to your QNX VM or target hardware.

🌐 Playing P2P UDP Multiplayer

To run a 2-player network game across two terminals or QNX VMs:

  1. Host Instance (White / Player 1):
    ./SpeedChess
    host 5555
  2. Client Instance (Black / Player 2):
    ./SpeedChess
    join <HOST_IP> 5555
  3. Once connected, both peers automatically transition to PLAYING state and sync moves live over UDP!

🤖 Stockfish AI Cross-Compilation & Setup

To enable human vs AI (PvE) gameplay, cross-compile Stockfish for QNX Neutrino RTOS (x86_64) from the included stockfish submodule:

Cross-Compiling Stockfish for QNX x86_64

In Command Prompt (cmd.exe)

C:\Users\moham\qnx800\qnxsdp-env.bat
set EXTRACXXFLAGS=-D_QNX_SOURCE -D_POSIX_C_SOURCE=200809L
cd /d D:\Projects\SpeedChess_Using_QNX\stockfish\src
make -j4 build ARCH=x86-64 COMP=gcc CXX=x86_64-pc-nto-qnx8.0.0-g++ CC=x86_64-pc-nto-qnx8.0.0-gcc LDFLAGS="-lsocket" OS=QNX target_windows=no

Key Compilation Flags:

  • OS=QNX target_windows=no: Prevents Stockfish Makefile from misdetecting the Windows host as the target OS.
  • EXTRACXXFLAGS="-D_QNX_SOURCE -D_POSIX_C_SOURCE=200809L": Exposes POSIX system calls (open, close, fstat) in QNX 8.0 strict C++17 headers.
  • LDFLAGS="-lsocket": Links QNX socket runtime libraries.

The cross-compiled ELF binary will be generated at stockfish/src/stockfish.

Deployment & Execution

  1. Copy the compiled stockfish binary to your QNX target machine or VirtualBox VM (e.g. /tmp/stockfish or /opt/speedchess/stockfish).
  2. Mark the file executable on QNX:
    chmod +x /opt/speedchess/stockfish
  3. Launch SpeedChess specifying the engine path if using a custom location:
    ./SpeedChess --engine /opt/speedchess/stockfish
  4. If Stockfish is missing, local Human vs Human (PvP) and P2P Network modes remain 100% operational.

🎮 Interactive Console Commands

Launch SpeedChess on the QNX target to use the interactive CLI:

Command Description
host [port] Host a network multiplayer game (default port 5555)
join <ip> [port] Connect to a remote host
netstat Display UDP network connection status and RTT latency
setup Interactive wizard to configure Game Mode, Time Controls, & Difficulty
move <uci> (e.g. e2e4) Execute a move in UCI notation
moves List all legal moves in current position
board / refresh Redraw the board with ANSI colors and captured pieces
history Display full move history in 2-column format
unicode Toggle UTF-8 Unicode pieces (♙..♚) vs ASCII (P..K)
color Toggle ANSI background square colors
flip Rotate board 180 degrees (Black perspective)
pause / resume Pause or resume the real-time chess clock
resign Resign current game
quit Exit application

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages