✅ impossible error

so i'm using a Stack<Move> for my chess board's move history. it somehow managed to raise an out-of-bounds error with the line being directly correlated to this line:
moveHistory.Push(move); // Index was outside the bounds of the array.
moveHistory.Push(move); // Index was outside the bounds of the array.
i have zero fucking clue what this is caused by. here's the rest of my code: https://mystb.in/4b14af70b18dc60777 (line 225-250)
8 Replies
it’s raining outside
checking the docs, there's literally zero way that this error can be raised, so im at a loss for what's happened updated to include lines
canton7
canton74mo ago
Threading If that's actually the line that's raising the error (and it's not Release mode or something changing the lines), that sort of error is almost always two threads using the collection at the same time I don't see any threading in your class, but maybe it's used by multiple threads?
Mako
Mako3mo ago
Have you figured it out? I'm curious to learn what it was the problem
it’s raining outside
oh yeah i found the error basically for the Move struct, the .ToString() representation turns the move into sq1sq2 and sq2 was -1 obviously thats not a square i do "abcdefgh"[sq % 8] + "12345678"[sq // 8] and because -1 % 8 still gives back -1, thats not a valid index i would love to add multithreading to my move generation so it runs faster
Mako
Mako3mo ago
thank you for the follow up! 😁
it’s raining outside
no problem as a followup: how it ended up being -1 is that i declared an array of where the rooks start (in chess960, they're different from classic chess), then i fill in all the spaces of rooks i can see on the board. i didn't use 0 because 0 is a valid index whereas -1 is not. i forgot to make it check that if the retrieved start position wasn't -1 and thats how i ended up getting errors for a method with no possible errors
canton7
canton73mo ago
$close
MODiX
MODiX3mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server