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

Game of life live_neighbor_count wrong neighbour index #177

Closed
tinoism opened this issue Jul 3, 2019 · 1 comment
Closed

Game of life live_neighbor_count wrong neighbour index #177

tinoism opened this issue Jul 3, 2019 · 1 comment

Comments

@tinoism
Copy link

tinoism commented Jul 3, 2019

The function in live_neighbor_count of Game of life should iterate delta_* from [-1, 0, 1] instead of from [self.height - 1, 0, 1] and [self.width - 1, 0, 1].

@tinoism
Copy link
Author

tinoism commented Jul 3, 2019

Just realized that it wouldn't compile... Although the intuition about having the negative index is correct, in rust we annotate the negative indices by adding the length of the array. For instance, "negative indexes like -1 and -2 get added to the length of the slice to become real indices, like len - 1 and len - 2" as indicated in this issue.

@tinoism tinoism closed this as completed Jul 3, 2019
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

Successfully merging a pull request may close this issue.

1 participant