Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of range error #7

Open
tinitus-git opened this issue Jun 3, 2021 · 1 comment
Open

Index out of range error #7

tinitus-git opened this issue Jun 3, 2021 · 1 comment

Comments

@tinitus-git
Copy link

I have the following FEN string:

r1b1kb1r/pppp1ppp/2n1p3/8/1PPPnP1q/8/P5PP/RNBQKBNR b - b3 0 1

which is causing an index out of bounds exception in RemovePieceAtSquare. Here is the callstack:

IndexOutOfRangeException: Index was outside the bounds of the array.
PieceList.RemovePieceAtSquare (System.Int32 square) (at Assets/Scripts/Core/PieceList.cs:29)
Chess.Board.MakeMove (Chess.Move move, System.Boolean inSearch) (at Assets/Scripts/Core/Board.cs:79)
Chess.Search.SearchMoves (System.Int32 depth, System.Int32 plyFromRoot, System.Int32 alpha, System.Int32 beta) (at Assets/Scripts/Core/AI/Search.cs:176)
Chess.Search.StartSearch () (at Assets/Scripts/Core/AI/Search.cs:77)
Chess.Game.AIPlayer.StartSearch () (at Assets/Scripts/Core/AIPlayer.cs:69)
Chess.Game.AIPlayer.NotifyTurnToMove () (at Assets/Scripts/Core/AIPlayer.cs:56)
Chess.Game.GameManager.NotifyPlayerToMove () (at Assets/Scripts/Core/GameManager.cs:175)
Chess.Game.GameManager.NewGame (Chess.Game.GameManager+PlayerType whitePlayerType, Chess.Game.GameManager+PlayerType blackPlayerType) (at Assets/Scripts/Core/GameManager.cs:121)
Chess.Game.GameManager.Start () (at Assets/Scripts/Core/GameManager.cs:56)

The fen string seems to be ok but I am seeing this error in my own application and when I force it in the chess-ai-main application.

Thanks,

Brian

@tinitus-git
Copy link
Author

OK I think I understand the issue....at least on a theoretical level. The fen string that I gave would never happen in a real classical game of chess. The problem is that the white king is in check and it is black's move. This would never happen in an actual real game of chess because white would have to get him or herself out of check on their move.

My game is a slight variation of chess and this situation can come up. I think I know what to do about this exception, but if there are any thoughts you have, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant