by ArnoHu
See inside

Welcome to Scratch Chess - Game of Kings ("GoK")! Looking forward to feedback in the comments. If you like the game, please ★ and ♥. NEWS UPDATE: Scratch Chess Engine Tournament Winner:

GoK implementation:

Forum discussion:

Scratch Chess GoK Kochy-Richter checkmate video:

Level "Difficult" runs best on fast hardware. Sulfurous version (faster and works on mobile):

For bug reports please attach exported board data (the one before the black move took place). Simply click "Export", then look for the next-to-last board list entry and copy it to the clipboard (or export all entries to a file and copy the one entry from there). Alternatively you can also export he move list (click "Moves").

I focused on game experience and AI. Considering the speed limitations of Scratch it shouldn't be too bad (it calculates up to five moves in advance, depending on selected level).

Known issues:
- User should be able to play with black too
- Mobility evaluation should be weighted per piece type and game stage
- Missing feature: PGN import / export (currently only custom format)
- Missing feature: FEN import / export (currently only custom format)

Fixed issues:
- Feature: Support for searching up to ply6 (plus 4 moves quiescence), adjusting automatically to board complexity and computer speed
- Feature: Transposition tables for caching and hash move ordering
- Feature: Quiescence search
- Feature: Underpromotion
- Bug: Move ordering not always applied, hence game is slow (thanks to blueking24 for reporting this)
- Bug: Cannot "Undo" after end of game
- Feature: Implement ply5 for level "Difficult" (was ply4 before)
- Bug: Undo leads to high CPU utilization
- Bug: Only wins accidentally (if at all) at level "Easy"
- Bug: Pawn jumps to wrong field in dutch opening
- Feature: Opening book is rudimentary (fixed by Grijfland)
- Bug: Evaluation functionality needs cleanup (currently cluttered code, with implicit dependencies)
- Bug: Disappearing piece due to wrong en-passant application during checkmate check (thanks to Itharius for reporting this)
- Bug: Wrong algebraic notation on H column (thanks to Itharius for reporting this)
- Bug: King passive in endgame due to latest performance tuning
- Feature: Performance tuning by evaluating position less frequently
- Bug: Allows castling through checked fields
- Feature: En-passant support
- Feature: Incremental move ordering (speedup)
- Feature: Isolated pawn evaluation
- Feature: Algebraic move list
- Feature: Undo move
- Feature: Import/export board data
- Bug: Queen moves too early
- Bug: Cannot move h2h4
- Feature: Opening book initial implementation
- Feature: Provide several difficulty levels
- Bug: Does not detect draws on repetitive positions
- Bug: Black move might lead to black king being checked
- Bug: Missing double pawn evaluation
- Bug: Thinks one side's check can be compensated by other side's check
- Bug: Does not consider check on castling
- Bug: Does not consider draw in move evaluation
- Bug: Applies pawn promotion too late
- Bug: Target piece not restored after invalid white move when checked

Chess, Ajedrez, Schach, Échecs, 棋, 체스, チェス.

Notes and Credits

Easy: Ply2 + Quiesc4, think time 2-5 seconds
Medium: Ply3 + Quiesc3 to Ply4, think time 10-20 seconds
Difficult: Ply4 + Quiesc2 to Ply6 + Quiesc4 (depending on board and system speed), think time 30-60 seconds

Sulfurous version (faster and works on mobile):

Opening Book by @Grijfland (thanks a ton, that was a lot of work!)

Graphics from external sources all labeled free for non-commercial use. See links below.

REMIX Instructions: As the transposition table gets really huge once you run GoK Chess, saving the project from the editor might fail after playing. Always run the "RUN_BEFORE_SAVING" function manually by double-clicking it before saving the project, or even better before editing it, because of auto-save. This clears the table and other lists, and the project can be stored again. Or remix the older GoK Chess Legacy version, this one didn't have a transposition table yet:

Board image:


Intro screen image:

Quicksort implementation:

Chess programming resources:

Orginally developed for a CoderDojo chess programming tutorial:

Shared: 8 Mar 2017 Modified: 14 Feb 2018
Favorite this project 312
Love this project 341
Total views 6568
View the remix tree  58
More projects by ArnoHu