Found entry points for the research project
This commit is contained in:
130343
copycat.log
130343
copycat.log
File diff suppressed because it is too large
Load Diff
@ -75,8 +75,10 @@ def __structureVsStructure(structure1, weight1, structure2, weight2):
|
||||
temperature = ctx.temperature
|
||||
structure1.updateStrength()
|
||||
structure2.updateStrength()
|
||||
#TODO: use entropy
|
||||
weightedStrength1 = temperature.getAdjustedValue(
|
||||
structure1.totalStrength * weight1)
|
||||
#TODO: use entropy
|
||||
weightedStrength2 = temperature.getAdjustedValue(
|
||||
structure2.totalStrength * weight2)
|
||||
return random.weighted_greater_than(weightedStrength1, weightedStrength2)
|
||||
@ -112,6 +114,7 @@ def __slippability(ctx, conceptMappings):
|
||||
temperature = ctx.temperature
|
||||
for mapping in conceptMappings:
|
||||
slippiness = mapping.slippability() / 100.0
|
||||
#TODO: use entropy
|
||||
probabilityOfSlippage = temperature.getAdjustedProbability(slippiness)
|
||||
if random.coinFlip(probabilityOfSlippage):
|
||||
return True
|
||||
@ -123,6 +126,7 @@ def breaker(ctx, codelet):
|
||||
random = ctx.random
|
||||
temperature = ctx.temperature
|
||||
workspace = ctx.workspace
|
||||
#TODO: use entropy
|
||||
probabilityOfFizzle = (100.0 - temperature.value()) / 100.0
|
||||
if random.coinFlip(probabilityOfFizzle):
|
||||
return
|
||||
@ -139,6 +143,7 @@ def breaker(ctx, codelet):
|
||||
breakObjects += [structure.source.group]
|
||||
# Break all the objects or none of them; this matches the Java
|
||||
for structure in breakObjects:
|
||||
#TODO: use entropy
|
||||
breakProbability = temperature.getAdjustedProbability(
|
||||
structure.totalStrength / 100.0)
|
||||
if random.coinFlip(breakProbability):
|
||||
@ -161,6 +166,7 @@ def similarPropertyLinks(ctx, slip_node):
|
||||
result = []
|
||||
for slip_link in slip_node.propertyLinks:
|
||||
association = slip_link.degreeOfAssociation() / 100.0
|
||||
#TODO:use entropy
|
||||
probability = temperature.getAdjustedProbability(association)
|
||||
if random.coinFlip(probability):
|
||||
result += [slip_link]
|
||||
@ -216,6 +222,7 @@ def description_strength_tester(ctx, codelet):
|
||||
description.descriptor.buffer = 100.0
|
||||
description.updateStrength()
|
||||
strength = description.totalStrength
|
||||
#TODO: use entropy
|
||||
probability = temperature.getAdjustedProbability(strength / 100.0)
|
||||
assert random.coinFlip(probability)
|
||||
coderack.newCodelet('description-builder', strength, [description])
|
||||
@ -361,6 +368,7 @@ def rule_strength_tester(ctx, codelet):
|
||||
temperature = ctx.temperature
|
||||
rule = codelet.arguments[0]
|
||||
rule.updateStrength()
|
||||
#TODO: use entropy
|
||||
probability = temperature.getAdjustedProbability(rule.totalStrength / 100.0)
|
||||
if random.coinFlip(probability):
|
||||
coderack.newCodelet('rule-builder', rule.totalStrength, [rule])
|
||||
@ -463,6 +471,7 @@ def bond_strength_tester(ctx, codelet):
|
||||
__showWhichStringObjectIsFrom(bond)
|
||||
bond.updateStrength()
|
||||
strength = bond.totalStrength
|
||||
#Todo: use entropy
|
||||
probability = temperature.getAdjustedProbability(strength / 100.0)
|
||||
logging.info('bond strength = %d for %s', strength, bond)
|
||||
assert random.coinFlip(probability)
|
||||
@ -745,6 +754,7 @@ def group_strength_tester(ctx, codelet):
|
||||
__showWhichStringObjectIsFrom(group)
|
||||
group.updateStrength()
|
||||
strength = group.totalStrength
|
||||
#TODO: use entropy
|
||||
probability = temperature.getAdjustedProbability(strength / 100.0)
|
||||
if random.coinFlip(probability):
|
||||
# it is strong enough - post builder & activate nodes
|
||||
@ -872,6 +882,7 @@ def rule_translator(ctx, codelet):
|
||||
bondDensity = min(bondDensity, 1.0)
|
||||
weights = __getCutoffWeights(bondDensity)
|
||||
cutoff = 10.0 * random.weighted_choice(list(range(1, 11)), weights)
|
||||
#TODO: use entropy
|
||||
if cutoff >= temperature.actual_value:
|
||||
result = workspace.rule.buildTranslatedRule()
|
||||
if result is not None:
|
||||
@ -928,6 +939,7 @@ def important_object_correspondence_scout(ctx, codelet):
|
||||
coderack = ctx.coderack
|
||||
random = ctx.random
|
||||
slipnet = ctx.slipnet
|
||||
#TODO: use entropy
|
||||
temperature = ctx.temperature
|
||||
workspace = ctx.workspace
|
||||
objectFromInitial = chooseUnmodifiedObject(ctx, 'relativeImportance',
|
||||
@ -998,6 +1010,7 @@ def correspondence_strength_tester(ctx, codelet):
|
||||
objectFromTarget.flipped_version())))
|
||||
correspondence.updateStrength()
|
||||
strength = correspondence.totalStrength
|
||||
#TODO: use entropy
|
||||
probability = temperature.getAdjustedProbability(strength / 100.0)
|
||||
if random.coinFlip(probability):
|
||||
# activate some concepts
|
||||
|
||||
@ -83,6 +83,7 @@ class Coderack(object):
|
||||
if 'correspondence' in codeletName:
|
||||
return workspace.interStringUnhappiness / 100.0
|
||||
if 'description' in codeletName:
|
||||
#TODO: use entropy
|
||||
return (temperature.value() / 100.0) ** 2
|
||||
return workspace.intraStringUnhappiness / 100.0
|
||||
|
||||
@ -161,6 +162,8 @@ class Coderack(object):
|
||||
urgency = 3
|
||||
if codeletName == 'breaker':
|
||||
urgency = 1
|
||||
|
||||
#TODO: use entropy
|
||||
if temperature.value() < 25.0 and 'translator' in codeletName:
|
||||
urgency = 5
|
||||
for _ in range(howMany):
|
||||
@ -287,6 +290,8 @@ class Coderack(object):
|
||||
random = self.ctx.random
|
||||
temperature = self.ctx.temperature
|
||||
assert self.codelets
|
||||
|
||||
#TODO: use entropy
|
||||
scale = (100.0 - temperature.value() + 10.0) / 15.0
|
||||
chosen = random.weighted_choice(self.codelets, [codelet.urgency ** scale for codelet in self.codelets])
|
||||
self.removeCodelet(chosen)
|
||||
|
||||
@ -239,6 +239,7 @@ class CursesReporter(Reporter):
|
||||
w.border()
|
||||
w.refresh()
|
||||
|
||||
#TODO: use entropy
|
||||
def report_temperature(self, temperature):
|
||||
self.do_keyboard_shortcuts()
|
||||
w = self.temperatureWindow
|
||||
|
||||
@ -96,6 +96,7 @@ class Group(WorkspaceObject):
|
||||
support = self.localSupport() / 100.0
|
||||
activation = slipnet.length.activation / 100.0
|
||||
supportedActivation = (support * activation) ** exp
|
||||
#TODO: use entropy
|
||||
return temperature.getAdjustedProbability(supportedActivation)
|
||||
|
||||
def flippedVersion(self):
|
||||
@ -130,6 +131,7 @@ class Group(WorkspaceObject):
|
||||
cubedlength = length ** 3
|
||||
fred = cubedlength * (100.0 - slipnet.length.activation) / 100.0
|
||||
probability = 0.5 ** fred
|
||||
#TODO: use entropy
|
||||
value = temperature.getAdjustedProbability(probability)
|
||||
if value < 0.06:
|
||||
value = 0.0
|
||||
|
||||
@ -82,6 +82,7 @@ class Workspace(object):
|
||||
self.initial.updateIntraStringUnhappiness()
|
||||
self.target.updateIntraStringUnhappiness()
|
||||
|
||||
#TODO: use entropy
|
||||
def getUpdatedTemperature(self):
|
||||
self.calculateIntraStringUnhappiness()
|
||||
self.calculateInterStringUnhappiness()
|
||||
|
||||
Reference in New Issue
Block a user