Closed marcharper closed 6 years ago
Awesome, this would be great to fully get working as it would make things a lot simpler for the revisiting tournament too :)
Ok, I've got a thread-safe implementation now and a proper tournament runs (see example below). There's also a function to find the absolute path on Linux (which works locally) and various documentation leads me to believe that the absolute path is returned by ctypes.util.find_library
on other platforms (which I haven't tested).
However, the travis build still can't find the library, and the local tests never finish for me, using "python -m pytest" locally. I'm not as familiar with pytest
or the travis setup so if either of you see anything please chime in!
from matplotlib import pyplot as plt
import axelrod as axl
from axelrod.action import Action
from axelrod_fortran import Player
from axelrod_fortran.strategies import all_strategies
C, D = Action.C, Action.D
if __name__ == "__main__":
players = (Player('ktitfortatc'),
Player('ktitfortatc'))
match = axl.Match(players, 5)
print(match.play())
players = [Player('ktitfortatc') for _ in range(5)] + [
Player('k42r') for _ in range(5)]
mp = axl.MoranProcess(players)
mp.play()
mp.populations_plot()
print(mp.populations[-1])
players = [Player(name) for name in all_strategies]
tournament = axl.Tournament(players, repetitions=2)
results = tournament.play(processes=4)
print(results.ranked_names)
plot = axl.Plot(results)
plot.save_all_plots("plots")
Nice work @marcharper!
I've taken a quick look at running things locally. Here are my steps:
I have not done anything at all in TourExec
.
To double check things I uninstalled whatever version of the axelrod_fortran
library I had by repeatedly rerunning:
$ pip uninstall axelrod_fortran
Then I installed a develop version of the library to be able to test (this did not actually seem necessary, there might be something that takes care of this in the other files in the repo):
$ python setup.py develop
Then I ran pytest just be typing:
$ pytest
From the stacktrace I believe some things are working but I'm not entirely sure, I've attached the output to this comment: test.log
I'm not sure if that's helpful, when I get a moment I can look in to things a bit more.
pytest still doesn't work locally for me but it seems to be some shenanigans with various library versions that I can't seem to sort. In any case it looks like we're in business!
Nice work @marcharper! Looks good to me, when I get a moment I'll give it a whirl on the reproducing paper repo, should clear up the analysis code nicely :)
This PR adds a class to manage multiple copies of the shared library so that multiple copies of a given player can be used without the user having to maintain multiple copies of the shared library themselves. It does this by literally copying the shared library file and reloading it. (Loading the same file repeatedly doesn't work.)
It works as is and I was able to run the Moran Process for several copies of players, but there are two issues: