@ -4,7 +4,7 @@ import random
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
import slipnet
|
from slipnet import slipnet
|
||||||
import temperature
|
import temperature
|
||||||
import formulas
|
import formulas
|
||||||
from workspaceFormulas import chooseDirectedNeighbor
|
from workspaceFormulas import chooseDirectedNeighbor
|
||||||
|
|||||||
@ -119,7 +119,7 @@ class CodeRack(object):
|
|||||||
|
|
||||||
def newCodelet(self, name, oldCodelet, strength, arguments=None):
|
def newCodelet(self, name, oldCodelet, strength, arguments=None):
|
||||||
#logging.debug('Posting new codelet called %s' % name)
|
#logging.debug('Posting new codelet called %s' % name)
|
||||||
urgency = self.getUrgencyBin(strength)
|
urgency = getUrgencyBin(strength)
|
||||||
newCodelet = Codelet(name, urgency, self.codeletsRun)
|
newCodelet = Codelet(name, urgency, self.codeletsRun)
|
||||||
if arguments:
|
if arguments:
|
||||||
newCodelet.arguments = [arguments]
|
newCodelet.arguments = [arguments]
|
||||||
@ -163,7 +163,7 @@ class CodeRack(object):
|
|||||||
numberOfMappings = len(mappings)
|
numberOfMappings = len(mappings)
|
||||||
if urgency:
|
if urgency:
|
||||||
urgency /= numberOfMappings
|
urgency /= numberOfMappings
|
||||||
binn = self.getUrgencyBin(urgency)
|
binn = getUrgencyBin(urgency)
|
||||||
logging.info('urgency: %s, number: %d, bin: %d',
|
logging.info('urgency: %s, number: %d, bin: %d',
|
||||||
urgency, numberOfMappings, binn)
|
urgency, numberOfMappings, binn)
|
||||||
self.newCodelet('correspondence-strength-tester',
|
self.newCodelet('correspondence-strength-tester',
|
||||||
|
|||||||
@ -47,7 +47,7 @@ def _codelet_index(codelet):
|
|||||||
i = name_indices.get(codelet.name, -1)
|
i = name_indices.get(codelet.name, -1)
|
||||||
try:
|
try:
|
||||||
return int(i)
|
return int(i)
|
||||||
except ValueError:
|
except (TypeError, ValueError):
|
||||||
try:
|
try:
|
||||||
node = codelet.arguments[0]
|
node = codelet.arguments[0]
|
||||||
return i[node]
|
return i[node]
|
||||||
|
|||||||
@ -4,6 +4,18 @@ from slipnode import Slipnode
|
|||||||
from sliplink import Sliplink
|
from sliplink import Sliplink
|
||||||
|
|
||||||
|
|
||||||
|
def distinguishingDescriptor(descriptor):
|
||||||
|
"""Whether no other object of the same type has the same descriptor"""
|
||||||
|
if descriptor == slipnet.letter:
|
||||||
|
return False
|
||||||
|
if descriptor == slipnet.group:
|
||||||
|
return False
|
||||||
|
for number in slipnet.numbers:
|
||||||
|
if number == descriptor:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class SlipNet(object):
|
class SlipNet(object):
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@ -1,28 +1,15 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from description import Description
|
from description import Description
|
||||||
from slipnet import slipnet
|
from slipnet import slipnet, distinguishingDescriptor
|
||||||
from workspaceStructure import WorkspaceStructure
|
from workspaceStructure import WorkspaceStructure
|
||||||
|
|
||||||
|
|
||||||
def distinguishingDescriptor(descriptor):
|
|
||||||
"""Whether no other object of the same type has the same descriptor"""
|
|
||||||
if descriptor == slipnet.letter:
|
|
||||||
return False
|
|
||||||
if descriptor == slipnet.group:
|
|
||||||
return False
|
|
||||||
for number in slipnet.numbers:
|
|
||||||
if number == descriptor:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class WorkspaceObject(WorkspaceStructure):
|
class WorkspaceObject(WorkspaceStructure):
|
||||||
# pylint: disable=too-many-instance-attributes
|
# pylint: disable=too-many-instance-attributes
|
||||||
def __init__(self, workspaceString):
|
def __init__(self, workspaceString):
|
||||||
WorkspaceStructure.__init__(self)
|
WorkspaceStructure.__init__(self)
|
||||||
self.string = workspaceString
|
self.string = workspaceString
|
||||||
#self.string.objects += [ self ]
|
|
||||||
self.descriptions = []
|
self.descriptions = []
|
||||||
self.extrinsicDescriptions = []
|
self.extrinsicDescriptions = []
|
||||||
self.incomingBonds = []
|
self.incomingBonds = []
|
||||||
@ -187,6 +174,10 @@ class WorkspaceObject(WorkspaceStructure):
|
|||||||
objectOnMyRightIsRightmost = True
|
objectOnMyRightIsRightmost = True
|
||||||
return objectOnMyRightIsRightmost and objectOnMyLeftIsLeftmost
|
return objectOnMyRightIsRightmost and objectOnMyLeftIsLeftmost
|
||||||
|
|
||||||
|
def distinguishingDescriptor(self, descriptor):
|
||||||
|
# pylint: disable=no-self-use
|
||||||
|
return distinguishingDescriptor(descriptor)
|
||||||
|
|
||||||
def relevantDistinguishingDescriptors(self):
|
def relevantDistinguishingDescriptors(self):
|
||||||
return [d.descriptor
|
return [d.descriptor
|
||||||
for d in self.relevantDescriptions()
|
for d in self.relevantDescriptions()
|
||||||
|
|||||||
Reference in New Issue
Block a user