Digital Secrets
Learn how to create an AI that plays chess using a convolutional neural network.
Link for the colab page:
https://colab.research.google.com/drive/1GSeBQdyZH_nHvl52XW0uhXV3Cslho24O
Link for the dataset show in the video:
https://drive.google.com/file/d/1YcFh-uBHflrRuQjh3rQ8CFfY2YKx7ytw
More matches:
https://drive.google.com/file/d/1_p3boDObEEfeRvUhQW8dhEmkD1S2l3KD
(you can load the pgn at https://lichess.org/analysis)
Note about the dataset:
I tested training the AI on two different datasets, the first Stockfish analyzed the positions up to depth 20. And on the second, depth 0. To my surprise, the AI trained in the second dataset achieved a much better result during the training and during the game, probably because it was easier for AI to learn the instant evaluation of stockfish, if you have another idea why this happened, we can talk about it in the comments below.
Source
How did you use stockfish in your program, im trying to make a chass bot aswell but that part I can't figure out
where did you get the dataset from?
Very useful 👍
I copy-pasted the above code directly, and used the dataset he linked in the comments. I got the same loss as he did after training, yet the model played HORRIBLY when I tested it with the get_ai_move function. Im confused, and help would be appreciated
Hi. This is new to me…
Could someone give me the code to create the dataset for training? (Using random_board and stockfish eval I guess)
That's WONDERFUL 🤩🤩🤩 !!! 10/10
Algum br
Do i see correctly that you started your AI with min-max depth set to 1.? It would mean that you are actually not using min-max at all, just returning min-max eval value (taken directly from your NN model). Can you tell something about performance of your bot (or rather algorithm itself?): How deep can you dig inside moves tree to get correct move and a reasonable time to wait?
Very concise explanation, thanks
Absolutely love your tutorial, having a fun time trying different architectures. I could really need some help on generating some more data on higher search depth, to further train the model. But I'm kinda struggling to get the stockfish to work.
By the way, you can change
def minimax_eval(board):
board3d = split_dims(board)
board3d = numpy.expand_dims(board3d, 0)
return model.predict(board3d)[0][0]
to
def minimax_eval(board):
board3d = split_dims(board)
board3d = numpy.expand_dims(board3d, 0)
return model.predict(board3d)[0][0]
model.predict() is super slow for some reason, model() is about 10 times faster.
Could you upload the whole code, I see you implemented 'principla variation search' and encoding could you upload that ?
I can't get the dataset, would you have a solution for that ?
why do i get "No such file or directory: '/content/stockfish': '/content/stockfish'" when i try to "print(stockfish(board, 10))"?
Great Video
Hello, I have been messing around with different tensorflow chess engines and it seems that your engine is the best in its simplicity (it is very simple and very effective – as we can see on your video). Although when i copy-pasted ur code into my colab with the same dataset and stockfish it plays veeeeery poorly. It's like engine is doing random moves without any sense. Did you do any changes in neural network or dataset in your video?
I need help can you help me?
I need chess developer
Very bad matrix sizing and structure.
I keep getting a graph execution error after using model.fit(x_train, y_train)
I keep getting an error when I try to train the model.
Great video! I see that you use a 64 positions output layer. Could you explain this to me? I understand that the boardsize is 8*8, but how do you know which piece to move there?
Hey, it is extremly interesting ! However I doubt that python is adapted for a performant min/max algorithm. Of course you can easily get to depth 4/5 but I don't think that you can go further without having to wait for a while. I will look if I can extract this neural network to a C or C++ program.
2:45 note : this is not the "attacked" areas, this is all the squares white can move to, this makes a difference for pawns (can only move up) and kings (can only move to unchecked squares)
The reason for the AI better performance at depth 0 over depth 20 would be because at depth 0 stockfish returns an evaluation of what is happening on the board at that moment while at depth 20 it is returning an estimate if what will happen in the future.
Training the AI on calm positions at depth 5 should be enough to make a stable AI.
Hi, I just wanted to clarify that in your code it states "h3->17" but it should be 12
I can’t access the google colab file. Apparently it’s not available. Anyone else having the issue ?
links off, download please, convert png images in FEN ?
I would like to know if it were possible to create an AI that plays like a Romantic era player by training it on enough games?
Hello! The link to the dataset is no longer working, where did you get the dataset file from originally?
I like your horror gamem❤
Which could be the difference if we use reinforcement learning? How can we use that method with the same libraries?
fantastic
Can ChatGPT write this for me?