From 74441a1746dc81bd7f0b8eaab698a48c66605886 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 23 May 2019 17:26:27 +0300 Subject: [PATCH] Convert functionality to pysol-cards mod. --- .appveyor.yml | 1 + .travis.yml | 2 +- pysollib/pysolrandom.py | 22 +++------------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6ceeb22ebc..c7824d8b2b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,6 +14,7 @@ install: - python3 -mpip install py2exe - python3 -mpip install pycotap - python3 -mpip install pygame + - python3 -mpip install pysol-cards - python3 -mpip install random2 - python3 -mpip install six - perl -v diff --git a/.travis.yml b/.travis.yml index b46e5b5620..acfb94a647 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_install: install: - sudo cpanm --notest Capture::Tiny - sudo cpanm Code::TidyAll::Plugin::Flake8 Perl::Tidy Test::Code::TidyAll Test::Differences Test::TrailingSpace - - export PY_MODS='pycotap random2 six' + - export PY_MODS='pycotap pysol-cards random2 six' - "`which python3` -m pip install --upgrade flake8 flake8-import-order $PY_MODS" - "sudo /usr/bin/python3 -m pip install --upgrade $PY_MODS || true" - "sudo `which python2` -m pip install --upgrade $PY_MODS" diff --git a/pysollib/pysolrandom.py b/pysollib/pysolrandom.py index 319094f284..747fc66ef2 100644 --- a/pysollib/pysolrandom.py +++ b/pysollib/pysolrandom.py @@ -34,6 +34,8 @@ "You need to install " + "https://pypi.python.org/pypi/random2 using pip or similar.") +from pysol_cards.random import RandomBase # noqa: I100 + # ************************************************************************ # * Abstract class for PySol Random number generator. @@ -42,7 +44,7 @@ # ************************************************************************ -class BasicRandom: +class BasicRandom(RandomBase): # MAX_SEED = 0L # MAX_SEED = 0xffffffffffffffffL # 64 bits MAX_SEED = int('100000000000000000000') # 20 digits @@ -172,20 +174,9 @@ def setstate(self, state): def choice(self, seq): return seq[int(self.random() * len(seq))] - # Get a random integer in the range [a, b] including both end points. - def randint(self, a, b): - return a + int(self.random() * (b+1-a)) - def randrange(self, a, b): return self.randint(a, b-1) - def shuffle(self, seq): - n = len(seq) - 1 - while n > 0: - j = self.randint(0, n) - seq[n], seq[j] = seq[j], seq[n] - n -= 1 - # ************************************************************************ # * Linear Congruential random generator @@ -266,13 +257,6 @@ def randint(self, a, b): return a + (ret % (b+1-a)) - def shuffle(self, seq): - n = len(seq) - 1 - while n > 0: - j = self.randint(0, n) - seq[n], seq[j] = seq[j], seq[n] - n -= 1 - def reset(self): self.setSeed(self.seed)