About the Game

Royal Gambit is a browser-based chess game you can play instantly โ€” no download or account required. Challenge a built-in AI opponent or sit back and watch two AIs compete on a beautiful, animated board.

Play online at linhtruong.com/game/chess. The game runs entirely in your browser and works on desktop, tablet, and mobile.

๐ŸŽฎ Play vs AI Choose your color and difficulty
๐Ÿค– AI vs AI Spectator mode with adjustable speed
โ™Ÿ Full Rules Castling, en passant, promotion
๐Ÿ”Š Sound Effects Move, capture, check & more

Getting Started

  1. Open the game โ€” Go to index.html or visit linhtruong.com/game/chess.
  2. Pick a mode โ€” Use the toggle at the top: Play vs AI or AI vs AI.
  3. Configure settings โ€” Choose your color (White or Black), AI difficulty, and other options in the side panels.
  4. Make your first move โ€” Click one of your pieces, then click a highlighted square to move. If you play as Black, the AI moves first automatically.
  5. Start a fresh game anytime โ€” Press New Game to reset the board.

Game Modes

๐ŸŽฎ Play vs AI

You play against the computer. Select Play vs AI in the header, then configure:

  • Play as โ€” โ™” White (move first) or โ™š Black (AI moves first)
  • AI Difficulty โ€” Easy, Medium, Hard, or Expert

When playing as Black, the board flips automatically so your pieces appear at the bottom. Use Undo to take back moves โ€” it removes your last move and the AI's response.

๐Ÿค– AI vs AI

Watch two AI opponents play each other. Great for learning openings, studying strategy, or simply enjoying the show.

  • AI Difficulty โ€” Sets the strength for both sides
  • Move Speed โ€” Blitz, Normal, Relaxed, or Slow (200 ms โ€“ 2.5 s per move)

The board is view-only in this mode โ€” you cannot move pieces manually. Undo is disabled; use New Game to restart.

Controls & Interface

Control Action
Click piece โ†’ click square Select and move (Play vs AI only)
โ†• Flip Rotate the board 180ยฐ (change perspective)
โ†ฉ Undo Take back move(s) โ€” Play vs AI only
โ™Ÿ New Game Reset the board and start over
๐Ÿ”Š / ๐Ÿ”‡ Toggle sound on or off
Mode switcher (header) Switch between Play vs AI and AI vs AI

Side Panels

Game Status
Current turn, check warnings, and checkmate/draw announcements.
Evaluation
A bar and score showing approximate advantage (+ favors White, โˆ’ favors Black).
Move History
All moves in standard algebraic notation (e.g. e4, Nf3, O-O).
Captured Pieces
Pieces taken during the game, shown above and below the board.
Sound
Toggle effects on/off and adjust volume. Quick mute via the ๐Ÿ”Š button below the board.
AI is thinkingโ€ฆ
Shown while the computer calculates its move. The panel keeps a fixed height so nothing jumps around.

Sound Effects

Royal Gambit includes procedural sound effects โ€” no downloads required. Sounds play for moves, captures, castling, checks, checkmate, and UI actions.

ControlLocation
๐Ÿ”Š / ๐Ÿ”‡ button Below the board โ€” quick mute toggle
Sound effects toggle Left panel โ†’ Sound
Volume slider Left panel โ†’ Sound (0โ€“100%)

What you'll hear

  • Move โ€” wooden thud when a piece is placed
  • Capture โ€” heavier impact on takes
  • Castle โ€” double thud
  • Promotion โ€” ascending chime
  • Check โ€” alert tone
  • Checkmate / Draw โ€” end-game fanfare
  • Select / Click โ€” subtle UI feedback

Browsers require a click or tap before playing audio. If you hear nothing at first, click anywhere on the page, then make a move.

Making Moves

  1. Click your piece โ€” Only pieces of the current color can be selected. Legal destination squares light up.
  2. Click a highlighted square โ€” The piece moves with a smooth animation.
  3. Change your mind โ€” Click another of your pieces to switch selection, or click elsewhere to deselect.

Move Highlights

Gold square โ€” selected piece
Dot โ€” legal empty-square move
Ring โ€” capture available
Gold tint โ€” last move played
Red pulse โ€” king in check

Pawn Promotion

When a pawn reaches the opposite end of the board, a popup lets you choose: Queen โ™•, Rook โ™–, Bishop โ™—, or Knight โ™˜. Queen is the strongest choice in almost every situation.

Reading the Board

Coordinates

Files (columns) are labeled a through h from left to right. Ranks (rows) are labeled 1 through 8. In the default view, White starts on ranks 1โ€“2 at the bottom; Black on ranks 7โ€“8 at the top.

Evaluation Bar

The evaluation bar estimates who is winning based on material and piece placement. A score of +1.0 means White is roughly a pawn ahead; โˆ’2.0 means Black is about two pawns better. It updates after every move and is especially useful in AI vs AI mode.

Move Notation

Moves are recorded in algebraic notation:

SymbolMeaningExample
(none)Pawn movee4
N, B, R, Q, KKnight, Bishop, Rook, Queen, KingNf3
xCaptureBxf7+
+CheckQh5+
#CheckmateQh7#
O-OKingside castleO-O
O-O-OQueenside castleO-O-O
=Q etc.Promotione8=Q

AI Difficulty

The AI uses a minimax search algorithm with alpha-beta pruning. Higher levels think more moves ahead.

Level Search Depth Best For
Easy 2 moves ahead Beginners learning the rules
Medium 3 moves ahead Casual players (default)
Hard 4 moves ahead Intermediate players wanting a challenge
Expert 5 moves ahead Experienced players โ€” AI may take a few seconds per move

