Fixes some displays

This commit is contained in:
LSaldyt
2017-10-22 13:15:26 -07:00
parent dcf5b252c3
commit 433067a045
3 changed files with 30 additions and 9 deletions

View File

@ -53,6 +53,18 @@ class Copycat(object):
self.lastUpdate = currentTime
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):
currentTime = self.coderack.codeletsRun
self.temperature.tryUnclamp(currentTime)
@ -64,7 +76,6 @@ class Copycat(object):
if self.showgui:
self.gui.refresh()
def runTrial(self):
"""Run a trial of the copycat algorithm"""
self.coderack.reset()
@ -82,12 +93,10 @@ class Copycat(object):
return answer
def run(self, initial, modified, target, iterations):
self.workspace.resetWithStrings(initial, modified, target)
self.reset_with_strings(initial, modified, target)
answers = {}
for i in range(iterations):
if self.gui.app.primary.control.go:
initial, modified, target = self.gui.app.primary.control.get_vars()
self.workspace.resetWithStrings(initial, modified, target)
if self.check_reset():
answers = {}
answer = self.runTrial()
@ -108,6 +117,7 @@ class Copycat(object):
return answers
def run_forever(self, initial, modified, target):
self.workspace.resetWithStrings(initial, modified, target)
self.reset_with_strings(initial, modified, target)
while True:
self.check_reset()
self.runTrial()

View File

@ -80,6 +80,9 @@ class MainApplication(GridFrame):
listStr = '{}: {}'.format(codelet.name, round(codelet.urgency, 2))
codeletList.insert(tk.END, listStr)
def reset_with_strings(self, initial, modified, target):
self.primary.reset_with_strings(initial, modified, target)
class GUI(object):
def __init__(self, title, updateInterval=.1):
self.root = tk.Tk()

View File

@ -51,13 +51,21 @@ class Primary(GridFrame):
def __init__(self, parent, *args, **kwargs):
GridFrame.__init__(self, parent, *args, **kwargs)
self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', '?')
self.add(self.canvas, 0, 0, xspan=2)
self.initial = ''
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.add(self.control, 0, 2)
def update(self, copycat):
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)
def reset_with_strings(self, initial, modified, target):
self.initial = initial
self.modified = modified
self.target = target