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

Update cycle detection to be more efficient #809

Merged
merged 2 commits into from
Jan 10, 2017
Merged

Conversation

marcharper
Copy link
Member

@marcharper marcharper commented Jan 9, 2017

Profiling indicates that detect_cycles is one most expensive functions in the library, so I rewrote it and the players that use it to be more efficient (without altering their behaviors significantly).

This PR decreases tournament run time by approx 20%.

Copy link
Member

@drvinceknight drvinceknight left a comment

Choose a reason for hiding this comment

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

Tiny PEP8. Feel free to push the fix and merge :)

@@ -44,6 +44,13 @@ def strategy(self, opponent):
return C


def is_alternator(history):
for i in range(len(history) - 1):
if history[i] == history[i+1]:
Copy link
Member

Choose a reason for hiding this comment

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

PEP8 i + 1

@marcharper marcharper merged commit ce9c4ed into master Jan 10, 2017
@marcharper marcharper deleted the cycle_update branch January 31, 2017 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants