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

fixed the rock-paper-scissors docs example #1419

Closed
wants to merge 5 commits into from

Conversation

alexhroom
Copy link
Contributor

Fixes a mistake in the doc page added by #1413 - it turns out that strategies can recognise actions from different games corresponding to the same row/column, so long as both of the Action classes have a total ordering. That is:

Using the example code from before this PR:
axl.rockpaperscissors.RPSAction.P == axl.Action.D -> False
After this PR:
axl.rockpaperscissors.RPSAction.P == axl.Action.D -> True

This is good news for the interoperability of different games! :)

@drvinceknight
Copy link
Member

Not actually sure what's causing the sphinx failure on read the docs. Here's the stack trace:

raceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/sphinx/registry.py", line 472, in load_extension
    mod = __import__(extname, None, None, ['setup'])
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/sphinx/builders/linkcheck.py", line 19, in <module>
    from requests.exceptions import HTTPError
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/urllib3/__init__.py", line 39, in <module>
    "urllib3 v2.0 only supports OpenSSL 1.1.1+, currently "
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.0.2n  7 Dec 2017. See: https://github.com/urllib3/urllib3/issues/2168

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/sphinx/application.py", line 224, in __init__
    self.setup_extension(extension)
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/sphinx/application.py", line 449, in setup_extension
    self.registry.load_extension(self, extname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/axelrod/envs/1419/lib/python3.7/site-packages/sphinx/registry.py", line 475, in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname, err)
sphinx.errors.ExtensionError: Could not import extension sphinx.builders.linkcheck (exception: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with OpenSSL 1.0.2n  7 Dec 2017. See: https://github.com/urllib3/urllib3/issues/2168)

Extension error:
Could not import extension sphinx.builders.linkcheck (exception: urllib3 v2.0 only supports OpenSSL 1.

I believe this is fixed here: readthedocs/readthedocs.org#10290. Will open a PR (hopefully) a fix to your branch @alexhroom.

This is to fix a build problem that surfaced on Axelrod-Python#1419
@drvinceknight
Copy link
Member

I've opened alexhroom#1

@alexhroom
Copy link
Contributor Author

@drvinceknight looks like it's working - i also had to add numpy to the doc requirements.txt since it isn't being mocked.

@marcharper
Copy link
Member

axl.rockpaperscissors.RPSAction.P == axl.Action.D -> True

I'm still not convinced we want this to be true -- it feels like a type mismatch. axl.action.D could reasonably equal RPSAction.S as well (being the last play rather than the second play). We're forcing a specific permutation of the actions for not a lot of benefit IMO.

Regardless of the mapping chosen, a 2x2 player like TFT may be able to technically play a game of higher dimension, but only in a degenerate way (restricted to a subset of actions). I don't see that this is really useful, other than perhaps refactoring some of the (degenerate) pure strategies like Cooperator and Defector to be more generic.

@alexhroom
Copy link
Contributor Author

@marcharper it matters a lot less now we've got a better idea on how we're going to redesign/refactor strategies - i'll leave this for now and create a separate PR just with the RTD fix.

@alexhroom alexhroom closed this May 11, 2023
@alexhroom alexhroom deleted the rps-docs-fix branch May 11, 2023 15:02
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

Successfully merging this pull request may close these issues.

3 participants