-
Notifications
You must be signed in to change notification settings - Fork 43
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
Board initializer use of piece.hashValue crashes under Swift 4.2 #21
Comments
I dealt with the issue in my fork of the repository: https://github.com/SuperGeroy/Sage Indeed the piece.hashValue property was used like a rawValue and behavior of hash values changed under Swift 4.2. |
@SuperGeroy are you taking over the project ? I am looking at your fork and it does work on my project (Xcode 10 & Swift 4.2) but I had to put the Also I am looking at a way to have the Here's what I got so far:
Any help appreciated :) |
Yes, I will further clean up the code to work well with Swift 4.2. I am not using CocoaPods but rather copy the files directly into a project so I cannot say much about that. Should I correct the description in the readme? PGN move parsing works for me with pull request #10. Need to include it in my branch though. |
Thanks @SuperGeroy, #10 seems to be exactly what I needed.
Yes. |
Swift 4.2 introduced random seeding for hashing so that hash values are really different each time the program runs.
The board initializer function in line 360 of
Board.swift
uses hash values as identifier for an array with 12 elements which under Swift 4.2/XCode 10 causes an index out of range error:The critical code is in the
for
loop:_bitboards[piece.hashValue] = Bitboard(startFor: piece)
now crashes the program.I understand why the error is there but don't know why this program ran without error under Swift 4.1 because the hash value should (also under Swift 4.1) be a kind of random
Int
which may be bigger than the maximum index number 11 of the_bitboards
array.@nvzqz seemed to have used the
piece.hashValue
rather like an identifier or rawValue.Any help in explaining why the program didn't crash under Swift 4.1 and in rectifying the error would be appreciated!
The text was updated successfully, but these errors were encountered: