cristal-smac / ipd Goto Github PK
View Code? Open in Web Editor NEWAll about Iterated Prisoner's Dilemma. Python code and jupyter notebooks. See how to build new strategies and evaluate them.
License: GNU Lesser General Public License v3.0
All about Iterated Prisoner's Dilemma. Python code and jupyter notebooks. See how to build new strategies and evaluate them.
License: GNU Lesser General Public License v3.0
According to the definition of Tf2t, Tf2t strategy will defect only when the opponent defected in the previous two moves.
In your implementation of Tf2t, it will defect when the opponent defected in the previous move, so
I think the following program needs to be modified. We present the modified version as “After fix”.
Now
Lines 60 to 67 in e6862a8
After fix
def getAction(self, tick):
if tick == 0 or tick == 1:
return "C"
else:
if self.hisPast[-1] == "D" and self.hisPast[-2]=="D": #here
return "D"
else:
return "C"
AttributeError Traceback (most recent call last)
Cell In[38], line 13
9 bag += [setGenericName(strat)]
12 # Evolution of the initial class
---> 13 e1 = Ecological(g, mem11)
14 e1.run()
16 evol=e1.historic
File ~/Dropbox/newGit/prisoners del/src/ipd.py:127, in Ecological.init(self, tournament, pop, max_iter)
125 self.max_iter = max_iter
126 self.tournament = tournament
--> 127 if not tournament.ran:
128 print("warning: running passed Tournament. This step may take a while.")
129 self.tournament.run()
AttributeError: 'Game' object has no attribute 'ran'
Running the provided example or anything else as an ecological simulation fails:
Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
I'm running this on Windows 10 64-bit if that helps.
>>> e.run()
C:\Users\macbr\Programming\ipd\src\ipd.py:206: RuntimeWarning: overflow encountered in long_scalars
self.base * parent * self.scores[strat.name] / total
C:\Users\macbr\Programming\ipd\src\ipd.py:193: RuntimeWarning: overflow encountered in long_scalars
self.scores[strat.name]
C:\Users\macbr\Programming\ipd\src\ipd.py:192: RuntimeWarning: overflow encountered in long_scalars
total += (
C:\Users\macbr\Programming\ipd\src\ipd.py:206: RuntimeWarning: invalid value encountered in long_scalars
self.base * parent * self.scores[strat.name] / total
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\macbr\Programming\GitHub\ipd\src\ipd.py", line 205, in run
self.historic.at[self.generation + 1, strat.name] = math.floor(
ValueError: cannot convert float NaN to integer
or
>>> e.run()
C:\Users\macbr\Programming\ipd\src\ipd.py:206: RuntimeWarning: overflow encountered in long_scalars
self.base * parent * self.scores[strat.name] / total
C:\Users\macbr\Programming\ipd\src\ipd.py:193: RuntimeWarning: overflow encountered in long_scalars
self.scores[strat.name]
C:\Users\macbr\Programming\ipd\src\ipd.py:192: RuntimeWarning: overflow encountered in long_scalars
total += (
Warning : max_iter reached
at one point also:
>>> e.run()
C:\Users\macbr\Programming\ipd\src\ipd.py:206: RuntimeWarning: overflow encountered in long_scalars
self.base * parent * self.scores[strat.name] / total
Warning : max_iter reached
These are the drawPlot() results for the example in the README.md
The affected readme for reference f2f766d
Unfortunately I don't have much experience with python, else I would try to fixing these issues myself.
Macbrayne
I'm having troubles executing the examples for running a ecological simulation. If I try running
from ipd import *
from strategies import *
bag=[Periodic("D"), HardMajority(), Tft(), Spiteful(), Gradual()]
e= Ecological(g,bag, 1000, pop=[100])
e.run()
e.tournament.matrix
e.historic
e.drawPlot()
I get the error message:
Traceback (most recent call last):
File "c:/Users/<redacted>/GitHub/ipd_experiments/test.py", line 5, in <module>
e= Ecological(g,bag, 1000, pop=[100])
TypeError: __init__() got multiple values for argument 'pop'
I'm unfortunately not very experienced in Python; is this connected to your recent changes to the Ecological class?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.