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

Saving values between games #58

Open
Leorias opened this issue May 23, 2021 · 2 comments
Open

Saving values between games #58

Leorias opened this issue May 23, 2021 · 2 comments

Comments

@Leorias
Copy link

Leorias commented May 23, 2021

Because the memory variable gets wiped between games and only retained turn to turn, I imagine that it is not wanted that information about previous games can be saved.

I used a class with simple booleans and the value I set them to got retained from game to game.
Example:

def strategy(history, memory):
    round = history.shape[1] + 1
    if round == 1:
        # This should never be 1
        print(MyMemory.test)
        return 1, MyMemory
    mem = memory
    mem.test = 1
    return 1, mem


class MyMemory:
    test = 0
cai-lw added a commit to cai-lw/PrisonersDilemmaTournament that referenced this issue May 23, 2021
Mitigates carykh#58 by forcing to `reload` the module and reset its global variables (See https://docs.python.org/3/library/importlib.html#importlib.reload)

Confirmed that this fix makes the code in carykh#58 no longer work.

However, there is still ways to get around, and I don't think a complete fix is possible. To prevent this completely we may have to rely on manual inspection.
@cai-lw
Copy link

cai-lw commented May 23, 2021

Great catch. I submitted a mitigation as #60 that makes this example no longer work,.

There are still many ways to get around and I don't think it's possible to fix it completely. But I think in the end Cary will manually inspect all top ranking submissions no matter what, so it will not be a devastating issue.

@jun-bun
Copy link

jun-bun commented May 24, 2021

is it unwanted or just unplanned for initially by @carykh ?

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

No branches or pull requests

3 participants