QuanticDev
QuanticDev
  • 45
  • 428 710
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:
* vole.wtf/kilobytes-gambit/
"En passant" move in chess, if you are curious about it:
* en.wikipedia.org/wiki/En_passant
If you want to read more about game trees and game theory:
* en.wikipedia.org/wiki/Game_tree
* en.wikipedia.org/wiki/Game_theory
De-obfuscated source-code of the chess game, which I used in this video:
* github.com/rhulha/nanochess/blob/master/modularized2/ToledoChess.js
One of the first 8-bit chess engines that I mentioned in this video:
* en.wikipedia.org/wiki/1K_ZX_Chess
* Source-code: users.ox.ac.uk/~uzdm0006/scans/1kchess
Hacker News discussion on this topic:
* news.ycombinator.com/item?id=26380110
If you want to read or contribute, you can find this guide on:
* quanticdev.com/articles/kilobytes-gambit-1024-byte-javascript-chess-engine
My "Project Reviews" Playlist:
* ua-cam.com/play/PLlPRnMzqjADqpds00gMgieN1FYb1cDc_A.html
- - - - - - - - - - -
quanticdev
quantic_dev
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!
Переглядів: 3 772

Відео

A Senior Developer's Linux Setup
Переглядів 44 тис.3 роки тому
In this video, I will recreate my Linux software development environment from scratch, as a senior software engineer with 10 years of experience. I will create a Linux based system that suits my software design, architecture, and development needs. I also need some business tools, so I will add them to the mix. Outline of this video: * 0:00 Why Linux * 1:26 Which Linux Distro * 2:00 Package Man...
Distributed Sorting - Google Interview Question - Algorithm & System Design - Full 2 Hour Interview
Переглядів 10 тис.3 роки тому
If you were given 1 TB of data and asked to sort it using 1000 computers, how would you do it. This is a Google senior interview question, and you are currently watching the optimum solution. In this video, we will do the full 2-hour interview stages together and get hired! Outline of this interview question video: * 0:00 Overview * 2:22 Problem Visualization * 4:40 Design Document * 5:22 Probl...
AI Socks Matching App in 10 Minutes
Переглядів 3,7 тис.3 роки тому
I'm in a situation where I need to match a lot of socks after washing, once again. And this is just half of it! Last time I did this manually, it took me ten long torturous minutes. So, I decided to do the only rational thing and use machine learning to match the socks. However, I gave myself only 10-minutes to get the job done, so it won't be costlier than manual matching. In this video, I wil...
Our Startup Office Tour - But He Gets Wider After Every Corner
Переглядів 8703 роки тому
My friend Hadrien is taking us to a tour of our software startup's new office in Sweden... but he gets wider every time he turns a corner! 0:00 Office building 0:07 Main entrance 0:20 Kitchen 0:30 Meeting room(s) 0:49 Bathroom 0:57 Main open-plan work area 1:13 Emergency exit Also, here is the glorious music used in this video: * On Apple Music: music.apple.com/us/album/song-for-denise-maxi-ver...
Merge Algorithms - 2-Way and K-Way Merge
Переглядів 21 тис.3 роки тому
Say in a programming interview situation, you are given two sorted arrays of integers and asked to merge them. What would you do? I'm pretty sure my first instinct would be to append them. Which then I would realize that the new array would be no longer be properly sorted. The correct approach to this problem is to use a 2-way merge. 2-way merge is quite simple. You take two sorted arrays. You ...
How I Mass Refactored Our Production Codebase Without Fear
Переглядів 5083 роки тому
I recently mass refactored our production codebase at work. And I did so without the fear of breaking things. Why did I not fear breaking our quite sophisticated enterprise product? You will discover in this video. This video is a part of my monthly engineering stories series. Let me give you some hints. It was a full-stack refactor, meaning it involved the client codebase, the DevOps code and ...
Method Chaining is Awesome
Переглядів 1,6 тис.3 роки тому
Have you ever worked with classes that are thousands of lines long? Those classes end up encapsulating tens of related functionality, and you end up repeating that class' name hundreds of times. But not today. In this video, we will clean up some mess using method chaining. Method chaining is an idiom in object-oriented languages where an object's methods return a reference to the object itself...
Physicist Reviews Black Mesa Research Facility
Переглядів 28 тис.3 роки тому
Hello fellow scientists and engineers, I am QuanticDev, and even though I develop software, I studied semiconductor physics and electronics. I also worked at my university's nuclear research institute in the particle accelerator facility, designing control systems for about two years. In this video, I will review the infamous Black Mesa Research Facility. I will try to compare it to a real nucl...
Recursion Visualization - Algorithms
Переглядів 16 тис.3 роки тому
Recursion is a concept that is best understood through visualization. In this video, you will see visualization for different kinds of recursions. For simplicity, I chose to animate recursive functions using trees. Properties of the recursion tree visualizations are: * Each node represents a single recursive function call. * The height of the recursion tree is the depth of our function call sta...
Automating My YouTube Uploads Using Node.js
Переглядів 13 тис.3 роки тому
In this video, you will learn how I automated my UA-cam uploads using Node.js. I've used the UA-cam API through Google's readily available Node.js client library. The library handles all HTTP communication with UA-cam API's upload endpoint. I extract all the required fields for the video (title, description, tags, etc.) from my video's script file and upload them to UA-cam along with the video ...
Alternative Big O Notation
Переглядів 4293 роки тому
This video will take any software engineer from O(k) to O(yeah) to O(mg). Gift the merch if you want to help out the channel. Alternative Big O Notation poster, stickers, mugs, and more: * quanticdev.com/shop * www.redbubble.com/shop/ap/54268092 (Redbubble shop direct link) * www.redbubble.com/shop/ap/54268334 (same artwork but with title) QuanticDev Poster: * www.redbubble.com/shop/ap/54006599...
Staircase Problem + 3 Variants - Different Ways to Reach the N'th Stair With M Different Steps
Переглядів 11 тис.3 роки тому
In a staircase problem, you try to calculate the different ways to reach the n'th stair where you are allowed to take up to m steps at a time. Say you are given a staircase problem with 5 stairs to climb, and you can take 1 or 2 steps at a time. How would you solve this problem? This and its variants are the focus in this video. It is a great problem to demonstrate the properties of dynamic pro...
My Project Got 800 Stars in Two Days on GitHub - KOAN (Open-Source)
Переглядів 1,4 тис.3 роки тому
In this video I will tell you how my open-source JavaScript project got 800 stars on GitHub within two days of publishing it. My project is called KOAN (github.com/soygul/koan), and I created it to preserve my general knowledge in Koa and Angular frameworks, as well as Node.js and MongoDB, by making a ready-to-use project template. Upon submitting it to a couple of JavaScript newsletters for re...
Maximum Value PC Build by a Software Engineer - Complete PC Build Guide
Переглядів 8 тис.3 роки тому
I am the QuanticDev, a senior software engineer with education in semiconductor physics and electronics, and today I will show you my recent maximum value PC build. I am a long time Mac and Linux user on the laptop side for my software engineering tasks, but I am tired of the fan noise. So, I decided to create a desktop build and get the maximum bang for my buck, while retaining great upgradabi...
How to Get a Great Linux Laptop at a Perfect Price - Lenovo ThinkPad Without a Pre-installed OS
Переглядів 12 тис.3 роки тому
How to Get a Great Linux Laptop at a Perfect Price - Lenovo ThinkPad Without a Pre-installed OS
Big O Time/Space Complexity Types Explained - Logarithmic, Polynomial, Exponential, and More
Переглядів 8 тис.3 роки тому
Big O Time/Space Complexity Types Explained - Logarithmic, Polynomial, Exponential, and More
Is Windows Good for Developers Again? - A Review by a Senior Software Engineer
Переглядів 1,2 тис.3 роки тому
Is Windows Good for Developers Again? - A Review by a Senior Software Engineer
Responding to Harvard's Survey Request About My Open-Source Contributions
Переглядів 3093 роки тому
Responding to Harvard's Survey Request About My Open-Source Contributions
Cleaning My MacBook After 16800 Hours of Use!
Переглядів 10 тис.4 роки тому
Cleaning My MacBook After 16800 Hours of Use!
Kadane's Algorithm and Its Proof - Max/Min Sum Subarray Problem
Переглядів 11 тис.4 роки тому
Kadane's Algorithm and Its Proof - Max/Min Sum Subarray Problem
How to Find Funding For Your Project - Recommendations From a Senior Software Engineer
Переглядів 1,2 тис.4 роки тому
How to Find Funding For Your Project - Recommendations From a Senior Software Engineer
How Fast is H.265/HEVC Software Encoding on ARM CPUs (iPhone/Android) With FFmpeg?
Переглядів 5 тис.4 роки тому
How Fast is H.265/HEVC Software Encoding on ARM CPUs (iPhone/Android) With FFmpeg?
Fastest PHP Best Practices Guide
Переглядів 1,4 тис.4 роки тому
Fastest PHP Best Practices Guide
Lockable Tree - Google Interview Question
Переглядів 23 тис.4 роки тому
Lockable Tree - Google Interview Question
Essential Software for Working From Home
Переглядів 4244 роки тому
Essential Software for Working From Home
OBS Studio: Open-Source Software for Video Recording and Live Streaming - Guide
Переглядів 1,7 тис.4 роки тому
OBS Studio: Open-Source Software for Video Recording and Live Streaming - Guide
Know the Difference: Subarray vs Substring vs Subsequence vs Subset
Переглядів 14 тис.4 роки тому
Know the Difference: Subarray vs Substring vs Subsequence vs Subset
State of Software Engineering in 2020
Переглядів 1,5 тис.4 роки тому
State of Software Engineering in 2020
Sliding Window Technique + 4 Questions - Algorithms
Переглядів 107 тис.4 роки тому
Sliding Window Technique 4 Questions - Algorithms

