Skip to content

SignalByNick/Hyperion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyperion ⚡♟️

A C++20 engine core for the standard 14×14 cross-shaped four-player chess board shown in the reference image. The board uses 196 addressable grid indices inside a custom 256-bit bitboard, with the 36 invalid corner squares masked out to leave 160 playable squares.

Performance design

  • alignas(32) four-limb uint256_t
  • Compile-time board masks, king attacks, knight attacks, pawn attacks, and rays
  • Incrementally maintained piece, color, and total occupancy
  • Mailbox lookup for constant-time captured-piece identification
  • Zobrist hashing updated during make/undo
  • Fixed-capacity move lists with no heap allocation
  • Ray-scan slider attacks using nearest-blocker bit scans
  • Optional BMI2/PEXT compressed directional attack tables (benchmarkable, not assumed faster)
  • Exact make/undo and null-move restoration

Classic 8×8 multiplication-based magic bitboards do not transfer cleanly to an irregular 160-square board. Hyperion therefore includes a magic-style PEXT backend: each directional ray is compressed into a small occupancy index and looked up in a precomputed attack table. It uses about 18 MiB and falls back to the ray scanner on processors without BMI2. The ray scanner is the default because it benchmarked faster on the build machine; the included benchmark lets you choose correctly for your CPU.

Both backends are tested against each other for random occupancies.

Implemented engine functions

position.inCheck();
position.inCheck(Color::Red);
position.givesCheck(move);

position.doMove(move, state);
position.undoMove(move, state);

position.canDoNullMove();
position.doNullMove(state);
position.undoNullMove(state);

movegen::generateMoves(position, moves);
movegen::generateCaptures(position, moves);
movegen::is_legal(position, move);
movegen::isCheckmate(position);
movegen::isStalemate(position);
movegen::perft(position, depth);

Rules represented

  • Red moves north
  • Blue moves east
  • Yellow moves south
  • Green moves west
  • Turn order: Red → Blue → Yellow → Green
  • Team mode: Red/Yellow vs Blue/Green
  • Free-for-all mode is also supported
  • Teammate pieces are friendly blockers and cannot be captured
  • Four-direction pawn movement and capture tables
  • Double pawn pushes
  • Promotion on each player’s 11th rank to queen, rook, bishop, or knight
  • En passant state and make/undo logic
  • Color-specific castling geometry
  • Legal move filtering against self-check

Starting position

The included start position matches the supplied board:

  • Red: R N B Q K B N R on d1k1
  • Blue: R N B K Q B N R on a4a11
  • Yellow: R N B K Q B N R on d14k14
  • Green: R N B Q K B N R on n4n11

Each side has eight pawns on the adjacent line.

Visual Studio

Open the extracted folder directly:

File → Open → Folder

Select Hyperion x64 Debug while developing and Hyperion x64 Release for perft and benchmarks. Use x64-release-pext only when your local benchmark shows the compressed tables are faster.

Build and test from a Developer PowerShell:

cmake --preset x64-release
cmake --build --preset x64-release
ctest --preset x64-release

Run:

.\out\build\x64-release\Hyperion.exe
.\out\build\x64-release\hyperion_benchmark.exe

Project layout

Hyperion.cpp                 Demo executable
Hyperion.h                   Umbrella include
include/hyperion/bitboard.hpp
include/hyperion/board.hpp
include/hyperion/attacks.hpp
include/hyperion/move.hpp
include/hyperion/position.hpp
include/hyperion/movegen.hpp
src/attacks.cpp
src/position.cpp
src/movegen.cpp
tests/engine_tests.cpp
benchmarks/benchmark.cpp

Important next layers

This package is the board and legal-move core. A competitive engine should build the following on top:

  1. Transposition table
  2. Iterative deepening and aspiration windows
  3. Alpha-beta/PVS search
  4. Quiescence search
  5. Null-move pruning using the included null-move API
  6. Late-move reductions
  7. Killer/history/countermove ordering
  8. Static exchange evaluation adapted for four players
  9. Team-aware evaluation
  10. Repetition and terminal-state handling

Before using null-move pruning, the search must also handle zugzwang safeguards and must never null-move while the current king is in check.

Documentation

About

Hyperion is a high-performance chess engine built specifically for four-player teams chess.

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages