|
2 | 2 |
|
3 | 3 | A minimal chess engine (not UCI, not XBoard, but only search and evaluation functions) |
4 | 4 |
|
5 | | -Source: Disservin/chess-library |
6 | | - |
7 | | -After seeing ["BEST C++ CODE ever written" // Code Review](https://www.youtube.com/watch?v=NeHjMNBsVfs) and [NicholasMaurer2005/ChessConsole](https://github.com/NicholasMaurer2005/ChessConsole) (the github page related) I see some major problems: |
8 | | -- Displacement of methods [1] [2] [3] [4] [5] |
9 | | -- Use `std::endl` [6] |
10 | | -- Use `rand()` [7] [8] |
11 | | -- `using namespace std;` in header (already covered) |
12 | | -- Optimize branch prediction [9] [10] |
13 | | -Citations: |
14 | | -- [1]: [Engine::makeMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L478) |
15 | | -- [2]: [Engine::printBoard](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L376) |
16 | | -- [3]: [Engine::inputAndParseMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L394) |
17 | | -- [4]: [Engine::squareToIndex](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L470) |
18 | | -- [5]: [Engine::kingInCheck](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L346) |
19 | | -- [6]: [std::endl](https://en.cppreference.com/w/cpp/io/manip/endl) |
20 | | -- [7]: [How good is the current implementations of rand() in C?](https://scicomp.stackexchange.com/questions/30479/how-good-are-current-implementations-of-rand-in-c) |
21 | | -- [8]: [Faster than rand()?](https://stackoverflow.com/questions/26237419/faster-than-rand) |
22 | | -- [9]: [MoveList::FindMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/MoveList.cpp#L35) |
23 | | -- [10]: [MoveList::FindCastleMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/MoveList.cpp#L35) |
| 5 | +**Source**: [Disservin/chess-library](https://github.com/Disservin/chess-library) |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +After watching ["BEST C++ CODE ever written" // Code Review](https://www.youtube.com/watch?v=NeHjMNBsVfs) and exploring [NicholasMaurer2005/ChessConsole](https://github.com/NicholasMaurer2005/ChessConsole), I noticed several issues that should be addressed: |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +### Problems in the Code: |
| 14 | + |
| 15 | +1. **Displacement of methods:** |
| 16 | + - [Engine::makeMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L478) |
| 17 | + - [Engine::printBoard](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L376) |
| 18 | + - [Engine::inputAndParseMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L394) |
| 19 | + - [Engine::squareToIndex](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L470) |
| 20 | + - [Engine::kingInCheck](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/Engine.cpp#L346) |
| 21 | + |
| 22 | +2. **Use of `std::endl`:** |
| 23 | + - [Link to std::endl](https://en.cppreference.com/w/cpp/io/manip/endl) |
| 24 | + |
| 25 | +3. **Use of `rand()`:** |
| 26 | + - [How good is the current implementations of rand() in C?](https://scicomp.stackexchange.com/questions/30479/how-good-are-current-implementations-of-rand-in-c) |
| 27 | + - [Faster than rand()?](https://stackoverflow.com/questions/26237419/faster-than-rand) |
| 28 | + |
| 29 | +4. **`using namespace std;` in header.** |
| 30 | + |
| 31 | +5. **Optimize branch prediction:** |
| 32 | + - [MoveList::FindMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/MoveList.cpp#L35) |
| 33 | + - [MoveList::FindCastleMove](https://github.com/NicholasMaurer2005/ChessConsole/blob/master/ChessConsole/MoveList.cpp#L35) |
0 commit comments