+ 10

Chess AI

I am hoping to make a chess robot, but I need to think small first. If I were to make a chess game in python how could I get the computer to make intelligent moves (depending on previous moves)?

11th Nov 2018, 11:13 PM
Jack
Jack - avatar
5 Answers
+ 17
You need a way to generate all possible legal moves in a given position. Then you can simulate them and look whether the position is better/worse than before. Usually you'd do that not one move ahead but as many as possible. To decide whether a position is good, you need to assign a number to a position by a so-called "heuristic". A simple way would be to count up the material on the board (bishop/knight = 3 pawns, rook = 5 pawns, queen = 9 pawns, king = 1000 pawns). Then you take your material minus your opponents and thats what you try to maximize for (higher = better!). You look at all the moves a couple moves deep and choose the one that has the best worst-case outcome (so you are assuming the opponent plays perfect) There are many ways to make it more sophisticated but that's the basic workings of a chess AI.
12th Nov 2018, 5:11 AM
Schindlabua
Schindlabua - avatar
+ 13
Sololearn created this chess engine contest few weeks ago, many people participated and came up with their solutions . There are many discussions and codes here in the comments that might be helpful. https://www.sololearn.com/learn/11610/?ref=app
12th Nov 2018, 6:23 AM
Morpheus
Morpheus - avatar
+ 7
If I was courageous enough to even try, I'd probably start with the core issue: checkmate. Empty board, two kings, one queen. And then figure out how to make the computer finish me off, probably with a whole bundle of ifs and elses. ;-)
11th Nov 2018, 11:22 PM
HonFu
HonFu - avatar
+ 1
Before making it,u have to be good at Neural networks.which will serve as neuron to the brain of the robot.Then if statements
3rd Feb 2020, 7:34 PM
Khaleed Ameen
Khaleed Ameen - avatar
21st Jul 2020, 3:36 AM
shubham kumar
shubham kumar - avatar