Standard Portal Chess v1.1 - Rules and Gameplay
Welcome to Standard Portal Chess v1.1, a fascinating variant of traditional chess that introduces portals—special squares that allow pieces to teleport across the board. This game combines classic chess strategy with unique portal mechanics, offering a fresh and exciting challenge. Below are the complete rules and gameplay mechanics, derived straight from the game’s code.
Objective
The goal remains the same as in classic chess: to checkmate your opponent’s king—place it under an unavoidable threat of capture. However, portals add a twist, making strategic positioning and movement more dynamic.
Board Setup
- Size: The game is played on a standard 8x8 chessboard (64 squares).
- Initial Position: Pieces are set up as in traditional chess:
- White: Pawns on row 7 (rank 2), Rooks on a1 and h1, Knights on b1 and g1, Bishops on c1 and f1, Queen on d1, King on e1.
- Black: Pawns on row 2 (rank 7), Rooks on a8 and h8, Knights on b8 and g8, Bishops on c8 and f8, Queen on d8, King on e8.
- Portals: Eight portal squares are placed on the board, either in a predefined layout (e.g., from "dfp.txt") or customized by the player. These portals are empty at the start and must be on distinct squares.
Players and Turns
- Players: Two players—White (human) and Black (AI by default)—or self-play mode where one player controls both sides.
- Turn Order: White moves first, and turns alternate between White and Black.
- AI Mode: By default, Black is controlled by an AI using a minimax algorithm with a search depth of 3, evaluating moves based on piece value, center control, and mobility.
Piece Movement
All pieces move as in standard chess, with additional rules for portals:
- Pawn: Moves forward one square (or two from its starting rank), captures diagonally forward. Promotes to a Queen upon reaching the opponent’s back rank (row 1 for White, row 8 for Black) on a non-portal square.
- Knight: Moves in an L-shape (two squares in one direction, then one perpendicular).
- Bishop: Moves diagonally any number of squares.
- Rook: Moves horizontally or vertically any number of squares.
- Queen: Moves any number of squares diagonally, horizontally, or vertically.
- King: Moves one square in any direction (no castling in this version).
Note: Movement stops at a portal or piece (friendly or enemy). Capturing an enemy piece on a non-portal square works as usual.
Portal Mechanics
Portals are the defining feature of this game, allowing pieces to teleport instantly across the board. Here’s how they work:
- Entering a Portal: A piece can move to a portal square if:
- It’s empty, and at least one other portal is open (empty), or
- It contains an enemy piece, making the portal unoccupied after capture.
- Exiting a Portal: After entering a portal, the piece must exit to another open portal square (not the entry portal) that doesn’t leave the player’s king in check.
- Portal Move Process:
- Move to the entry portal (capturing if applicable).
- Select a safe exit portal from available options.
- The piece teleports to the exit, a new portal appears at the origin square, and one portal is removed from the entry square (maintaining exactly 8 portals).
- King and Check: A portal move is invalid if it leaves the king in check after exiting.
Key Rule: A piece cannot stay on the entry portal after capturing—it must exit to another portal, ensuring dynamic movement.
Game States
- Check: Occurs when a king is under threat of capture. The player must move the king, capture the threat, or block it (via portals if possible).
- Checkmate: If the king is in check and no legal move (standard or portal) can escape it, the game ends with the opponent winning.
- Stalemate: If a player has no legal moves and their king is not in check, the game ends in a draw.
Gameplay Features
- Interface: A graphical board with light and dark squares, portal tokens (blue circles), and piece images. Highlights show legal moves.
- Move History: Tracks all moves in algebraic notation (e.g., "White P: e2 to e4" or "Black Portal: e7 via d5 to f3").
- Portal Placement:
- Standard Game: Loads a default layout (e.g., "dfp.txt").
- Custom Game: Players place exactly 8 portals on empty squares before starting.
- Save/Load: Games and portal arrangements can be saved to and loaded from text files.
- Self-Play Mode: Toggle to control both sides manually.
AI Behavior
The AI (Black by default) uses a minimax algorithm with alpha-beta pruning to select moves, prioritizing:
- Capturing high-value pieces (Pawn: 1, Knight/Bishop: 3, Rook: 5, Queen: 9).
- Putting the opponent in check.
- Maintaining piece mobility and center control.
It evaluates all legal moves, including portal options, and chooses the best based on a calculated score.
Winning the Game
The game ends when:
- A player delivers checkmate, winning immediately.
- A stalemate occurs, resulting in a draw.
- The AI declares "no legal moves" (though this typically aligns with checkmate or stalemate).