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

Three new ZD strategies #1097

Merged
merged 4 commits into from
Jul 29, 2017
Merged

Three new ZD strategies #1097

merged 4 commits into from
Jul 29, 2017

Conversation

marcharper
Copy link
Member

Also:

  • moved ZD strategies to their own file
  • fixed a reset bug on NTitsForMTats
  • various style cleanups

Copy link
Member

@drvinceknight drvinceknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typo and a minor request, also zero_determinant needs to be added to docs/reference/all_strategies :)


class ZDExtort3(LRPlayer):
"""
An extortionate strategy from Press and Dyson's paper an extortion factor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with an extortion

}

def test_four_vector(self):
expected_dictionary = {(C, C): 0.64, (C, D): 0.18, (D, C): 0.28,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write these as fractions here? (Just to avoid floating point errors)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took them from the reference like that. Can change if you want...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only to avoid the numerical manipulation carried out by the strategy to throw out numerical floating point errors at some point? (if it never fails then I'm completely fine with them being numeric, just trying to avoid a trivial fix in the future)

>>> import sympy as sym
>>> sym.nsimplify(.64), sym.nsimplify(0.18), sym.nsimplify(0.28)
(16/25, 9/50, 7/25)


def reset(self):
super().reset()
self.retaliate_count = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not tripping a test means we can probably improve the test...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hypothesis caught it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just written another one. Pushing it now :)

drvinceknight added a commit that referenced this pull request Jul 29, 2017
We were only playing against Random, @marcharper found and fixed a bug via
hypothesis on it here:
#1097

This catches the bug too:

Axelrod(pass-match-attributes) ✗: python -m unittest
axelrod.tests.strategies.test_titfortat
...............................................................................F................................................................
======================================================================
FAIL: test_reset_history_and_attributes
(axelrod.tests.strategies.test_titfortat.TestNTitsForMTats)
Make sure resetting works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/home/vince/src/Axelrod/axelrod/tests/strategies/test_player.py",
  line 411, in test_reset_history_and_attributes
      self.assertEqual(player, clone)
      AssertionError: N Tit(s) For M Tat(s): 3, 2 != N Tit(s) For M
      Tat(s): 3, 2
drvinceknight added a commit that referenced this pull request Jul 29, 2017
We were only playing against Random, @marcharper found and fixed a bug via
hypothesis on it here:
#1097

This catches the bug too:

Axelrod(pass-match-attributes) ✗: python -m unittest
axelrod.tests.strategies.test_titfortat
...............................................................................F................................................................
======================================================================
FAIL: test_reset_history_and_attributes
(axelrod.tests.strategies.test_titfortat.TestNTitsForMTats)
Make sure resetting works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/home/vince/src/Axelrod/axelrod/tests/strategies/test_player.py",
  line 411, in test_reset_history_and_attributes
      self.assertEqual(player, clone)
      AssertionError: N Tit(s) For M Tat(s): 3, 2 != N Tit(s) For M
      Tat(s): 3, 2
@drvinceknight
Copy link
Member

Assuming appveyor is happy. 👍

@meatballs meatballs merged commit 715f67c into master Jul 29, 2017
@meatballs meatballs deleted the new_zd branch July 29, 2017 19:50
drvinceknight added a commit that referenced this pull request Jul 29, 2017
We were only playing against Random, @marcharper found and fixed a bug via
hypothesis on it here:
#1097

This catches the bug too:

Axelrod(pass-match-attributes) ✗: python -m unittest
axelrod.tests.strategies.test_titfortat
...............................................................................F................................................................
======================================================================
FAIL: test_reset_history_and_attributes
(axelrod.tests.strategies.test_titfortat.TestNTitsForMTats)
Make sure resetting works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/home/vince/src/Axelrod/axelrod/tests/strategies/test_player.py",
  line 411, in test_reset_history_and_attributes
      self.assertEqual(player, clone)
      AssertionError: N Tit(s) For M Tat(s): 3, 2 != N Tit(s) For M
      Tat(s): 3, 2
marcharper pushed a commit that referenced this pull request Jul 30, 2017
We were only playing against Random, @marcharper found and fixed a bug via
hypothesis on it here:
#1097

This catches the bug too:

Axelrod(pass-match-attributes) ✗: python -m unittest
axelrod.tests.strategies.test_titfortat
...............................................................................F................................................................
======================================================================
FAIL: test_reset_history_and_attributes
(axelrod.tests.strategies.test_titfortat.TestNTitsForMTats)
Make sure resetting works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File
  "/home/vince/src/Axelrod/axelrod/tests/strategies/test_player.py",
  line 411, in test_reset_history_and_attributes
      self.assertEqual(player, clone)
      AssertionError: N Tit(s) For M Tat(s): 3, 2 != N Tit(s) For M
      Tat(s): 3, 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants