![]() This is very strange, because isolated, the make_move() method works just fine. When printing the game state after calling game_state.make_move() in perft(), it seems to have had no effect on the position bitboards (the other properties change like they are supposed to). To sort the vector of legal moves causes the found number of total nodes for the initial position (for depth 3) to change from the wrong 7070 to the (also wrong) 7331. I discovered some interesting new facts that might help to solve the problem, but I don't know what to do with them:įor some reason, using std::sort() like this in perft(): std::sort(legal_moves.begin(), legal_moves.end(), (auto first, auto second)) If you have any idea what the problem could be here, please help me out. When calling perft() on the position you get after making the move a2a3 in the initial position in my engine, it calculates the correct number of total nodes at depth 2, 380:.When calling perft() on the initial position in my engine, it calculates 280 subnodes for a2a3 at depth 3.When calling perft() on the initial position in stockfish, it calculates 380 subnodes for a2a3 at depth 3.But for all moves I tried this with, the engine suddenly starts to output the correct results I expected to get earlier! I figured that my move generator was just buggy, and tried to track down the bugs by making a move the engine gives incorrect values for on the board and then calling perft() with depth = 2 on it to find out which moves are missing. The results stop matching at depth 3, though: Helps you calculate the next best move, explore openings, all by using stockfish engine. It's results for the initial chess position (FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1) for depths 1 and 2 match the results of stockfish's perft command, so I assume they are correct: h2h3: 1 Chess Compass is a free website which can solve analyzing your chess games online with the help of Stockfish. Nodes += perft_no_print(game_state, depth - 1) One Move At A Time Sophisticated chess programs since at least CHESS 4.5 have adopted the opposite strategy: generate a few moves at a time, search them, and if a cutoff can be caused, there will be no need to generate the rest of the moves. Std::cout legal_moves = generator.generate_legal_moves(game_state) Last_move_nodes = perft_no_print(game_state, depth - 1) Std::vector legal_moves = generator.generate_legal_moves(game_state) ![]() For this purpose, I wrote a simple perft() function: int32_t Engine::perft(GameState game_state, int32_t depth) Info string NNUE evaluation using nn-3475407dc199.I am currently developing a chess engine in C++, and I am in the process of debugging my move generator. Stockfish 14 by the Stockfish developers (see AUTHORS file) (That's also the output of the code below) Now, using io.WriteString it finishes after milliseconds without any (visible) calculation: Info depth 4 seldepth 4 multipv 1 score cp -161 nodes 1 tbhits 0 time 12 pv e7e6 f1d3 g8f6 b1c3 Info depth 3 seldepth 3 multipv 1 score cp -161 nodes tbhits 0 time 10 pv e7e6 f1d3 g8f6 Info depth 2 seldepth 2 multipv 1 score cp -161 nodes tbhits 0 time 8 pv e7e6 f1d3 Info depth 1 seldepth 1 multipv 1 score cp -161 nodes tbhits 0 time 7 pv e7e6 Info string NNUE evaluation using nn-3475407dc199.nnue enabled Using my command line tool it searches for about 5 seconds using a depth of 20, and it looks like this: In order to let the engine search for the best move, you use "go depth n" - the higher the depth - the longer it takes to search. ![]() The executable is called "Stockfish" (Chess Engine) and obviously usable via command line tools. I'm using the io package to work with an executable defined in my PATH. Stockfish is a free and strong UCI chess engine derived from Glaurung 2.1 that analyzes chess positions and computes the optimal moves. Or, process all the moves/board appending to data, then open your CSV file and write data writer.writerows(data): This will open the file "for creating" which overwrites any previous data.Īlso, from looking at your code and what you're trying to do, I see there are two ways to accomplish what you want, and you're trying both at the same time and that's creating other issues.Įither open the CSV file for writing, and loop over your moves writing as you process the board/moves with writer.writerow(stockfish(board, 10))/100): As pointed out by Camaendir in the comment, you're opening your output file on every iteration of the move.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |