This commit is contained in:
LSaldyt
2017-10-18 10:29:03 -07:00
parent dd0e7d8f37
commit ebee40323c
4 changed files with 1209 additions and 176423 deletions

177593
copycat.log

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,6 @@ def codelet(name):
return f return f
return wrap return wrap
# some methods common to the codelets # some methods common to the codelets
def __showWhichStringObjectIsFrom(structure): def __showWhichStringObjectIsFrom(structure):
if not structure: if not structure:

View File

@ -52,11 +52,7 @@ class Copycat(object):
self.reporter.report_workspace(self.workspace) self.reporter.report_workspace(self.workspace)
if self.showgui: if self.showgui:
self.gui.update( self.gui.update(self)
self.temperature.value(),
self.slipnet.slipnodes,
self.coderack.codelets
)
return lastUpdate return lastUpdate
def runTrial(self): def runTrial(self):

View File

@ -13,7 +13,7 @@ font2Size = 16
font1 = ('Helvetica', str(font1Size)) font1 = ('Helvetica', str(font1Size))
font2 = ('Helvetica', str(font2Size)) font2 = ('Helvetica', str(font2Size))
style = dict(background='#70747a', style = dict(background='black',
foreground='white', foreground='white',
borderwidth=5, borderwidth=5,
relief=tk.GROOVE, relief=tk.GROOVE,
@ -61,7 +61,7 @@ class MainApplication(ttk.Frame):
self.rowconfigure(0) self.rowconfigure(0)
def create_widgets(self): def create_widgets(self):
self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', '') self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', '?')
self.canvas.grid(column=0, row=0, sticky=tk.N+tk.S+tk.E+tk.W) self.canvas.grid(column=0, row=0, sticky=tk.N+tk.S+tk.E+tk.W)
tempLabel = ttk.Label(self, text='', **style, padding=30) tempLabel = ttk.Label(self, text='', **style, padding=30)
@ -76,11 +76,17 @@ class MainApplication(ttk.Frame):
codeletList.grid(column=3, row=0, sticky=tk.N+tk.S+tk.E+tk.W) codeletList.grid(column=3, row=0, sticky=tk.N+tk.S+tk.E+tk.W)
self.widgets['codeletlist'] = codeletList self.widgets['codeletlist'] = codeletList
def update(self, temp, slipnodes, codelets): def update(self, copycat):
temp = copycat.temperature.value()
slipnodes = copycat.slipnet.slipnodes
codelets = copycat.coderack.codelets
answer = '' if copycat.workspace.rule is None else copycat.workspace.rule.buildTranslatedRule()
slipList = self.widgets['sliplist'] slipList = self.widgets['sliplist']
slipList.delete(0, slipList.size()) slipList.delete(0, slipList.size())
self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', '') self.canvas = create_main_canvas(self, 'abc', 'abd', 'ijk', answer)
self.canvas.grid(column=0, row=0, sticky=tk.N+tk.S+tk.E+tk.W)
self.widgets['temp']['text'] = 'Temp:\n{}'.format(round(temp, 2)) self.widgets['temp']['text'] = 'Temp:\n{}'.format(round(temp, 2))
slipnodes = sorted(slipnodes, key=lambda s:s.activation, reverse=True) slipnodes = sorted(slipnodes, key=lambda s:s.activation, reverse=True)
for item in slipnodes: for item in slipnodes:
@ -94,21 +100,31 @@ class MainApplication(ttk.Frame):
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)
descriptionsFrame = tk.Frame(self)
for i, obj in enumerate(sorted(copycat.workspace.objects, key=lambda o:o.string.string)):
l = tk.Label(descriptionsFrame, text=obj.string.string)
l.grid(column=i, row=0)
for j, description in enumerate(obj.descriptions):
l = tk.Label(descriptionsFrame, text='[]')
l.grid(column=i, row=j+1)
descriptionsFrame.grid(row=1)
class GUI(object): class GUI(object):
def __init__(self, title, updateInterval=.5): def __init__(self, title, updateInterval=.1):
self.root = tk.Tk() self.root = tk.Tk()
self.root.title(title) self.root.title(title)
#self.root.geometry('1200x800') #self.root.geometry('1200x800')
self.app = MainApplication(self.root) self.app = MainApplication(self.root)
self.app.pack(side='top', fill='both', expand=True) self.app.pack(fill=tk.Y)
self.lastUpdated = time.time() self.lastUpdated = time.time()
self.updateInterval = updateInterval self.updateInterval = updateInterval
def update(self, temp, slipnodes, codelets): def update(self, copycat):
self.root.update_idletasks() self.root.update_idletasks()
self.root.update() self.root.update()
current = time.time() current = time.time()
if current - self.lastUpdated > self.updateInterval: if current - self.lastUpdated > self.updateInterval:
self.app.update(temp, slipnodes, codelets) self.app.update(copycat)
self.lastUpdated = current self.lastUpdated = current