КОМЕНТАРІ

  • @gs7326
    @gs7326 Годину тому

    hey! loved it. i wish you'd redo it with Project Lambda. It's much more detailed, and brings this legendary facility to life even further

  • @thatlutherfan
    @thatlutherfan 15 днів тому

    that was an AH-64 apache, not a cargo helicopter. If im correct, its for military weapons research.

  • @ganeshjaggineni4097
    @ganeshjaggineni4097 27 днів тому

    NICE SUPER EXCELLENT MOTIVATED

  • @NOISCALE
    @NOISCALE Місяць тому

    💙💙💙

  • @Xomtheproto
    @Xomtheproto Місяць тому

    I want to see this dude react to the original half life facility

  • @justforrow
    @justforrow 2 місяці тому

    Thank you for this great video sir! I learned a lot.

  • @slavaslava9763
    @slavaslava9763 2 місяці тому

    I think there is mistake in Question 2 - Kardane's algorithm used for finding maximum number, not exact number.

  • @gabrielasalvo7080
    @gabrielasalvo7080 3 місяці тому

    Amazing explanation!

  • @aliveiamnot9919
    @aliveiamnot9919 3 місяці тому

    i wish you'd come back

  • @akashagarwal6390
    @akashagarwal6390 3 місяці тому

    why not thinking of external merge sort in the first part?

  • @shivayshakti6575
    @shivayshakti6575 3 місяці тому

    great tip, method chaining also helps us in pandas analysis :)

  • @camaycama7479
    @camaycama7479 4 місяці тому

    Hi! Why not Debian 12? Or Fedora woth btrfs with snapshots ? I would love to get your insights. Thanks!

  • @Valehass
    @Valehass 4 місяці тому

    4:45 that is an apache gunship, not a "cargo helicopter", I agree a transport would make a lot more sense but I think its purpose is to patrol the vast out lying perimeter of the Black Mesa facility for intruders (human presumably).

  • @komradwide4660
    @komradwide4660 5 місяців тому

    Do PC's and Servers in the facilities you worked in run Windows or Linux (or a mix of both)?

  • @HyperMAX9001
    @HyperMAX9001 6 місяців тому

    Very enjoyable to watch, please comment the resto f the facility.

  • @gehteuchnixan8256
    @gehteuchnixan8256 6 місяців тому

    Indeed some huge lobbys or waiting areas in the game, which you shouldn't expect inside a real science lab. Entrance halls like this are more to expect in public areas, like a show room, a hotel, or whereever many guests are expected and wanted to be impressed, but not deep inside a research facility, where the scientific personal is just passing by. But of course this was designed for the message that black mesa is just gigantic in size with an unlimited pool of money. The always present security personal also made me smile. Concealment is one thing, but an armed guard at every third internal door, whose only job is to open the door for a scientist... a lot of 30k $/yr salarys that have to be earned.

  • @BenoHourglass
    @BenoHourglass 6 місяців тому

    Half-Life is set in the year 2000, so keep that in mind when looking at everything.

  • @Zartren
    @Zartren 6 місяців тому

    TPS reports and the request to come in on Saturday are a reference to the Office Space movie.

  • @Daniel__Nobre
    @Daniel__Nobre 6 місяців тому

    Love this! It’s like hearing Gordon Freeman’s thoughts/narration sometimes :) Thank you for sharing your knowledge

  • @mr2meows
    @mr2meows 6 місяців тому

    i dont think black mesa is very realistic because you can see fog and water through walls

  • @CaseStudyQB
    @CaseStudyQB 6 місяців тому

    Thanks so much for this tutorial!

  • @abdullahshoukat7848
    @abdullahshoukat7848 6 місяців тому

    thank you so much. you deserve much more subscribers and views.

  • @enocescalona
    @enocescalona 6 місяців тому

    i would love more scientists to take a look at the Half-Life world. Am curious what other physicists would think of both remake and the original Black Mesa as a whole.

  • @archangelapache2953
    @archangelapache2953 6 місяців тому

    4:47 *Sees Apache attack helicopter* “ah yes, transport helicopter”

  • @der.Schtefan
    @der.Schtefan 7 місяців тому

    I think most of the Black Mesa and Aperture Science compounds are built around old salt mines, which end up looking like this, HUGE CAVERNS, extreme sizes. NaCL forms extremely stable formations, but is easy to mine out. That's also the reason why the complex seems so spread out.

    • @circleinforthecube5170
      @circleinforthecube5170 6 місяців тому

      only aperature is a mine, northern michigan is know for that while black mesa is old missle silos expanded upon for half a century

    • @codemancz798
      @codemancz798 6 місяців тому

      Black Mesa (a bulk of it anyway) is apparently built into Cold War-era bunkers bought from the US government, which explains the presence of silos.

  • @sejalkale67
    @sejalkale67 7 місяців тому

    How to make it thread safe ??

  • @NerdistRay
    @NerdistRay 8 місяців тому

    Manjaro? Better to go with Arch instead. Much more stable.

  • @AccerAspire
    @AccerAspire 8 місяців тому

    Thank you sir

  • @Tatar_Piano
    @Tatar_Piano 8 місяців тому

    Ffmpeg now supports hardware encoding in termux

  • @wallabing
    @wallabing 8 місяців тому

    There's a massive amount of security and military hardware because Black Mesa has already been traveling to Xen for decades, and bringing back live alien specimens to our world, including alien mind controllers. The security is more likely to contain whatever happens, and to keep low level scientist hush. The immediate opening announcments during the tram ride are also extremely ominious, they probally need "expendables" guinea pig scientists to send to Xen, and to capture live specimens, and more security to handle them, such as the Xen "zoo" biodome during Opposing force.

  • @rudranarayansamal4168
    @rudranarayansamal4168 8 місяців тому

    Great Video ! Thanks for the detailed explanation

  • @jasper5016
    @jasper5016 8 місяців тому

    Fantastic, wish you could have shown Java code to represent how to think through code. Thanks again

  • @NetEngs4UA
    @NetEngs4UA 9 місяців тому

    This was quite a treat to watch! And quite a nostalgic trip down the memory lane for those of us, who are the 90s kids and still remember the original HL1 release. 😅

  • @imaginecodes2382
    @imaginecodes2382 10 місяців тому

    22:00 i know for this given ip array there will one answer but lets suppose i took an diff ip array like [0,1,0,1,0,0,0,1,1] , there will a tie.

  • @AnandKumar-kz3ls
    @AnandKumar-kz3ls 10 місяців тому

    this is top tier explanation i used to apply sliding window blindly never know the rules thanks bro

  • @sapperjaeger
    @sapperjaeger 10 місяців тому

    super helpful!!

  • @concordat
    @concordat 10 місяців тому

    I believe there have been mods made for the original version of Half-Life that let you explore the facility, pre-disaster. Seems like that might be ideal for this type of video.

  • @erenerdogan4222
    @erenerdogan4222 10 місяців тому

    why do i get localhost- port problem , how can i solve this

  • @devbhattacharya153
    @devbhattacharya153 10 місяців тому

    Thanks man!

  • @kaushik.aryan04
    @kaushik.aryan04 10 місяців тому

    please make more videos on dynammic programming and graphs

  • @kaushik.aryan04
    @kaushik.aryan04 10 місяців тому

    wow you really explained it very well and fast too just what I was looking for

  • @3x6249
    @3x6249 11 місяців тому

    if those arrays are not sorted, why not just combine all of them and apply quick sort?

  • @ImBadAtNames2876
    @ImBadAtNames2876 11 місяців тому

    half life, the game this is absed off of, has an expansion called decay which i hear has a section in the dormitories, but both other expansions and the original game itself have quite an expansive map of the facility. in fact half life i spired me to design a fictional research base of my own that i call titan forge

  • @tezwoacz
    @tezwoacz 11 місяців тому

    So how wide should someone be in order to get hired ?

  • @MartinRadio2
    @MartinRadio2 Рік тому

    this has suddenly stopped working I get error:: invalid_grant every time

  • @nonameman7114
    @nonameman7114 Рік тому

    This is really interesting and informative. I’m designing this huge underground research facility for my sci-fi series and came across this because I’m a huge half life fan. What are some things that media gets wrong about these type of work environments?

  • @Enigma3
    @Enigma3 Рік тому

    i cleaned my macbook today after 10 years and it is running SOOOO FAST again 10 hours a day everyday for 10 years = 364000 hours + 2 spilled coffees it was quite dirty......took me 4 hours lol my battery is about to explode....bulging would be an understatement

  • @MagnetismR
    @MagnetismR Рік тому

    "This should shake up those Grand Unification boys, hm?" "Are you sure you checked the Eigen attenuators?" "Are you running those tunneling lattice calculations again?" The best 1998 has to offer.

  • @mauser98kar
    @mauser98kar Рік тому

    4:48 - A cargo helicopter, I assume. Yes, this heli brings cargo. In form of 8 to 16 Hellfire missiles.

  • @Shinotama
    @Shinotama Рік тому

    I love that you called the Apache AH-64 Attack Helecopter a cargo helicopter haha.. Nothing suspicious about seeing that in a research base.. Cool commentary either way :P