Teach Context to be self-sufficient. NFC.

You can now create and run a Copycat instance by just saying
`Context().run('abc', 'abd', 'efg', 100)`!
This commit is contained in:
Arthur O'Dwyer
2017-04-17 23:17:47 -07:00
parent 12283b0836
commit 7388eaec54
5 changed files with 18 additions and 37 deletions

View File

@ -16,10 +16,7 @@ def __adjustUnhappiness(values):
class Workspace(object):
def __init__(self, ctx):
#logging.debug('workspace.__init__()')
self.ctx = ctx
self.setStrings('', '', '')
self.reset()
self.totalUnhappiness = 0.0
self.intraStringUnhappiness = 0.0
self.interStringUnhappiness = 0.0
@ -28,13 +25,13 @@ class Workspace(object):
return '<Workspace trying %s:%s::%s:?>' % (
self.initialString, self.modifiedString, self.targetString)
def setStrings(self, initial, modified, target):
def resetWithStrings(self, initial, modified, target):
self.targetString = target
self.initialString = initial
self.modifiedString = modified
self.reset()
def reset(self):
#logging.debug('workspace.reset()')
self.foundAnswer = False
self.changedObject = None
self.objects = []