Open cai-lw opened 3 years ago
The following code can still retain variables in MyMemory
class between games.
import random
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
try:
MyMemory
except NameError:
class MyMemory:
test = 0
Mitigates #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 #58 no longer work.
However, there are 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.