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