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

Fixes #31 (fix lookup_evolve) #50

Merged
merged 7 commits into from
Sep 1, 2018
Merged

Conversation

jsafyan
Copy link
Contributor

@jsafyan jsafyan commented Aug 19, 2018

Fixes #31 and changes mutation_rate to mutation_probability to conform to the Population genetic algorithm class.

@marcharper
Copy link
Member

Thanks! I presume you ran it locally since it looks like we didn't have a broken test.

@jsafyan
Copy link
Contributor Author

jsafyan commented Aug 19, 2018

Yes -- due to limited compute I ran it like this:

$ python lookup_evolve.py --turns 1 --generations 1

which yields
Scoring Generation 1 Generation 1 | Best Score: 2.34536231884058 2:2:2:[C, C]:CDDDCDDCDCCCCCCCCDCCDDDCCDDDDDDDCDCCDDCDDDDDDDCDDCDDDCDDCDCCCCDC

@@ -104,7 +104,7 @@ def mutate(self):

@staticmethod
def crossover_tables(table1, table2):
keys = list(sorted(table1.keys()))
keys = list(table1.keys())
Copy link
Member

Choose a reason for hiding this comment

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

I think we still want the sort here, or is there a good reason to remove it?

Copy link
Contributor Author

@jsafyan jsafyan Aug 19, 2018

Choose a reason for hiding this comment

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

I removed it because it was throwing this error:

TypeError: '<' not supported between instances of 'Action' and 'Action'

I considered defining a total order on the Action class, but I don't think sorting is actually needed here. The keys are considered in the same order for both table1 and table2, so the crosspoint still defines the same partition of the keys for both tables, which seems sufficient.

new_table)

def __repr__(self):
return "{}:{}:{}:{}:{}".format(
self.plays,
self.op_plays,
self.op_start_plays,
''.join(self.initial_actions),
''.join([v for k, v in sorted(self.table.items())])
self.initial_actions,
Copy link
Member

@marcharper marcharper Aug 19, 2018

Choose a reason for hiding this comment

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

actions_to_str here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, please see below.

@marcharper
Copy link
Member

marcharper commented Aug 19, 2018

Looks good, just two questions.

''.join(self.initial_actions),
''.join([v for k, v in sorted(self.table.items())])
actions_to_str(self.initial_actions),
actions_to_str([v for k, v in self.table.items()])
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to sort these guys (via actions like you suggested above). Otherwise these representations won't be unique, and reversing __repr__ won't work in a stable manner.

Copy link
Member

Choose a reason for hiding this comment

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

Once Axelrod-Python/Axelrod#1199 is in and a new release of Axelrod done (I'll do it as soon as) we could bump https://github.com/Axelrod-Python/axelrod-dojo/blob/master/requirements.txt to keep track of the fact that we need the ordered actions?

Copy link
Member

Choose a reason for hiding this comment

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

SGTM

@jsafyan
Copy link
Contributor Author

jsafyan commented Aug 30, 2018

I added sorting back now that Axelrod-Python/Axelrod#1199 has been merged.

Running $ python lookup_evolve.py --turns 1 --generations 1 yields

Scoring Generation 1 Generation 1 | Best Score: 2.3444927536231885 2:2:2:CC:CCDCCDCDDCCDDCDCDDCDDDCCDDCDDDDDCDDDDDDCCDCDCCCCCDDDDDDCCDCCDCDC

@drvinceknight
Copy link
Member

I've just released v4.3.0 of Axelrod on Pypi so now the ordered actions are in the latest release of Axelrod.

@jsafyan could you bump https://github.com/Axelrod-Python/axelrod-dojo/blob/master/requirements.txt#L1 to be:

axelrod>=4.3.0

👍

Side question: any trouble that CI passed even when it would have been using a version of the Axelrod library without ordered actions?

@marcharper
Copy link
Member

Side question: any trouble that CI passed even when it would have been using a version of the Axelrod library without ordered actions?

We don't have a test that makes sure that the pattern representation is sorted, but we need it for reproducibility and reloading previously evolved strategies.

@drvinceknight
Copy link
Member

LGTM (thanks @jsafyan 👍)

@marcharper marcharper merged commit 828fa08 into Axelrod-Python:master Sep 1, 2018
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.

3 participants