# The PROPER Chess Game, Not a Rip Off

**URL:** https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050
**Category:** Collaboration
**Created:** [December 14, 2023, 9:52pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050 "2023-12-14T21:52:52Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![pixelking12](https://avatars.discourse-cdn.com/v4/letter/p/ecc23a/32.png) [@pixelking12](https://forum.makecode.com/u/pixelking12)
#### Post date: [December 14, 2023, 9:52pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/1 "2023-12-14T21:52:53Z")

</div>

hey guys, I know that this sounds crazy impossible but i really want to make a proper chess game. Like proper. Not multiplayer but like an ai bot that can see forks pins, and can predict checkmates to make the best possible moves. We would need to make a piece know if it is in danger of being taken and have a variable for that so that the bot would take your piece in a situation but would always take the best piece meaning the pieces have to be ranked in a variable also. I know this sounds impossible but if @UnsignedArduino is ok with this then I will create a copy of his game form the forum [Arcade Advanced Stream #211 - Recreating ALL of Chess in ONE STREAM](https://forum.makecode.com/t/arcade-advanced-stream-211-recreating-all-of-chess-in-one-stream/6522) (post 15) on my laptop and make major changes. This might have the most block code of all time, but no promises. I also know that I seem like a noob at coding as i don’t have many posts on the forums but I’m not as terrible as you think.

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [December 14, 2023, 10:24pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/2 "2023-12-14T22:24:40Z")

</div>

So making a chess bot? I wonder if you could use @randomuser’s [AI Extension](https://forum.makecode.com/t/the-ai-extension-is-here/23603) to make one…

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [December 16, 2023, 6:32am UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/3 "2023-12-16T06:32:46Z")

</div>

Chess bots usually work based on evaluation algorithms, not machine learning. You only introduce real AI when you get to a very high level, but that’s waaay outside of the scope of makecode

---

<div class="post-metadata">

### Author: ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)
#### Post date: [December 16, 2023, 6:36am UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/4 "2023-12-16T06:36:11Z")

</div>

Thanks for summoning me Luke! Looking it over, I could modify my extension to fit this bot, but the TLDR is it would suck at chess. Chess is hard, complicated, and long- training would be a nightmare! Even getting it to make legal moves would take forever.

An AI opponent in a video game is a great idea though, and I’m working on an RPG style one! 😉

---

<div class="post-metadata">

### Author: ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)
#### Post date: [December 18, 2023, 4:54pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/5 "2023-12-18T16:54:14Z")

</div>

> [@pixelking12](#):
>
> …if @UnsignedArduino is ok with this then I will create a copy of his game form the forum [Arcade Advanced Stream #211 - Recreating ALL of Chess in ONE STREAM](https://forum.makecode.com/t/arcade-advanced-stream-211-recreating-all-of-chess-in-one-stream/6522) (post 15)…

Of course! (I’m pretty sure I stole the assets from Vivian when I did this 😅)

* * *

> [@pixelking12](#):
>
> …an ai bot that can see forks pins, and can predict checkmates to make the best possible moves. We would need to make a piece know if it is in danger of being taken and have a variable for that so that the bot would take your piece in a situation but would always take the best piece meaning the pieces have to be ranked in a variable also…

The [Chess Programming Wiki](https://www.chessprogramming.org/Main_Page) will be your best friend!

If you do it the typical way chess engines do it, your engine does not directly see forks, pins, and attacks. The most common method chess engines use, including Stockfish (the best chess engine in the world), is a highly-optimized mini-max search tree with alpha-beta pruning so that bad moves (such as walking into an absolute pin or not defending against checkmate) are pruned from the search tree. This allows the engine to search _millions_ of positions per second deep into the future, often 20+ moves ahead. You will also need to write a fast evaluation function, which can be handcrafted (like old Stockfish) or using a neural network trained on _billions_ of positions to estimate the chance of a side winning from this position. (New Stockfish and Leela Chess Zero use this) Unfortunately, I don’t think it will be practical to train a neural network of that size and load it into MakeCode, so have fun writing an evaluation function!

**The Chess Programming Wiki has a great [getting started](https://www.chessprogramming.org/Getting_Started) guide that will guide you through creating a chess engine**, including pseudo-code for algorithms and other ideas. Unfortunately, my code will not be very useful because it does not have a good complete bug-free board representation, you should create your own in an extension using classes.

* * *

> [@Luke](#):
>
> I wonder if you could use @randomuser’s [AI Extension](https://forum.makecode.com/t/the-ai-extension-is-here/23603) to make one…

As mentioned above, I think the network will have to be extremely big to have decent strength…I think it will be better to write your own custom evaluation function instead. (But if you try I’d love to see the results!)

* * *

Shameless self-promotion: My friend and I have been working on **TinyChess** - a chess engine _optimized for memory usage_ - perfect for a constrained environment like MakeCode Arcade’s VM! It’s still not complete, has many bugs, is slow, sees like 4 moves into the future, looks ugly AF, and has some unholy C++ code (yea it’s written in C++ 😬) but if you would like to take a look here it is:

> **[GitHub - Bobingstern/TinyChess: A small chess engine in C++](https://github.com/Bobingstern/TinyChess)**
>
> A small chess engine in C++

* * *

Ugh, now I want to make a real working chess game as well that has a working chess bot…

---

<div class="post-metadata">

### Author: ![ChimbroDaPro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/chimbrodapro/32/15852_2.png) [@ChimbroDaPro](https://forum.makecode.com/u/ChimbroDaPro)
#### Post date: [December 18, 2023, 5:09pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/6 "2023-12-18T17:09:20Z")

</div>

Oooooh! I can help! I recently made a chess bot using minimax!

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [December 18, 2023, 5:11pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/7 "2023-12-18T17:11:12Z")

</div>

To elaborate on what I mean, here’s an example

[![](https://img.youtube.com/vi/U4ogK0MIzqk/maxresdefault.jpg "Coding Adventure: Chess") ](https://www.youtube.com/watch?v=U4ogK0MIzqk)

Sebastian Lague made a chess bot, which does not include any machine learning, but rather just a complex set of algorithms that predict good next moves.

---

<div class="post-metadata">

### Author: ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)
#### Post date: [December 18, 2023, 6:44pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/8 "2023-12-18T18:44:39Z")

</div>

Wow, that’s amazing!

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [December 18, 2023, 6:49pm UTC](https://forum.makecode.com/t/the-proper-chess-game-not-a-rip-off/25050/9 "2023-12-18T18:49:59Z")

</div>

I’m literally watching the premiere for his chess bot tournament right now lol
