1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Convert functionality to pysol-cards mod.

This commit is contained in:
Shlomi Fish 2019-05-23 17:26:27 +03:00
parent 4853b2dc5f
commit 74441a1746
3 changed files with 5 additions and 20 deletions

View file

@ -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

View file

@ -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"

View file

@ -34,6 +34,8 @@ except ImportError:
"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 @@ except ImportError:
# ************************************************************************
class BasicRandom:
class BasicRandom(RandomBase):
# MAX_SEED = 0L
# MAX_SEED = 0xffffffffffffffffL # 64 bits
MAX_SEED = int('100000000000000000000') # 20 digits
@ -172,20 +174,9 @@ class MFXRandom(BasicRandom):
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 @@ class LCRandom31(MFXRandom):
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)