1024 Byte JavaScript Chess Engine - Reviewing Your Projects - The Kilobyte's Gambit

Описание к видео 1024 Byte JavaScript Chess Engine - Reviewing Your Projects - The Kilobyte's Gambit

In this video, I will review yet another project submitted by you guys. This time we have a 1 KB JavaScript chess game. It is appropriately called The Kilobyte's Gambit, after the TV series The Queen's Gambit. We will first check out the game, then will analyze the game theory behind it. We will also go over the de-obfuscated source code to analyze the details of this tiny implementation. Finally, I will compare this project to 8-bit chess engines from the 1980s. In essence, the game implements a minimal game tree to search for the best moves. I will go deeper into the game trees and game theory in the video.

Outline of this video:
0:00 - The Kilobyte's Gambit
0:22 - A Game of Chess
3:20 - Game Theory and Game Trees
5:11 - Source Code Analysis
7:19 - 8-Bit Chess Engines
7:58 - Conclusion

You can play the 1K chess game that is the topic of this video at:
https://vole.wtf/kilobytes-gambit/

"En passant" move in chess, if you are curious about it:
https://en.wikipedia.org/wiki/En_passant

If you want to read more about game trees and game theory:
https://en.wikipedia.org/wiki/Game_tree
https://en.wikipedia.org/wiki/Game_th...

De-obfuscated source-code of the chess game, which I used in this video:
https://github.com/rhulha/nanochess/b...

One of the first 8-bit chess engines that I mentioned in this video:
https://en.wikipedia.org/wiki/1K_ZX_C...
Source-code: http://users.ox.ac.uk/~uzdm0006/scans...

Hacker News discussion on this topic:
https://news.ycombinator.com/item?id=...

If you want to read or contribute, you can find this guide on:
https://quanticdev.com/articles/kilob...

My "Project Reviews" Playlist:
   • Project Reviews  

- - - - - - - - - -
  / quanticdev  
  / quantic_dev  
https://quanticdev.com

- - - - - - - - - -
Abstract:

The Kilobyte's Gambit is a minimal JavaScript chess game. It is an excellent demonstration of how concisely game trees can be implemented. The chess engine starts by calculating each move's value in each branch of the game tree. For instance, taking an opponent pawn is a good move. Taking a bishop is even better. And taking command of a corner of the board is the best. On the other hand, losing a piece without getting something in return is bad. As we are trying to make moves that minimize losses and maximize our wins, we are doing a form of minimaxing. However, our game tree branches out exponentially with each move so we cannot possibly explore all possible moves. Instead, we stop following branches with the lowest score.

Ideally, we should only stop calculating all possible outcomes of a move if one of the outcomes of that move is a definitive loss. This is called the alpha-beta pruning of a game tree. However, to keep things simple, our 1 KB implementation sticks to the more straightforward method of ranking game tree nodes and choosing the one with a score better than a certain threshold.

A Note on Heuristics:
Creating a game tree of possible moves is not enough. The game needs to calculate the value of each move. This is called "heuristic". In this game engine, the heuristic is very simple. The value of a move goes up if we are going to take a stronger position on the board or if we are going to take an opponent piece. The more valuable the piece, the better the move. If the consecutive possible moves by the opponent result in a loss of our piece, the value of the move goes down. And the game engine continues to scan for moves up to the given scan depth. This chess engine only scans for two moves ahead per player. However, even then, it managed to play a good game against me.

In the video, you want watch me struggle against this tiny chess engine!

Комментарии

Информация по комментариям в разработке