Chess

Public domain classic

The original strategy game. Play white against the computer.

Chess

At a glance

Rules
Full chess: castling, en passant, promotion to any piece, check, checkmate and stalemate
Draws
Stalemate, too little material to mate, the fifty-move rule and threefold repetition, all called for you
Players
You play white, drawn in ivory at the bottom of the board, against the computer
Difficulty
Easy, Normal and Hard. Normal is set when the page opens
Controls
Tap or click one of your pieces, then a glowing square. Esc pauses. There is no keyboard play for moves
Help
Undo, a move list in algebraic notation, the last move highlighted, and trays of captured pieces
Score
The material you capture, plus 1,000 for a win or 100 for a draw
Saves
Your best score, in this browser only
Cost
Free, no account

How this chess game plays

  • Tap one of your pieces and every square it can legally reach lights up: a dot on an empty square, a ring round a piece you can take. Tap a lit square to move, or another of your pieces to switch to it.
  • Only legal moves are offered. A move that would leave your king in check never lights up. When you are in check, the king's square is outlined in red and the panel says so.
  • Castling works on either side while the king and that rook have not moved, the squares between them are empty, and the king is not in check and does not cross or land on an attacked square.
  • En passant is offered only on the move straight after the pawn's double step.
  • Promotion opens a chooser with queen, rook, bishop and knight. Enter picks the queen.
  • The game ends by itself on checkmate, stalemate, too little material, 100 half-moves in a row with no capture or pawn move, or the same position for the third time with the same side to move and the same castling rights. Too little material means two bare kings, a king with one knight or one bishop, or only bishops that all stand on squares of one colour.
  • Undo takes back your move and the computer's reply. Pressed while the computer is still thinking, it takes back just your move.

How the computer plays

  • It thinks in a background worker, so the board stays responsive, and the panel shows the depth it has reached.
  • It searches with alpha-beta. Easy looks at its own move only, Normal three moves deep (its move, your reply, its next move) and Hard four. At the end of each line it keeps following captures and promotions for up to five more moves, so it does not stop half way through an exchange.
  • It scores a position by material (pawn 100, knight 320, bishop 335, rook 500, queen 900) plus a table for each kind of piece that rewards good squares, such as knights near the centre.
  • Easy adds a random bonus of up to 90 to each move's score, so it may pick a move up to 90 points worse than its best, a little less than a pawn, and the same position can get different replies. Normal and Hard have no randomness.
  • Each move has a 12-second limit. If time runs out, it plays the best move from the last depth it finished.

In the rule test the three levels were given the same 30 positions. Easy and Normal chose different moves in 12, Normal and Hard in 3, and Easy and Hard in 13. Asked twice about the same position, Easy answered differently in 13 of the 30. All three levels found a mate in one, and Easy took a queen left hanging in all 20 tries. Hard finished its full search every time, and its slowest reply in the test took 5.0 seconds. In the browser check the computer's first reply came in about 0.1 seconds on Easy and on Normal.

Reading the move list

Files run a to h from left to right and ranks 1 to 8 from your side up, as labelled round the board. Each move is written with the piece letter first (N knight, B bishop, R rook, Q queen, K king, nothing for a pawn), an x for a capture, then the square it lands on, as in Nf3 or exd5. A pawn capture starts with the file the pawn came from.

  • Castling is O-O on the king's side and O-O-O on the queen's side.
  • A promotion adds the new piece, as in a8=Q.
  • A plus marks check and a hash marks mate, as in Qxf7#.
  • When two pieces of the same kind could reach the square, the file or rank they came from is added, as in Rad1 or R1a3.

How the rules were checked

The build brief asked for the move generator to be checked by counting every legal sequence of moves to a fixed depth, a test known as perft, and named the counts to match. From the starting position this game counts 20, 400, 8,902 and 197,281 positions after one, two, three and four moves. From a crowded test position called Kiwipete, also named in the brief, it counts 48, 2,039 and 97,862 after one, two and three. The build report gave exactly those numbers, and the rule test on 2026-11-11 got them again.

