Major overhaul of "randomness" throughout.

- Nobody does `import random` anymore.

- Random numbers are gotten from `ctx.random`, which is an object
of type `Randomness` with all the convenience methods that used to
be obnoxious functions in the `formulas` module.

- Every place that was using `random.random()` to implement the
equivalent of Python3 `random.choices(seq, weights)` has been updated
to use `ctx.random.weighted_choice(seq, weights)`.

This has a functional effect, since the details of random number
generation have changed. The *statistical* effect should be small.
I do observe that Copycat is having trouble inventing the "mrrjjjj"
solution right now (even in 1000 test runs), so maybe something is
slightly broken.
This commit is contained in:
Arthur O'Dwyer
2017-04-17 22:18:37 -07:00
parent 8fdb9d06e6
commit 3732ae8475
11 changed files with 179 additions and 214 deletions

View File

@ -32,7 +32,7 @@ class Slipnet(object):
for node in self.initiallyClampedSlipnodes:
node.clampHigh()
def update(self):
def update(self, random):
logging.debug('slipnet.update()')
self.numberOfUpdates += 1
if self.numberOfUpdates == 50:
@ -44,7 +44,7 @@ class Slipnet(object):
node.spread_activation()
for node in self.slipnodes:
node.addBuffer()
node.jump()
node.jump(random)
node.buffer = 0.0
def isDistinguishingDescriptor(self, descriptor):