Polar Games

A complete chess game for the web · 1.0.0

Toy Chess

This guide explains how to install, play, customize and update the game. Pick your language at the top; screenshots stay in English.

Version 1.0.0 Edition Standalone buyer edition

This guide works without internet. Images, styles and scripts are already inside this file.

Contents
  1. Overview
  2. Installing on your website
  3. Requirements
  4. How to play
  5. Screens
  6. Files and folders
  7. Internal names in the code
  8. Customizing
  9. Languages
  10. Saving and resetting
  11. Development (optional)
  12. Updating and clearing the cache
  13. Licences and credits
  14. Common problems
  15. FAQ
  16. Support

1 Overview

Toy Chess is a complete HTML5 chess game with all the official rules: castling, en passant, promotion, check, checkmate, stalemate, threefold repetition, the 50-move rule and insufficient material. The player taps a piece and then a square, or drags the piece.

It has four ways to play: against the computer (6 opponents with their own portraits and reactions, from Pip, who is just learning, to Atlas, the final boss), two players on one device, 36 mate challenges (12 each of mate in 1, 2 and 3) and Learn the pieces, with animated demonstrations.

The chess engine is part of the game and runs in the browser in a Web Worker, so the screen does not freeze while it thinks and no server is needed. Around the game: hints, undo, board flip, captured pieces, move list, automatic save with Continue, sound effects, music, 14 interface languages and layouts for desktop, tablet and phone.

2 Installing on your website

Installing takes a few minutes if you have FTP access or a file manager in your hosting panel.

  1. 1. Extract toy-chess-static-1.0.0.zip on your computer.
  2. 2. Connect to your hosting by FTP or its file manager and open the folder where the game should live, for example public_html/games/toy-chess/.
  3. 3. Upload only the contents of the game/ folder, so that index.html sits directly inside the target folder.
  4. 4. Keep assets/ and src/ beside index.html, with names and letter case unchanged.
  5. 5. Open https://your-domain.example/games/toy-chess/ in a modern browser.
Warning Do not upload the source/ folder, the documentation/ folder or the ZIP itself. Players need no Node.js, PHP, database or account.

