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

Strategy Design Pattern #45

Closed
meatballs opened this issue Feb 24, 2015 · 3 comments
Closed

Strategy Design Pattern #45

meatballs opened this issue Feb 24, 2015 · 3 comments

Comments

@meatballs
Copy link
Member

Implement the strategy design pattern described here: https://en.wikipedia.org/wiki/Strategy_pattern

This would:

  • Separate the behaviour of a Player from its instantiation and/or participation in a Tournament
  • Simplify the definition of Strategies
  • Allow multiple Players in a Tournament to use the same Strategy
  • Enable dynamic allocation of Strategy to Player at Tournament runtime
  • Enable the Django model layer (Django Application #44) to represent Players and Tournaments as simple objects with properties

Both a function and a class based example of how the pattern might be implemented in Python are described here: http://codereview.stackexchange.com/questions/20718/strategy-design-pattern-with-various-duck-type-classes

@meatballs
Copy link
Member Author

Do we want to bother with this? The structure we have in place now would enable this to be done (I think), but it's still a fair amount of work as all the existing strategies would have to change.

In the short term, the main advantage would be to allow tournaments with more than one player executing the same strategy. If that's of interest, then I'll have a crack at it.

@drvinceknight
Copy link
Member

In the short term, the main advantage would be to allow tournaments with more than one player executing the same strategy. If that's of interest, then I'll have a crack at it.

But this can already be done right?

import axelrod
P1 = axelrod.Cooperator()
P2 = axelrod.Cooperator()
P3 = axelrod.Cooperator()
P4 = axelrod.Defector()
A = axelrod.Tournament([P1, P2, P3, P4])
A.play().generate_scores()

Am I missing something?

Nice to keep this as an optional thing for once we've packaged this so people can run their own tournaments...

@meatballs
Copy link
Member Author

True. Doesn't seem worth the effort at the moment, then.

Probably one to bear in mind in the run up to djangocon, if this gets in as a sprint.

@drvinceknight drvinceknight removed their assignment Apr 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants