✅ 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:
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
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
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?
Have you figured it out? I'm curious to learn what it was the problem
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 fasterthank you for the follow up! 😁
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$close
If you have no further questions, please use /close to mark the forum thread as answered