Minor Pythonicisms. NFC.
This commit is contained in:
@ -196,9 +196,8 @@ class Coderack(object):
|
||||
rule = Rule(self.ctx, facet, description, category, relation)
|
||||
rule.updateStrength()
|
||||
if description and relation:
|
||||
depths = description.conceptualDepth + relation.conceptualDepth
|
||||
depths /= 200.0
|
||||
urgency = math.sqrt(depths) * 100.0
|
||||
averageDepth = (description.conceptualDepth + relation.conceptualDepth) / 2.0
|
||||
urgency = 100.0 * math.sqrt(averageDepth / 100.0)
|
||||
else:
|
||||
urgency = 0
|
||||
self.newCodelet('rule-strength-tester', urgency, [rule])
|
||||
|
||||
@ -72,11 +72,6 @@ class Slipnode(object):
|
||||
linkLength = self.shrunkLinkLength
|
||||
return 100.0 - linkLength
|
||||
|
||||
def update(self):
|
||||
act = self.activation
|
||||
self.oldActivation = act
|
||||
self.buffer -= self.activation * (100.0 - self.conceptualDepth) / 100.0
|
||||
|
||||
def linked(self, other):
|
||||
"""Whether the other is among the outgoing links"""
|
||||
return any(l.points_at(other) for l in self.outgoingLinks)
|
||||
@ -129,6 +124,10 @@ class Slipnode(object):
|
||||
logging.info('Got no bond')
|
||||
return result
|
||||
|
||||
def update(self):
|
||||
self.oldActivation = self.activation
|
||||
self.buffer -= self.activation * (100.0 - self.conceptualDepth) / 100.0
|
||||
|
||||
def spread_activation(self):
|
||||
if self.fully_active():
|
||||
for link in self.outgoingLinks:
|
||||
@ -140,9 +139,7 @@ class Slipnode(object):
|
||||
self.activation = min(max(0, self.activation), 100)
|
||||
|
||||
def jump(self, random):
|
||||
if self.activation <= jump_threshold():
|
||||
return
|
||||
if self.clamped:
|
||||
if self.clamped or self.activation <= jump_threshold():
|
||||
return
|
||||
value = (self.activation / 100.0) ** 3
|
||||
if random.coinFlip(value):
|
||||
|
||||
@ -14,21 +14,16 @@ class WorkspaceString(object):
|
||||
self.letters = []
|
||||
self.length = len(s)
|
||||
self.intraStringUnhappiness = 0.0
|
||||
if not self.length:
|
||||
return
|
||||
position = 0
|
||||
|
||||
for c in self.string.upper():
|
||||
for position, c in enumerate(self.string.upper(), 1):
|
||||
value = ord(c) - ord('A')
|
||||
letter = Letter(self, position + 1, self.length)
|
||||
letter = Letter(self, position, self.length)
|
||||
letter.workspaceString = self
|
||||
letter.addDescription(slipnet.objectCategory, slipnet.letter)
|
||||
letter.addDescription(slipnet.letterCategory,
|
||||
slipnet.letters[value])
|
||||
letter.describe(position + 1, self.length)
|
||||
letter.addDescription(slipnet.letterCategory, slipnet.letters[value])
|
||||
letter.describe(position, self.length)
|
||||
workspace.buildDescriptions(letter)
|
||||
self.letters += [letter]
|
||||
position += 1
|
||||
|
||||
def __repr__(self):
|
||||
return '<WorkspaceString: %s>' % self.string
|
||||
|
||||
Reference in New Issue
Block a user