Creating a Chess AI with TensorFlow

preview_player
Показать описание
Learn how to create an AI that plays chess using a convolutional neural network.

Link for the colab page:

Link for the dataset show in the video:

More matches:

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.
Рекомендации по теме
Комментарии
Автор

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)

Philgob
Автор

Hello! The link to the dataset is no longer working, where did you get the dataset file from originally?

noahbond
Автор

Great Video, the colab link and the google drive doesn't work, is it possible for you to fix it? Thanks!

soccerstuff
Автор

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

owenjones
Автор

Excellent video. I'm doing a project on this stuff, and this is really helpful.

senyoohene
Автор

Nice video!
About the dataset: It probably works better with depth 0 because a long-term prediction of the game is not required while having a pure intuitive analysis of the current board... so, thanks to that, the network training is more accurate and then, during games, that "long-term prediction" that I mentioned is probably achieved by the minimax algorithm that you implemented to let the ai play.

scasci
Автор

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?

wojciechadamiec
Автор

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 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?

askurmom
Автор

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.

gustavboye
Автор

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.

Champignon
Автор

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?

aesop
Автор

I can’t access the google colab file. Apparently it’s not available. Anyone else having the issue ?

anto
Автор

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?

FSstan
Автор

Hi very interesting, are the links off ?

dlep
Автор

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)

trondamlie
Автор

How did you use stockfish in your program, im trying to make a chass bot aswell but that part I can't figure out

midasscheffers
Автор

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.

lordseidon
Автор

why do i get "No such file or directory: '/content/stockfish': '/content/stockfish'" when i try to "print(stockfish(board, 10))"?

topasta
Автор

I came from "the dark pursuer" game
I want to know how to make a match with somebody else ?

Muhammad-idrt
Автор

I keep getting an error when I try to train the model.

Lord_Liverpool