Chess

by ArnoHu
  scripts
  sprites
See inside
Instructions

Welcome to Scratch Chess - Game of Kings ("GoK")!

GoK Online Chess (two remote players, public viewing): https://scratch.mit.edu/projects/209130998/
Sulfurous version (faster and works on mobile): https://sulfurous.aau.at/html/app.html?id=148769358
Forum discussion: https://scratch.mit.edu/discuss/topic/248984/

Press 'd' for iterative deepening info
Press 'p' for profiler mode (Scratch 3.0 and Sulfurous only, as Scratch 2.0 lacks hires timers)
Press 'c' to toggle to 60 seconds think time on Difficult

GoK scores a draw against Leela Zero neural network chess AI: https://scratch.mit.edu/discuss/post/3099651/
Two times Scratch Chess Engine Tournament Winner:
https://scratch.mit.edu/discuss/post/2936664/
https://scratch.mit.edu/discuss/topic/291239/

GoK implementation details: https://scratch.mit.edu/discuss/post/2967632/

Scratch Chess GoK Kochy-Richter checkmate video: https://scratch.mit.edu/discuss/post/2893102/

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 twelve moves in advance, depending on selected level).

Known issues:

Fixed issues:
- Feature: User should be able to play with black too
- Feature: Mobility evaluation should be weighted per piece type and game stage
- Feature: PGN export (currently only custom format)
- Feature: FEN import / export (currently only custom format)
- 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
- Feature: 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
- Feature: 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

Notes and Credits

If you like GoK Chess, please give it a ★ and ♥. Looking forward to your feedback in the comments. Thank you!

Easy: 5 seconds think time
Medium: 25 seconds think time
Difficult: 45/30 seconds think time (midgame/endgame)

REMIX INSTRUCTIONS: Always remix (or save a remix) BEFORE playing a game, otherwise transposition tables might be too large for storage (saving might take forever then). Run the "RUN_BEFORE_SAVING" block to clear transposition tables, so project can be saved again.

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.

Board image: https://upload.wikimedia.org/wikipedia/commons/5/5b/Chess-niemann.PNG

Sprites: https://commons.wikimedia.org/wiki/File:Chess_Pieces_Sprite.svg

Intro screen image:
https://pixabay.com/p-316657/

Quicksort implementation:
https://scratch.mit.edu/projects/41440388/

Chess programming resources: https://chessprogramming.wikispaces.com

Orginally developed for a CoderDojo chess programming tutorial: http://coderdojo-linz.github.io/trainingsanleitungen/scratch/scratch-chess.html

Shared: 8 Mar 2017 Modified: 21 Oct 2018
Favorite this project 538
Love this project 604
Total views 15975
View the remix tree  83
  
More projects by ArnoHu