Open rodrigo-sotelo-sd opened 11 months ago
this is accurate to my experience too, yesterday i left off because even though i never feed illegal moves into the system i kept getting illegal moves sent back after a depth of around 4. it could very well still be my fault but have definitely been confused for a few days now.
MakeMove works fine to me, make sure you call UndoMove(move) each time you call MakeMove
I am doing that which is why i find it weird.
Another weird thing is that it says it's playing illegal moves that shouldn't even be possible in any position.
"Illegal move: d1h5 in position: rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1"
d1h5 moves the queen not even in the same diagonal
grr i have taht pronblem too
its so anoying how would you even make a bot without that feature
How do you get your moves to make? Do you use the board's method GetLegalMoves()
?
yes
its board.GetLegalMoves()
Whenever you do a MakeMove
you should have a corresponding UndoMove
, before you can do a MakeMove
of its 'siblings legalMoves'.
wrong
foreach(var m in board.GetLegalMoves())
{
board.MakeMove(m);
// do other stuff
}
right
foreach(var m in board.GetLegalMoves())
{
board.MakeMove(m);
// do other stuff
board.UndoMove(); // undo move m
}
also wrong
foreach(var m in board.GetLegalMoves())
{
board.MakeMove(m);
// do other stuff
// nested calls to GetLegalMoves()
foreach(var m2 in board.GetLegalMoves()) // these are other legal moves than above
{
board.MakeMove(m2);
// do more stuff
}
}
also right
foreach(var m in board.GetLegalMoves())
{
board.MakeMove(m);
// do other stuff
// nested calls to GetLegalMoves()
foreach(var m2 in board.GetLegalMoves()) // these are other legal moves than above
{
board.MakeMove(m2);
// do more stuff
board.UndoMove(); // undo move m2
}
board.UndoMove(); // undo move m
}
I did that but somehow it doesn't want to work
On Wed, 20 Sept 2023, 18:23 Ryan Heath, @.***> wrote:
Whenever you do a MakeMove you should have a corresponding UndoMove, before you can do a MakeMove of its 'siblings legalMoves'.
wrong
foreach(var m in board.GetLegalMoves()) { board.MakeMove(m); // do other stuff }
right
foreach(var m in board.GetLegalMoves()) { board.MakeMove(m); // do other stuff board.UndoMove(); // undo move m }
also wrong
foreach(var m in board.GetLegalMoves()) { board.MakeMove(m); // do other stuff // nested calls to GetLegalMoves() foreach(var m2 in board.GetLegalMoves()) // these are other legal moves than above { board.MakeMove(m2); // do more stuff } }
also right
foreach(var m in board.GetLegalMoves()) { board.MakeMove(m); // do other stuff // nested calls to GetLegalMoves() foreach(var m2 in board.GetLegalMoves()) // these are other legal moves than above { board.MakeMove(m2); // do more stuff board.UndoMove(); // undo move m2 } board.UndoMove(); // undo move m }
— Reply to this email directly, view it on GitHub https://github.com/SebLague/Chess-Challenge/issues/427#issuecomment-1728066498, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCPILCSATCP2E6NUGQMPZ5LX3MKA7ANCNFSM6AAAAAA3CVHTYY . You are receiving this because you commented.Message ID: @.***>
I'm implementing a search function (very similar to the one Sebastian shows in the first coding adventure video) and I'm getting that the bot is making illegal moves on the board and the game is over on the spot.
I think that what's happening is that MakeMove() doesn't update the FEN string of the current position and when I search with depth >= 3, the bot can make moves that are impossible in the current position.
For example, if the bot is black, I play 1.e4 and it starts searching. In that process it plays 1.e5 and it evaluates after white's next move the move e1e2, but the game's FEN string shows there's a pawn there.
Maybe I'm wrong, I'm very new to C# and chess programming. If you need to look at my code I can show it.