Fixes some displays
This commit is contained in:
@ -53,6 +53,18 @@ class Copycat(object):
|
|||||||
self.lastUpdate = currentTime
|
self.lastUpdate = currentTime
|
||||||
self.reporter.report_slipnet(self.slipnet)
|
self.reporter.report_slipnet(self.slipnet)
|
||||||
|
|
||||||
|
def check_reset(self):
|
||||||
|
if self.gui.app.primary.control.go:
|
||||||
|
initial, modified, target = self.gui.app.primary.control.get_vars()
|
||||||
|
self.reset_with_strings(initial, modified, target)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def reset_with_strings(self, initial, modified, target):
|
||||||
|
self.workspace.resetWithStrings(initial, modified, target)
|
||||||
|
self.gui.app.reset_with_strings(initial, modified, target)
|
||||||
|
|
||||||
def mainLoop(self):
|
def mainLoop(self):
|
||||||
currentTime = self.coderack.codeletsRun
|
currentTime = self.coderack.codeletsRun
|
||||||
self.temperature.tryUnclamp(currentTime)
|
self.temperature.tryUnclamp(currentTime)
|
||||||
@ -64,7 +76,6 @@ class Copycat(object):
|
|||||||
if self.showgui:
|
if self.showgui:
|
||||||
self.gui.refresh()
|
self.gui.refresh()
|
||||||
|
|
||||||
|
|
||||||
def runTrial(self):
|
def runTrial(self):
|
||||||
"""Run a trial of the copycat algorithm"""
|
"""Run a trial of the copycat algorithm"""
|
||||||
self.coderack.reset()
|
self.coderack.reset()
|
||||||
@ -82,12 +93,10 @@ class Copycat(object):
|
|||||||
return answer
|
return answer
|
||||||
|
|
||||||
def run(self, initial, modified, target, iterations):
|
def run(self, initial, modified, target, iterations):
|
||||||
self.workspace.resetWithStrings(initial, modified, target)
|
self.reset_with_strings(initial, modified, target)
|
||||||
answers = {}
|
answers = {}
|
||||||
for i in range(iterations):
|
for i in range(iterations):
|
||||||
if self.gui.app.primary.control.go:
|
if self.check_reset():
|
||||||
initial, modified, target = self.gui.app.primary.control.get_vars()
|
|
||||||
self.workspace.resetWithStrings(initial, modified, target)
|
|
||||||
answers = {}
|
answers = {}
|
||||||
|
|
||||||
answer = self.runTrial()
|
answer = self.runTrial()
|
||||||
@ -108,6 +117,7 @@ class Copycat(object):
|
|||||||
return answers
|
return answers
|
||||||
|
|
||||||
def run_forever(self, initial, modified, target):
|
def run_forever(self, initial, modified, target):
|
||||||
self.workspace.resetWithStrings(initial, modified, target)
|
self.reset_with_strings(initial, modified, target)
|
||||||
while True:
|
while True:
|
||||||
|
self.check_reset()
|
||||||
self.runTrial()
|
self.runTrial()
|
||||||
|
|||||||
@ -80,6 +80,9 @@ class MainApplication(GridFrame):
|
|||||||
listStr = '{}: {}'.format(codelet.name, round(codelet.urgency, 2))
|
listStr = '{}: {}'.format(codelet.name, round(codelet.urgency, 2))
|
||||||
codeletList.insert(tk.END, listStr)
|
codeletList.insert(tk.END, listStr)
|
||||||
|
|
||||||
|
def reset_with_strings(self, initial, modified, target):
|
||||||
|
self.primary.reset_with_strings(initial, modified, target)
|
||||||
|
|
||||||
class GUI(object):
|
class GUI(object):
|
||||||
def __init__(self, title, updateInterval=.1):
|
def __init__(self, title, updateInterval=.1):
|
||||||
self.root = tk.Tk()
|
self.root = tk.Tk()
|
||||||
|
|||||||
@ -51,13 +51,21 @@ class Primary(GridFrame):
|
|||||||
def __init__(self, parent, *args, **kwargs):
|
def __init__(self, parent, *args, **kwargs):
|
||||||
GridFrame.__init__(self, parent, *args, **kwargs)
|
GridFrame.__init__(self, parent, *args, **kwargs)
|
||||||
|
|
||||||
self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', '?')
|
self.initial = ''
|
||||||
self.add(self.canvas, 0, 0, xspan=2)
|
self.modified = ''
|
||||||
|
self.target = ''
|
||||||
|
|
||||||
|
self.canvas = create_main_canvas(self, self.initial, self.modified, self.target, '')
|
||||||
|
self.add(self.canvas, 0, 0, xspan=2)
|
||||||
self.control = Control(self)
|
self.control = Control(self)
|
||||||
self.add(self.control, 0, 2)
|
self.add(self.control, 0, 2)
|
||||||
|
|
||||||
def update(self, copycat):
|
def update(self, copycat):
|
||||||
answer = '' if copycat.workspace.rule is None else copycat.workspace.rule.buildTranslatedRule()
|
answer = '' if copycat.workspace.rule is None else copycat.workspace.rule.buildTranslatedRule()
|
||||||
self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', answer)
|
self.canvas = create_main_canvas(self, self.initial, self.modified, self.target, answer)
|
||||||
self.add(self.canvas, 0, 0, xspan=2)
|
self.add(self.canvas, 0, 0, xspan=2)
|
||||||
|
|
||||||
|
def reset_with_strings(self, initial, modified, target):
|
||||||
|
self.initial = initial
|
||||||
|
self.modified = modified
|
||||||
|
self.target = target
|
||||||
|
|||||||
Reference in New Issue
Block a user