-
Notifications
You must be signed in to change notification settings - Fork 265
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
GRASR strategy #1051
Comments
I'm a newcomer and I'd like to work on this. I did some (admittedly superficial) research and couldn't find anything about the 'Analogy' strategy, so I'm going to follow your suggestion leave that unimplemented for now (with a note in the documentation of the strategy). That being said, I have one question. This paper defines Graaskamp slightly differently:
Should my implementation also play tit-for-tat (TFT) if it detects that the opponent is also using Graaskamp (this is my interpretation of "its own twin")? If so, what is the best way to detect Graaskamp? Is it sufficient to look for 50 rounds of TFT followed by defect followed by 5 more rounds of TFT? |
That's great @SplitInfinity! I suggest going with both implementations. So one can be In terms of "playing it's own twin", you can see the histories of both so I hope that helps :) |
You might have already looked through the documentation but if not this is the specific section on contributing with guidance on writing a strategy: http://axelrod.readthedocs.io/en/stable/tutorials/contributing/index.html 👍 |
If you are willing to look through some Fortran, this strategy appears to be in the second Axelrod tournament as well. See the source code and look for a line "C TYPED BY AX, 3/27/79 (SAME AS ROUND ONE GRAASKAMP)" (there's another strategy "C BY JIM GRAASKAMP AND KEN KATZEN" that I think is different). Here is some info on interpreting the Fortran functions. |
How do you interpret the if statements in that Fortran code? For example, what is the meaning of:
I assume from my knowledge of C that predicate is false only if |
If (...) < 0 go to 1, == 0 Goto 2, < 0 Goto 3. See 11.4 here. |
Thanks! I think I understand the implementation you linked on a statement/language level now but not yet on an algorithmic level. Should |
Ideally these are the same -- hopefully the Fortran can help explain anything missing. |
The one thing @drvinceknight and I couldn't figure out is how to detect if the opponent is using the 'Analogy' strategy. How does the Fortran code you linked do that? |
I don't know -- I haven't taken the time to translate the Fortran code and we don't know what the analogy strategy is in any case. Probably one or more of the conditionals detects whatever analogy was doing... |
My interpretation of this is that the strategy class should take a constructor argument called Another interpretation is that starting at round 57, the implementation should generate a random number Which of these two makes the most sense? |
The FORTRAN is below. It looks like at some point (near the end) the strategy computes Whether the opponent is playing analogy appears to be depending on some count of four things that meets some criteria. That may be difficult to mimic exactly, but you can try to decipher the code below for some clues.
|
I've studied the Fortran and unless I've made a huge mistake (which is possible), it is not the same as the Graaskamp strategy in the Axelrod documentation and in the very first post above. The Fortran code plays tit for tat for 50 rounds, defects in round 51, and plays tit for tat for 5 more rounds. But after that, it does things differently. In round 57, the Fortran code chooses one of four "modes" (stored by the variable Mode 1 Mode 2 Mode 3 Mode 4
In light of these differences, what would you suggest I implement? |
My guess is that one of the following is happening:
My guess is that this is the real strategy. The other Fortran strategy associated to Graaskamp looks totally different (see below). If you're up for it (and it seems like you are!), please implement the strategy as you've deciphered it from the Fortran. @drvinceknight probably recommended using a Chi-squared test since that is what another strategy does and it's a reasonable way to do it. However Mode 3 may also be a way of detecting "random" play (or how someone interpreted that when writing the description). Thanks for looking so closely at the details! There's a bit of archeology involved when implementing these strategies (often the hardest part).
|
I'm almost ready to post a pull request with an implementation of Graaskamp as deciphered from the Fortran. I have a few more loose ends to tie:
|
Hi @SplitInfinity :)
Yup, no smart way that I'm aware of, simply search for a seed which ultimately pins the behaviour you want.
I'd suggest going with:
I've gotten those details from the header on the source code. |
Hi @SplitInfinity just checking how this is going? How do you feel your strategy compares to the description at http://axelrod.readthedocs.io/en/stable/reference/overview_of_strategies.html#graaskamp That description is from Axelrod's first tournament and the Fortran code is from his second. We've come to realise that it's not necessarily true that the author (Graaskamp) would have submitted the same to both. |
It might be that we mark your strategy as Note we've created a separate/partner library that directly speaks to the Fortran code of the second tournament: https://github.com/Axelrod-Python/axelrod-fortran. We've opened #1095 to keep up with translating those Fortran strategies in to Python which I believe is what you have accomplished. |
I've been on vacation for the last month - sorry for not communicating this to the team! The strategy as I deciphered it from the Fortran provided is completely different from the description in the Axelrod documentation (hence the confusion in my earlier posts on this issue). Status This gist shows the strategy and its tests so far: https://gist.github.com/SplitInfinity/ca42d7aa0defe143ee9a08187735fa00 The strategy itself has been implemented, and basic tests against a cooperator, defector and alternator have been written. These tests verify the behaviour of the strategy up to round 57, after which the strategy enters one of four "modes" as described earlier. I'm currently writing tests that test each of these four modes. One of the modes is stochastic, and I'm trying to figure out a smart way to test it. Next Steps |
Welcome back! Open the PR on this repository, please. For the stochastic tests please set random seeds for reproducibility. If you have trouble finding suitable seeds try looping the test over |
Absolutely no problem :) Hope you had a great vacation.
Ok that's great to have all confirmed. 👍
Not sure if you've seen but there's the option to pass a random seed to So that lets you check behaviour for a fixed random path.
Please send it to this repo, the I'm going to rename this issue to reflect that you have reverse engineered and are implementing a Fortran strategy from I suggest you call the strategy I'll also open another issue to get the original Thanks for your work on this. 👍 |
EDIT: This issue is no longer about the strategy described below. It now corresponds to an implementation of a Fortran strategy.
This strategy is one of the strategies from Axelrod's original tournaments. It is described here http://axelrod.readthedocs.io/en/stable/reference/overview_of_strategies.html#graaskamp as:1. Play Tit For Tat for the first 50 rounds;2. Defects on round 51;3. Plays 5 further rounds of Tit For Tat;4. A check is then made to see if the opponent is playing randomly in which case it defects for the rest of the game;5. The strategy also checks to see if the opponent is playing Tit For Tat or another strategy from a preliminary tournament called ‘Analogy’. If so it plays Tit For Tat. If not it cooperates and randomly defects every 5 to 15 moves.Step 4 can be implemented using a chi squared test similarly to the Stein and Rapaport strategy which is implemented here: https://github.com/Axelrod-Python/Axelrod/blob/master/axelrod/strategies/axelrod_first.py#L496Step 5 is a bit tricky as it refers to a strategy called "Analogy". I have not been able to find any information describing this strategy. I suggest that anyone who tries to work on this does their best to find that information but if there is non available let us simply ignore that part of the check but clearly point that out in the documentation of the strategy.(Other strategies that we'd like to implement are available here: #379)The text was updated successfully, but these errors were encountered: