-
-
Notifications
You must be signed in to change notification settings - Fork 49.3k
Create wa-tor algorithm #8899
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
Create wa-tor algorithm #8899
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
Co-authored-by: Christian Clauss <cclauss@me.com>
for more information, see https://pre-commit.ci
|
Again, not sure why build is failing. All tests pass locally for my algorithm |
It looks to be something in one of |
|
Please rename |
|
@CaedenPH Let's see if the build succeeds now |
|
Works 👍 |
tianyizheng02
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General feedback:
- Per PEP8,
x is True->x - Rather than iterating over the 4 possible directions and having multiple nested if-statements handling each direction, it's a lot simpler to just iterate over a list of the 4 neighboring squares and handle them in a more generic manner. For example, instead of checking if
row - 1 >= 0when the direction is North and ifrow + 1 < self.heightwhen the direction is South, just check whether the row to move to is in bounds:0 <= r < self.height. An extra comparison or two is worth the increased readability, IMO.
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
ea3869f to
9f23c25
Compare
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
6f61366 to
e659bd1
Compare
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
c025f8a to
d277dba
Compare
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
faafb49 to
7dc6788
Compare
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
for more information, see https://pre-commit.ci
|
@tianyizheng02 Apologies for not responding earlier, I've been very busy with work. The suggestions regarding simplifying the logic for neighbouring cells you made are logical, however they don't account for the weighting order. Might be better to leave it as is |
tianyizheng02
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Describe your change:
Implements the wa-tor algorithm (https://en.wikipedia.org/wiki/Wa-Tor)
The wa-tor algorithm is a cellular automata featuring predators and prey. All code is doctested and documented, linking to multiple sources.
Checklist: