-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
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 review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to 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 <[email protected]>
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 👍 |
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 >= 0
when the direction is North and ifrow + 1 < self.height
when 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 <[email protected]>
ea3869f
to
9f23c25
Compare
Co-authored-by: Tianyi Zheng <[email protected]>
Co-authored-by: Tianyi Zheng <[email protected]>
Co-authored-by: Tianyi Zheng <[email protected]>
6f61366
to
e659bd1
Compare
Co-authored-by: Tianyi Zheng <[email protected]>
c025f8a
to
d277dba
Compare
Co-authored-by: Tianyi Zheng <[email protected]>
Co-authored-by: Tianyi Zheng <[email protected]>
Co-authored-by: Tianyi Zheng <[email protected]>
Co-authored-by: Tianyi Zheng <[email protected]>
Co-authored-by: Tianyi Zheng <[email protected]>
faafb49
to
7dc6788
Compare
Co-authored-by: Tianyi Zheng <[email protected]>
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 |
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
* feat(cellular_automata): Create wa-tor algorithm * updating DIRECTORY.md * chore(quality): Implement algo-keeper bot changes * Update cellular_automata/wa_tor.py Co-authored-by: Christian Clauss <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor(repr): Return repr as python object * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * Update cellular_automata/wa_tor.py Co-authored-by: Tianyi Zheng <[email protected]> * refactor(display): Rename to display_visually to visualise * refactor(wa-tor): Use double for loop * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * chore(wa-tor): Implement suggestions from code review --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Tianyi Zheng <[email protected]>
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: