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

Create langtons ant algorithm #8967

Merged
merged 8 commits into from
Aug 21, 2023

Conversation

CaedenPH
Copy link
Contributor

Describe your change:

Implements the langtons ant algorithm
@ https://en.wikipedia.org/wiki/Langton%27s_ant

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

@CaedenPH
Copy link
Contributor Author

@tianyizheng02 Pinging for review

@algorithms-keeper algorithms-keeper bot mentioned this pull request Aug 21, 2023
14 tasks
Copy link
Contributor

@tianyizheng02 tianyizheng02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, only got some minor suggestions. Also, could you add a function to animate the ant? Currently the user must call move_ant and display repeatedly to see the ant move, and it'd be nice if that could be automated.

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Aug 21, 2023
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
@CaedenPH
Copy link
Contributor Author

@tianyizheng02
https://github.com/CaedenPH/Python/blob/langtons-ant/cellular_automata/langtons_ant.py#L95-L98
This animation is a matplotlib animation which calls func (move_ant) frames times. The default frames passed is 100_000 so it would animate langtons ant up to 100_000 iterations. Here is what it looks like

screen-capture.13.webm

At the 11000th iteration, this pattern is created
basic-ant

@CaedenPH CaedenPH requested a review from tianyizheng02 August 21, 2023 14:22
@tianyizheng02 tianyizheng02 merged commit 04fd5c1 into TheAlgorithms:master Aug 21, 2023
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Aug 21, 2023
@CaedenPH CaedenPH deleted the langtons-ant branch August 22, 2023 06:21
sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
* updating DIRECTORY.md

* feat(cellular_automata): Langonts ant algorithm

* updating DIRECTORY.md

* Update cellular_automata/langtons_ant.py

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* Apply suggestions from code review

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>

* fix(langtons-ant): Set funcanimation interval to 1

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
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 this pull request may close these issues.

2 participants