Skip to content

Commit

Permalink
Convert functionality to pysol-cards mod.
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed May 23, 2019
1 parent 4853b2d commit 74441a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 3 additions & 19 deletions pysollib/pysolrandom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -42,7 +44,7 @@
# ************************************************************************


class BasicRandom:
class BasicRandom(RandomBase):
# MAX_SEED = 0L
# MAX_SEED = 0xffffffffffffffffL # 64 bits
MAX_SEED = int('100000000000000000000') # 20 digits
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 74441a1

Please sign in to comment.