-
Notifications
You must be signed in to change notification settings - Fork 268
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
Algorithm for Memory Depth in FSM #1233
Conversation
next_action, | ||
last_opponent_action)) | ||
|
||
class ActionChain(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move these classes out of the function, it doesn't seem like they use any local data in their definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that they could be moved outside of the function without problem. My reasoning for leaving them in the function is because they're not used anywhere else, and my feeling is that it's similar to a local variable, which could be made global, but encapsulation is better. I know this is a contentious point though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to see these classes outside the function and with unit tests for their behaviour.
The travis error is as follows (docstring format):
The tests are also outputing all the branches as the algorithm proceeds, I'd make that optional (with a verbose kwarg):
|
Can you apply the algorithm to the existing FSM players in the library? The current memory depth values were best guesses at the time the strategies were added. In some cases we inherit from the TestPlayer class to add additional tests, in this case something like TestFSMPlayer where it applies your algorithm to verify, at test time, that the player is of the expected depth. |
We could also consider adding a method to |
Fixed.
I added a print_output flag to go along with the (even more verbose) print_trace flag. |
I'll do that.
Currently the runtime for large FSMs is too long to be tolerable. [Like many times longer than the rest of the tests put together.] I'll see if there are any easy speed-ups. |
A suggestion: one option could be to have a separate repo where we run the algorithm on the fsms perhaps? |
These 16-state strategies take a very long time. I guess the number of branches is growing exponentially. I'm going have to get this thing to run faster. I think there's a memoization here that makes sense. |
I may end up changing stuff for the caching logic. Closing for now. |
In thinking about how to memoize, I ended up changing significantly. It brought the runtime down from days to milliseconds. The new approach is a little abstract, and it may be harder to see that it works, but it does match the other implementation on every FSM strategy, and it passes all of the tests. |
I can probably do these now that it runs fast. |
The error is on the typing syntax, which isn't supported on Python 3.5. However we generally only support the last two trailing versions of Python, so it's time we updated the library to 3.6 and 3.7, which would eliminate the error. @drvinceknight ok with you to drop 3.5 and add 3.7? Edit: See #1235 |
I was thinking to do this in a separate PR, but I hadn't realized that it would be such a minor change. I accepted your PR into this change; it looks good to me.
I think it makes sense to make a FSM section on that page, and mention it on there. It would feel out-of-place otherwise. I'd be happy to write such a section; let me know what you think.
Makes sense to me. I moved it. |
Sounds good to me 👍 |
For a nice overview of FSMs (with the memory length use case) perhaps this section of the docs would be more appropriate: https://axelrod.readthedocs.io/en/stable/tutorials/further_topics/index.html ? |
I decided to leave it on the further topics page, and focus on the way you execute the code. I think the research topics page would be better if I focused on open questions or some of the research around this, but this is sorta how dojo documentation approaches it already. I put this under a broader "meta-strategies" heading, because I thought we could eventually add write-up for things like HMMPlayer, SequencePlayer, LookerUp, and Gambler. I wrote the section that it would be general enough to apply to games other than IPD, in anticipation of 5.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks really good to me @gaffney2010, I've left some minor comments to ensure the docs build, a style suggestion/request for the orderered memit and also a request to modularise some of the tests (sorry for being a pain).
Once these minor tweaks have been made I think this is good to go makes for an awesome contribution. 👍
Closes #119 Since this research was originally started, an algorithm has been proposed to accurately measure the memory of finite state machines: Axelrod-Python/Axelrod#1233 This step manually corrects the known discrepancies but has no effect on the results of the work.
Closes #119 Since this research was originally started, an algorithm has been proposed to accurately measure the memory of finite state machines: Axelrod-Python/Axelrod#1233 This step manually corrects the known discrepancies but has no effect on the results of the work.
Here's the build error (it's in the docs):
|
It's the bib item missing: #1233 (comment) 👍 |
Can't figure out why I can't commit that file. Ended up editing it on Github's GUI. |
I was accidentally making changes to the wrong branch. Got it cleaned up now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you for all the changes @gaffney2010 and thanks for the overall contribution: very very cool.
I'll let @marcharper merge just to be sure he's not unhappy with any of the changes made. 👍
I'll aim to put a new release together tomorrow 👍 |
Hey guys, I just had the pleasure of reading through this thread and wanted to send a shout out. It's a very cool change. And it's encouraging to see the project being so vibrant with so much collaboration :) kudos! |
As discussed here:
#597