For a board game with fewer pieces, try Checkers.

Known limits

  • You always play white, and the board does not turn round.
  • No resign button and no draw offer. New game starts again at any time.
  • The level can only be changed from the New game card.
  • Hard can take several seconds over a move in a busy position.
  • A bishop counts 33.5 in the score, so a score can end in .5.
  • No keyboard play for moves: you need a mouse or touch.
  • On a 390 by 844 screen each square is 37.5 pixels across.
  • At 1280 by 720 the game frame is 848 pixels tall, so the bottom of the board can sit below the window until you scroll.
  • Switching tabs pauses the game, and the computer starts its search again when you resume.
  • If storage is blocked, your best score is not kept.

How it was built and checked

AI tool
Codex
First committed
2026-10-14, on its own, the same day as a batch of 10 classic games
Size
One HTML file of 310 lines (about 26 KB), no game libraries
Rounds of changes
1 at build, from the build record. Changed once since, on 2026-11-11: Easy added its random bonus after the search had cut moves short, so it nearly always played the last move it looked at and missed even a mate in one. It now scores every move in full first
Checked at build
The build report: the perft counts from the start and from Kiwipete, a four-move mate, stalemate, all four promotions, en passant, castling, too little material, the fifty-move rule, repetition, each level returning a legal move, and the screen code run against a stand-in page. It lists real browser layout, real touch hardware and whether browsers allow the background worker as not verified
Checked since
2026-11-11: a new rule test (263 checks covering the perft counts, castling, en passant, promotion, check, notation, every way a game ends, the three levels on 30 positions, a mate in one and a hanging queen at each level, and taps, promotion, Undo, pause, New game and Play Again through the real screen code at both sizes), and an automated browser check of the local build at 1280 by 720 on Normal and 390 by 844 on Easy. Each time the background worker replied inside the game frame. The check tapped e2 and then e4, played a second move, pressed Undo, paused with Esc, set a position with a mate in one and finished it with two taps, pressed Play Again, then set a position where the computer mates and saw it do so
Played on a phone
2026-11-11, a full game on a real phone before this page went live

Embed Chess on your site

Free to embed. Please keep the credit link.

<div style="position:relative;padding-top:75%;max-width:640px"><iframe src="https://aivibecodedgames.com/games/chess/" title="Chess (free browser game)" style="position:absolute;inset:0;width:100%;height:100%;border:0" loading="lazy" allow="fullscreen" allowfullscreen></iframe></div>
<p><a href="https://aivibecodedgames.com/play/chess/">Play Chess free</a> on AI Vibe Coded Games</p>

How it was vibe coded

ToolCodex
Rounds of changes: 1
First committed2026-10-14

The opening prompt

Make a complete chess game. You play white against a computer playing black. Full legal rules: all piece moves, castling both sides with all conditions, en passant, pawn promotion (choose piece, default queen), check, checkmate, stalemate, draw by insufficient material and by the fifty-move rule. Highlight legal moves and the last move, show a check warning, captured pieces tray, move list in algebraic notation. Computer: alpha-beta minimax with material plus piece-square tables and quiescence search, Easy (depth 1 with randomness), Normal (depth 3), Hard (depth 4) toggle, run the search in small time slices or a Worker built from a Blob so the UI never freezes. Draw pieces with canvas using the Unicode chess glyphs (U+2654 to U+265F, filled glyphs for both sides, colour them ivory and charcoal with an outline). Undo takes back your last move and the reply. Board flips are not needed.

What we learned

  • The build check confirmed that each level returned a legal reply (20, 852 and 4,596 positions searched for Easy, Normal and Hard) but never looked at which move Easy chose. Easy added its random bonus after the search had cut a move short, so it nearly always played the last move it looked at and missed a mate in one. A test that asks each level to find a mate in one and take a free queen shows this straight away.

Game controls

  • Tap or click a piece, then a highlighted square
  • Undo and New game buttons

The game brief includes touch controls for phones.

Open the game on its own

More games