You shouldn't worry too much about strongest and fastest at first. The existing top bots are really really hard to compete with. But you can still make something very good for sure.
There's a few core things I would recommend you start coding first.
-
Move generator. Takes a description of a board position, and generates the list of legal moves. This can be quite tricky to get right, common issues are figuring out pins to a king, dealing with en passent and castling rights, checks. If you look on the Chess Programming wiki they have some 'perft results' you can look at. These give you the number of legal moves to a particular depth from some position, and can be used to test your move generator.
-
Evaluation function. In order to judge which position is better, and therefore which move is better, you need some way of evaluating a position. The most simple method is just material count. 1 point for a pawn, 3 for minor piece, 5 for rook, 9 for queen, or whatever you personally want to assign to those. A next improvement to that may be some bonuses for position. There are certain squares that you know a knight is great to have on, so you'd give a bonus for things like that, pawns on the 7th rank etc.
-
Search function. Now that you can generate legal moves and evaluate positions, you need to be able to search to some depth. For example, on a new board, you may say that 1. e4 is at a depth of 1, if you consider blacks response 1. e4 e5, you're at a depth of 2. For the first move on a new board, there are 20 possible moves, and then for each of those, there are 20 possible responses by black. The plan is to find the move which gives you the best possible outcome, but also taking into account the fact that the other player is going to try and counter you. The basic algorithm to learn about for this is called minimax, it's about maximizing the score when it's your turn (as you can choose what happens), and minimizing it when it's the opponent (because they are going to try and force against you, so you have to consider their most deadly possible response).
This to me is the core of an engine, the most basic version. If you got that far, then the next common steps are things like alpha-beta pruning to speed up your search, and piece square tables to improve your evaluation function.
Make sure to read the Chess Programming Wiki, it's really useful.
You shouldn't worry too much about strongest and fastest at first. The existing top bots are really really hard to compete with. But you can still make something very good for sure.
There's a few core things I would recommend you start coding first.
1) Move generator. Takes a description of a board position, and generates the list of legal moves. This can be quite tricky to get right, common issues are figuring out pins to a king, dealing with en passent and castling rights, checks. If you look on the Chess Programming wiki they have some 'perft results' you can look at. These give you the number of legal moves to a particular depth from some position, and can be used to test your move generator.
2) Evaluation function. In order to judge which position is better, and therefore which move is better, you need some way of evaluating a position. The most simple method is just material count. 1 point for a pawn, 3 for minor piece, 5 for rook, 9 for queen, or whatever you personally want to assign to those. A next improvement to that may be some bonuses for position. There are certain squares that you know a knight is great to have on, so you'd give a bonus for things like that, pawns on the 7th rank etc.
3) Search function. Now that you can generate legal moves and evaluate positions, you need to be able to search to some depth. For example, on a new board, you may say that 1. e4 is at a depth of 1, if you consider blacks response 1. e4 e5, you're at a depth of 2. For the first move on a new board, there are 20 possible moves, and then for each of those, there are 20 possible responses by black. The plan is to find the move which gives you the best possible outcome, but also taking into account the fact that the other player is going to try and counter you. The basic algorithm to learn about for this is called minimax, it's about maximizing the score when it's your turn (as you can choose what happens), and minimizing it when it's the opponent (because they are going to try and force against you, so you have to consider their most deadly possible response).
This to me is the core of an engine, the most basic version. If you got that far, then the next common steps are things like alpha-beta pruning to speed up your search, and piece square tables to improve your evaluation function.
Make sure to read the Chess Programming Wiki, it's really useful.
I just played a couple of games against your bot and was impressed. I'm not a very strong player myself so blundered a few times and it put up a fight, it seems quite aggressive but perhaps not a great defender?
In this game for example I threatened the b7 pawn with my Queen (move nine) and the bot removed the bishop defending it, then did some weird pawn pushes and basically gave up both Rooks. It gained a little compensation after I tried to trap the Queen haha but things like the b7 pawn and back rank is a potential weakness that you guys could look at!
https://lichess.org/embed/Debh7x70?theme=auto&bg=auto
I just played a couple of games against your bot and was impressed. I'm not a very strong player myself so blundered a few times and it put up a fight, it seems quite aggressive but perhaps not a great defender?
In this game for example I threatened the b7 pawn with my Queen (move nine) and the bot removed the bishop defending it, then did some weird pawn pushes and basically gave up both Rooks. It gained a little compensation after I tried to trap the Queen haha but things like the b7 pawn and back rank is a potential weakness that you guys could look at!
https://lichess.org/embed/Debh7x70?theme=auto&bg=auto
<Comment deleted by user>
Thanks @Curthis for the feedback. Defense is exactly what we're aiming at improving next.
Thanks @Curthis for the feedback. Defense is exactly what we're aiming at improving next.
<Comment deleted by user>
#25 Besides the online github. you actually need an IDE on home computer, where you can debug, interpret and or compile your code. there are integrations from Github to many IDEs. many IDEs cover many languages... I suggest you do some search and try a few before committing to one, but that is my way of approaching things. I used to like menu ergonomics, but now this getting to be a lost tradition.. I don't know how of which generation your might be. You could just like vs code, right away.
in any case. the only things that are being executed on github are its features about code versioning and collaborating (and correlates). so repository more than code development i would say. You could go step by step. and learn the GitHub from it GitHub desktop. but still you would need an editor. it talks to Atom (a browser in disguise) or vs code.. or maybe more now.
but anyway, the push pull merge branch origin fork upstream words would become understandable in that non-integrated approach. then you could use a real IDE (vs code, visual studio, intellij, eclipse, and others,,, make sure C is part of them).
i suggest you allow python in your baggage... and it is a popular wrapper for chess, as far i bothered to see or remember.
The rest you would have to ask else where i think. The chess programming web site would give you some vocabulary and good overview of the ingredients. (the little i read there was very helpful, but i did not intend to code, just understand how engines might work. And i still don't know, yet. not fully.. but does anyone?
#25 Besides the online github. you actually need an IDE on home computer, where you can debug, interpret and or compile your code. there are integrations from Github to many IDEs. many IDEs cover many languages... I suggest you do some search and try a few before committing to one, but that is my way of approaching things. I used to like menu ergonomics, but now this getting to be a lost tradition.. I don't know how of which generation your might be. You could just like vs code, right away.
in any case. the only things that are being executed on github are its features about code versioning and collaborating (and correlates). so repository more than code development i would say. You could go step by step. and learn the GitHub from it GitHub desktop. but still you would need an editor. it talks to Atom (a browser in disguise) or vs code.. or maybe more now.
but anyway, the push pull merge branch origin fork upstream words would become understandable in that non-integrated approach. then you could use a real IDE (vs code, visual studio, intellij, eclipse, and others,,, make sure C is part of them).
i suggest you allow python in your baggage... and it is a popular wrapper for chess, as far i bothered to see or remember.
The rest you would have to ask else where i think. The chess programming web site would give you some vocabulary and good overview of the ingredients. (the little i read there was very helpful, but i did not intend to code, just understand how engines might work. And i still don't know, yet. not fully.. but does anyone?
@Darsh_Shah_07
I agree with @dboing that you should consider using Python. Although you say you already know C, and in reality the best engines will be coded in languages like C/C++ for the speed they can give, Python may be better for the first explorations into an engine.
When I did my experiments I used the Python chess library:
https://github.com/niklasf/python-chess
I used this library to deal with generating legal moves, representing a board and some other basic utility stuff. To me this is the more boring stuff, I wanted to concentrate on things like how to best evaluate a position, so it was good to offload the grunt work to this library.
I also took some code from Sunfish:
https://github.com/thomasahle/sunfish
I took the xboard.py file from that project and made it call my code instead of the sunfish engine, so that I could use my engine with the xboard/winboard chess GUI.
@Darsh_Shah_07
I agree with @dboing that you should consider using Python. Although you say you already know C, and in reality the best engines will be coded in languages like C/C++ for the speed they can give, Python may be better for the first explorations into an engine.
When I did my experiments I used the Python chess library:
https://github.com/niklasf/python-chess
I used this library to deal with generating legal moves, representing a board and some other basic utility stuff. To me this is the more boring stuff, I wanted to concentrate on things like how to best evaluate a position, so it was good to offload the grunt work to this library.
I also took some code from Sunfish:
https://github.com/thomasahle/sunfish
I took the xboard.py file from that project and made it call my code instead of the sunfish engine, so that I could use my engine with the xboard/winboard chess GUI.
Agree with @RookToZ99, python with python-chess is probably the easiest way to get started. This is also what @Babibot is using.
To follow-up on #1, moderators have responded positively and un-banned @Babibot ! 🎉
Agree with @RookToZ99, python with python-chess is probably the easiest way to get started. This is also what @Babibot is using.
To follow-up on #1, moderators have responded positively and un-banned @Babibot ! 🎉
<Comment deleted by user>