The AI evaluates positions based on piece values, board control, and check threats. It is strong for a browser engine but not comparable to dedicated chess software.

Chess Basics

Chess is a two-player strategy game played on an 8ร—8 board. Each player starts with 16 pieces: one king, one queen, two rooks, two bishops, two knights, and eight pawns.

Objective: Put the opponent's king in checkmate โ€” a position where the king is in check and has no legal escape. You do not capture the king; the game ends the moment checkmate is unavoidable.

White always moves first. Players alternate turns, moving one piece at a time (except castling, which moves king and rook together). You may not move into check or leave your own king in check.

Piece Values (approximate)

PieceSymbolValue
Pawnโ™™ โ™Ÿ1
Knightโ™˜ โ™ž3
Bishopโ™— โ™3
Rookโ™– โ™œ5
Queenโ™• โ™›9
Kingโ™” โ™šโˆž (priceless)

How Pieces Move

โ™™

Pawn

Moves forward one square. On its first move, it may move two squares. Captures diagonally one square forward. Cannot move backward.

โ™˜

Knight

Moves in an L-shape: two squares in one direction, then one square perpendicular. The only piece that can jump over others.

โ™—

Bishop

Moves any number of squares diagonally. Each bishop stays on one color for the entire game.

โ™–

Rook

Moves any number of squares horizontally or vertically. Especially powerful on open files and in the endgame.

โ™•

Queen

Combines rook and bishop movement โ€” any number of squares in any straight line (horizontal, vertical, or diagonal). The most powerful piece.

โ™”

King

Moves one square in any direction. Must be protected at all costs. Can castle under specific conditions (see below).

Special Moves

Castling

A one-time move combining the king and a rook. The king moves two squares toward the rook; the rook jumps to the other side of the king.

  • Kingside (O-O): King e1โ†’g1, Rook h1โ†’f1 (for White)
  • Queenside (O-O-O): King e1โ†’c1, Rook a1โ†’d1 (for White)

Requirements โ€” all must be true:

  • Neither the king nor the involved rook has moved before
  • No pieces between the king and rook
  • The king is not currently in check
  • The king does not pass through or land on an attacked square

En Passant

If an opponent's pawn moves two squares forward from its starting rank and lands beside your pawn, you may capture it as if it had only moved one square โ€” but only on the very next turn.

Example: White pawn on e5, Black plays d7โ†’d5. White can capture on d6 immediately. If White does not capture right away, the opportunity is lost.

Pawn Promotion

When a pawn reaches the farthest rank (8th for White, 1st for Black), it must be promoted to a Queen, Rook, Bishop, or Knight. Nearly always choose Queen โ€” Royal Gambit will prompt you to pick.

Check, Checkmate & Draws

Check
Your king is under attack by an opponent's piece. You must escape on your next move โ€” by moving the king, blocking the attack, or capturing the attacking piece. The king square pulses red in Royal Gambit.
Checkmate
The king is in check and no legal move can escape. The game ends immediately; the attacking player wins. Royal Gambit announces the winner on screen.
Stalemate
The player to move has no legal moves, but their king is not in check. The game is a draw.
Fifty-Move Rule
If 50 consecutive moves pass without a pawn move or capture, the game is automatically declared a draw. Royal Gambit tracks this internally.

Royal Gambit does not currently detect threefold repetition or insufficient material draws. In those rare cases, you may agree to a draw by starting a new game.

Tips & Strategy

Opening Principles

  • Control the center (e4, d4, e5, d5)
  • Develop knights and bishops early
  • Castle to safety โ€” don't leave your king in the center
  • Don't move the same piece twice in the opening without reason

Middlegame

  • Look for tactics: forks, pins, skewers
  • Coordinate your pieces โ€” they work best together
  • Watch the evaluation bar for a rough sense of advantage
  • Trade pieces when ahead in material; avoid trades when behind

Endgame

  • Activate your king โ€” it becomes a fighting piece
  • Push passed pawns toward promotion
  • Rooks belong behind passed pawns
  • Queen + King vs King is a basic winning checkmate pattern

Playing the AI

  • Start on Easy or Medium to learn
  • Use Undo freely while practicing openings
  • Try AI vs AI on Hard to study how stronger play looks
  • Watch the move history to review your games

Frequently Asked Questions

Do I need to create an account?

No. Royal Gambit runs entirely in your browser with no sign-up, login, or personal data required.

Does the game work on mobile?

Yes. The layout adapts to smaller screens. Tap a piece, then tap a highlighted square to move.

Why can't I castle?

Castling requires that neither piece has moved, the squares between them are empty, the king isn't in check, and no square the king crosses is attacked. Bishops on f1/c1 commonly block castling at the start โ€” develop them first.

Why didn't en passant appear?

En passant is only available the move immediately after the opponent's pawn jumps two squares. You must capture on that turn or the chance is gone.

Why is there no sound?

Most browsers block audio until you interact with the page. Click anywhere on the board or press a button, then try again. Also check that sound is enabled in the left panel and the ๐Ÿ”Š button below the board isn't muted.

Why is the AI moving both sides in Play vs AI?

It shouldn't โ€” you only control your chosen color (White or Black). If both sides move automatically, refresh the page and start a new game. Make sure Play vs AI is selected in the header, not AI vs AI.

Can I save or load a game?

Not currently. Refreshing the page starts a new game. Use the move history panel to review the current game.

Why is the AI taking a long time?

Expert difficulty searches five moves ahead, which takes longer as the position opens up. Try Medium or Hard for faster responses.

Can I embed this on my website?

Yes. Upload the game folder to your server and link to index.html, or embed it in an iframe. See the project README.md for deployment and iframe examples.

Ready to Play?

Put your knowledge to the test on the board.