3 Requirements

  • Any static web hosting with HTTPS (or HTTP). Opening index.html directly from the disk (file://) does not work, because browsers block JavaScript modules there.
  • A current browser: Chrome, Edge, Firefox, Safari or Opera, on desktop or mobile.
  • About 4 MB of space on the server. The game makes no request to other websites: fonts, pictures and sounds are all inside game/.
  • Node.js is only needed to run the tests or to rebuild the game from source/ (see the development section).

4 How to play

Tap or click a piece: it lifts and the squares it can move to are marked. Tap one of them to move, or drag the piece and drop it on the square. A piece with no legal move shakes when tapped.

Buttons during a game: Undo takes back your last move and the reply of the computer, Hint draws an arrow with a good move (3 per game), Flip turns the board around and Menu opens the pause panel with Resume, Restart, Resign and Main menu. Restart and Resign ask for confirmation.

Mate challenges: find the checkmate in the number of moves shown. A wrong move goes back and you can try again. See solution plays the whole answer on the board without counting as solved, and Retry starts the challenge again.

The game is saved after every move, and the main menu shows Continue game to go back to it. There is one saved game at a time, so starting a new game over a saved one asks first.

5 Screens

Main menu: play the computer, two players, mate challenges and Learn the pieces. Sound and Settings stay in the
top corner.
Main menu: play the computer, two players, mate challenges and Learn the pieces. Sound and Settings stay in the top corner.

Marks on the screenshot

  1. Play the computer
  2. Two players
  3. Mate challenges
  4. Learn the pieces
  5. Sound: effects and music volume
  6. Settings
Choose your opponent: 6 characters from easy to very strong, and the color you want to play.
Choose your opponent: 6 characters from easy to very strong, and the color you want to play.

Marks on the screenshot

  1. Chosen opponent
  2. Strength
  3. Your color
  4. Start
  5. Back
A game: the board in the center, the players and captured pieces on one side, the move list and the buttons on
the other.
A game: the board in the center, the players and captured pieces on one side, the move list and the buttons on the other.

Marks on the screenshot

  1. Opponent
  2. You
  3. Board
  4. Move list
  5. Captured pieces
  6. Undo
  7. Hint
  8. Flip board
  9. Menu
Result: who won and why, then play again, swap colors, view the board or go to the menu.
Result: who won and why, then play again, swap colors, view the board or go to the menu.

Marks on the screenshot

  1. Play again
  2. Swap colors
  3. View board
  4. Main menu
Mate challenges: 3 groups of 12. Solved challenges get a check mark and the next one is highlighted.
Mate challenges: 3 groups of 12. Solved challenges get a check mark and the next one is highlighted.

Marks on the screenshot

  1. Group of challenges
  2. Next challenge
A challenge: the goal, the current move, See solution and Retry.
A challenge: the goal, the current move, See solution and Retry.

Marks on the screenshot

  1. Goal
  2. Current move
  3. See solution
  4. Retry
  5. Back
Learn the pieces: each piece shows its moves by itself. Tap a dot to send it there.
Learn the pieces: each piece shows its moves by itself. Tap a dot to send it there.

Marks on the screenshot

  1. Pieces
  2. Live demonstration
  3. How it moves
  4. Special moves
Settings: vibration, reduce motion, language, full screen and the game options.
Settings: vibration, reduce motion, language, full screen and the game options.

Marks on the screenshot

  1. Reduce motion
  2. Language
  3. Game options
  4. Close
Portrait phone: the board takes the full width, with the players above and below it.
Portrait phone: the board takes the full width, with the players above and below it.

6 Files and folders

game/ is the ready-to-host game. source/ has the same editable files plus the tests, a local preview server and the build command. The code is plain JavaScript ES modules with no compile step and no npm dependency.

game/                        upload these contents to your web host
  index.html                 the page: loads the style sheets and src/main.js
  src/config.js              START HERE: opponents and every game-feel number (FEEL)
  src/rules.js               the complete chess rules
  src/engine.js              the chess engine and its levels
  src/engine.worker.js       runs the engine in the background
  src/puzzles.js             the 36 mate challenges
  src/game.js                runs a match
  src/board.js               the board on screen, tap and drag
  src/move-fx.js, ceremony.js, fx.js    captures, check, promotion, checkmate, particles
  src/main.js, templates.js, parts.js   screens and HUD
  src/panels.js              sound, settings, pause, result, confirmation
  src/mascot.js              the living opponents
  src/demo.js                the lesson
  src/audio.js               sound effects and music
  src/styles.css             layout and colors
  src/juice.css              motion and effects
  src/locales/               interface texts, one file per language
  assets/pieces/             the 12 pieces (WebP)
  assets/faces/              the 6 opponents, 6 portraits each (WebP)
  assets/ui/, assets/icons/  interface art and icons (WebP)
  assets/bg/, assets/scene/  backgrounds and moving scenery (WebP)
  assets/sfx/, assets/music/ sound effects and music (MP3)
  assets/fonts/              Fredoka, Nunito and their licenses
  DOCUMENTATION.txt          short note that points to this guide
source/                      the same editable files, plus:
  package.json, package-lock.json
  README.md
  tests/                     npm test (31 checks)
  tools/build.mjs            copies the game into dist/
  tools/serve.mjs            local preview server (npm run dev, npm run preview)
  tools/check-node.mjs       checks the Node.js version before the commands
documentation/index.html     this guide (offline, 14 languages)
documentation/customization.html   step-by-step customization guide
documentation/img/           the screenshots of the guides
DOCUMENTATION.html           shortcut to this guide
CUSTOMIZATION.html           shortcut to the customization guide
START-HERE.txt, CHANGELOG.txt
THIRD-PARTY-LICENSES/        Fredoka and Nunito licenses
  • src/config.js: the first file to edit. The 6 opponents and FEEL, the block with every animation and game-feel number.
  • src/rules.js: the complete chess rules, with no interface code. src/engine.js: the chess engine and its levels (LEVELS). src/engine.worker.js and src/ai.js run it in the background. src/tactics.js reads the position for the effects.
  • src/game.js: runs a match. src/board.js: the board on screen, tap and drag. src/move-fx.js, src/ceremony.js and src/fx.js: captures, check, promotion, the checkmate sequence and particles.
  • src/main.js: connects the screens and draws the HUD. src/templates.js and src/parts.js: the HTML of the screens. src/panels.js: sound, settings, pause, result and confirmation panels. src/mascot.js: the living opponents. src/ui-fx.js: screen transition and the versus screen. src/demo.js: the lesson.
  • src/styles.css: layout and colors. src/juice.css: motion and effects. src/puzzles.js: the 36 challenges. src/audio.js: sound and music. src/locales/: one file per language.
  • assets/pieces/, assets/faces/, assets/ui/, assets/icons/, assets/bg/ and assets/scene/: all the art. assets/sfx/ and assets/music/: sounds in MP3. assets/fonts/: fonts with their licenses.

7 Internal names in the code

A few ids in the code differ from the names on screen. They are only names: players never see them.

  • The two armies keep their chess names in the code: w (white) is the orange army and b (black) is the blue army. A piece file is that letter plus k, q, r, b, n or p: wq.webp is the orange queen and bn.webp is the blue knight.
  • Opponents use the keys pip, nina, otto, vera, rex and atlas. Each has six portraits: idle, think, smile, check, cheer and sad.
  • Capture sounds: cap-p is a pawn, cap-m a knight or bishop, cap-r a rook and cap-q a queen.
  • puzzle in the code is a mate challenge, bot is a computer opponent and ply is a move by one side.
  • On localhost only, window.__chess is a test handle for developers. On a public address it does not exist.

8 Customizing

Note Not a programmer? The Customization Guide shows the most common changes step by step. Open CUSTOMIZATION.html in the main folder of the download, or documentation/customization.html.

Customizing

Brand: the name in the browser tab is the <title> line of index.html. The logo is made of three pictures of the same size so the flags can wave: assets/ui/logo-base.webp, logo-flag-l.webp and logo-flag-r.webp. The page icon is assets/icon-192.png.

Colors and pictures: the board colors are --sq-l and --sq-d at the top of src/styles.css. To reskin, replace a file in assets/ with another WebP of the same name and a similar size.

Opponents: names are in BOTS in src/config.js, their short descriptions are the bot.pip.d style keys in src/locales/, and their strength is in LEVELS in src/engine.js: depth is how far it looks, noise is how much it errs and think is the pause before it moves.

Game feel: FEEL in src/config.js holds the flight of the pieces, the impact of each capture, the checkmate timing and the screen transitions in one place.

Sounds and music

Every effect is an MP3 in assets/sfx/, named with its id and a number, for example drop-1.mp3. Frequent sounds have several versions and the game alternates them. Replace a file keeping its name. The music is assets/music/castle-theme.mp3.

To add a version, put the file in the folder and raise its number in FILES at the top of src/audio.js. The volume of each sound is in GAIN in the same file.

Warning Save keys: every key starts with toy-chess.template. If you host more than one copy of the game on the same domain, change them in src/config.js, src/settings.js, src/audio.js and src/main.js, otherwise the copies share saved games and settings.

9 Languages

The game has 14 languages: English, Portuguese, Spanish, French, German, Italian, Dutch, Polish, Turkish, Russian, Indonesian, Japanese, Korean and Chinese. The first visit uses the browser language; the player can change it in Settings.

To change a text, edit the same key in src/locales/<code>.js. A key missing in another language falls back to English. To add a language, copy en.js, translate it and add it to LANGS and LANG_NAMES in src/i18n.js.

To start in one language, set lang in DEF in src/settings.js, for example lang: 'pt'. Russian uses the included Nunito font. Japanese, Korean and Chinese use the fonts of the device.

10 Saving and resetting

  • The game in progress, solved challenges, settings, language and volumes are saved automatically in the browser of each player (localStorage). Nothing is sent to a server.
  • The game in progress is stored under the key below. Settings, volumes and challenges use toy-chess.template.settings, toy-chess.template.volumes and toy-chess.template.puzzles.
  • To start over, delete these keys in the developer tools (F12), under Application, Local Storage, or clear the site data in the browser.
toy-chess.template.save.v1

11 Development (optional)

This section is only for changing the code. The game/ folder already contains the finished game, so installing it needs no Node.js. The game has no dependencies and no compile step: npm run build only copies the files into dist/.

1. Install Node.js. Open https://nodejs.org/en/download and choose the latest Node.js 26 LTS installer for your system (minimum 26.13.0). npm is included.

Windows: run the .msi installer, keep npm and Add to PATH enabled, finish the installation and reopen Command Prompt. macOS: run the official .pkg installer and reopen Terminal. Linux: follow the instructions on the same page for your distribution.

2. Check the installation. Run node --version and npm --version separately. Both must print a version number, and Node.js must be 26.13.0 or newer. If a command is not found, reopen the terminal and check that Node.js is in PATH.

node --version
npm --version

3. Extract the complete ZIP first and open its source/ folder, where package.json is. Windows: type cmd in the address bar of that folder in File Explorer. macOS and Linux: open Terminal and use cd with the path of the folder.

4. Run the commands below one by one. npm ci checks the lock file (nothing is downloaded, the project has no dependencies). npm test runs 31 checks on the chess rules, the engine, all 36 challenges and the package.

npm ci
npm test

5. Preview: npm run dev starts a local server; open http://localhost:5180/ in your browser, play for a while, and stop the server with Ctrl+C.

npm run dev

6. Build: npm run build empties source/dist/ and copies index.html, src/ and assets/ into it. dist/ is what you publish; while the source is unchanged it is identical to game/.

npm run build

7. Publish: back up the game on your website, then upload the contents of dist/ in place of the old files, keeping the folders. If you deleted or renamed a file, delete the old one on the server yourself. Clear the cache afterwards.

Note Troubleshooting: ENOENT or a missing package.json means the terminal is in the wrong folder. EBADENGINE, or the Node.js message printed before npm test, means Node.js is too old. If PowerShell blocks npm.ps1, use Command Prompt or run npm.cmd.

12 Updating and clearing the cache

Clearing the cache without losing progress

Progress is stored in this browser, not on the server. Clearing cached images and files, or doing a hard reload, keeps your progress.

Computer: press Ctrl+F5 on Windows and Linux, or Cmd+Shift+R on macOS. Phone: in the browser settings, choose the option to clear cached images and files.

Do not choose cookies and site data, or clear site data, for the game's address. That deletes the local save.

13 Licences and credits

The game code, the artwork, the sound effects and the music are supplied under the license of the item you purchased.

Third-party parts, with their complete license texts in THIRD-PARTY-LICENSES/: the Fredoka and Nunito fonts (SIL Open Font License 1.1, also in assets/fonts/). The project has no other third-party library.

14 Common problems

  • Blank page or a game that never opens: the game was opened from the disk or a file is missing. Use a web host and keep every file and folder of game/ next to index.html.
  • No sound: browsers start audio only after the first click or tap (the Tap to start screen does this). Check both volumes in the Sound panel and the volume of the device.
  • The computer takes a moment on the strongest levels: this is normal. Atlas can think for up to 3 seconds. Faster computer replies in Settings shortens the pause.
  • A piece does not move: in check, only moves that save the king are allowed, and a pinned piece cannot leave its line. The marked dots always show the legal moves.
  • The old version still appears after an update: clear the cache (see the section above). Two copies share their saved games: give each copy its own save keys.

15 FAQ

Does the game need a database or a server language?
No. It is a static website: HTML, CSS, JavaScript, pictures and sounds. The chess engine runs in the browser of the player.
Does it include a third-party chess engine?
No. The rules and the engine are original code written for this game, in src/rules.js and src/engine.js.
Can I add my own mate challenges?
Yes. Add a position to src/puzzles.js (see the Customization Guide) and run npm test: it checks that each challenge has one winning first move and no shorter mate.
Does it work on phones?
Yes, in portrait and landscape, with touch and drag. It also works with a mouse on desktop.
Can two people play online?
No. Two players share the same device and take turns. There is no online mode in this edition.

16 Support

Questions or problems: write to willian@polargames.com.br with your purchase code, the browser and a short description or screenshot.

Support request

When you write to support, include the browser and device, the game version, the page address, the steps that caused the problem, a screenshot and the first error shown in the browser console. Never send passwords, payment details or secret keys.