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

Better tests, better __main__.py, no duplicates on teams #53

Merged
merged 18 commits into from
Jun 28, 2023
Merged

Conversation

phinate
Copy link
Collaborator

@phinate phinate commented Jun 24, 2023

turns out the use of deepcopy in the Team class in #36 #40 #41 didn't actually fix our issue -- the cause is probably right since it always happens with duplicate pokemon, but this didn't make the pokemon separate from the point of view of the bot.

this fixes the issue indirectly in fitness_mutate and mutate by forcing a resampling whenever duplicate pokemon are generated for the same team. additionally, there's a hard guard to this in Team now which checks the pokemon upon initialisation.

what's not protected against is modifying the .pokemon attribute directly, so I've made this a tuple for now -- needs some ironing out for use in the crossover methods, since they've been designed for numpy arrays. (i cast once or twice atm to get partially around this).

@phinate
Copy link
Collaborator Author

phinate commented Jun 26, 2023

I've also ensured that pokemon cannot be modified in-place by storing them in a tuple, and making the Team module an immutable dataclass. With this and a bunch of duplicate checking, I have yet to encounter #36!

@phinate
Copy link
Collaborator Author

phinate commented Jun 26, 2023

oh aaaaaaand there's support again to write-out teams in the main function -- see p2lab --help :)

@phinate
Copy link
Collaborator Author

phinate commented Jun 26, 2023

i've requested a couple reviews:

  • @AoifeHughes, can you check the basic functionality + tests and see if anything needs changing within the scope of this PR?
  • @philswatton, I've made quite a few changes to the crossover code, so I think it needs your eyes on it again to make sure i've not made any algorithmic mistakes!

@AoifeHughes
Copy link
Collaborator

All tests are passing on latest commit for me.

@phinate
Copy link
Collaborator Author

phinate commented Jun 28, 2023

I'm gonna merge this since I think it's a good base to build on -- we can work out any creases in the genetic algorithm with separate PRs :)

@phinate phinate merged commit f7dd223 into main Jun 28, 2023
@phinate phinate deleted the test-update branch June 28, 2023 08:36
@AoifeHughes
Copy link
Collaborator

I've also ensured that pokemon cannot be modified in-place by storing them in a tuple, and making the Team module an immutable dataclass. With this and a bunch of duplicate checking, I have yet to encounter #36!

This is scary in terms of performance, no?

@phinate
Copy link
Collaborator Author

phinate commented Jun 28, 2023

This is scary in terms of performance, no?

from what? i haven't noticed a slowdown, don't think that the object types here are an issue -- feel free to benchmark something and show me!

@AoifeHughes
Copy link
Collaborator

Also, @phinate https://github.com/alan-turing-institute/p2lab-pokemon/actions/runs/5399005143/jobs/9805574268 any thoughts on this does this need to be raised as an issue?

@phinate
Copy link
Collaborator Author

phinate commented Jun 28, 2023

Also, @phinate https://github.com/alan-turing-institute/p2lab-pokemon/actions/runs/5399005143/jobs/9805574268 any thoughts on this does this need to be raised as an issue?

Ty, just made #57

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