diff --git a/README.md b/README.md index e776dfb..0fe9ab9 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,6 @@ co.py.cat ![GUI](https://i.imgur.com/7pb20g0.png) -Linhares and I are planning to use this codebase to implement a variation of Copycat that uses *Entropy* instead of *Temperature*, while still preserving the parallel terraced scan in full form. If the change is viable, I plan to write a paper on that (if anyone is interested in co-authoring, let me know). For the general idea, please see pages 41 and 42 of the [*Information Sciences*](https://github.com/Alex-Linhares/FARGlexandria/blob/master/Literature/Chess-Capyblanca-2014-Linhares-Information%20Sciences.pdf) paper on [Capyblanca](https://github.com/Alex-Linhares/FARGlexandria). - -**If you would like to help research and publish a paper, please let me know.** - -Please see also [FARGlexandria](https://github.com/Alex-Linhares/FARGlexandria), a repository with all FARG projects (and help if you have some of the missing info there, especially about Letter Spirit and George!) - -------------------------------- An implementation of [Douglas Hofstadter](http://prelectur.stanford.edu/lecturers/hofstadter/)'s Copycat algorithm. The Copycat algorithm is explained [on Wikipedia](https://en.wikipedia.org/wiki/Copycat_%28software%29), and that page has many links for deeper reading. See also [Farglexandria](https://github.com/Alex-Linhares/Farglexandria). diff --git a/copycat/copycat.py b/copycat/copycat.py index f7dbceb..96e36be 100644 --- a/copycat/copycat.py +++ b/copycat/copycat.py @@ -63,8 +63,8 @@ class Copycat(object): def mainLoop(self): currentTime = self.coderack.codeletsRun self.temperature.tryUnclamp(currentTime) - # Every 15 codelets, we update the workspace. - if currentTime >= self.lastUpdate + 15: + # Every 5 codelets, we update the workspace. + if currentTime >= self.lastUpdate + 5: self.update_workspace(currentTime) self.step() diff --git a/copycat/gui/gui.py b/copycat/gui/gui.py index 2cd42cc..7c603df 100644 --- a/copycat/gui/gui.py +++ b/copycat/gui/gui.py @@ -16,7 +16,7 @@ from .primary import Primary from .list import List from .style import configure_style -from .plot import plot_imbedded +from .plot import plot_answers, plot_temp plt.style.use('dark_background') @@ -40,10 +40,13 @@ class MainApplication(GridFrame): self.add(self.codeletList, 1, 1) self.objectList = List(self, columns) - self.add(self.objectList, 2, 1) + self.add(self.objectList, 2, 1, xspan=2) + + self.graph1 = Plot(self, 'Temperature history') + self.add(self.graph1, 2, 0) self.graph2 = Plot(self, 'Answer Distribution') - self.add(self.graph2, 2, 0) + self.add(self.graph2, 3, 0) def update(self, copycat): self.primary.update(copycat) @@ -57,6 +60,11 @@ class MainApplication(GridFrame): self.codeletList.update(codelets, key=lambda c:c.urgency, formatter= lambda s : '{}: {}'.format(s.name, round(s.urgency, 2))) get_descriptors = lambda s : ', '.join('({}={})'.format(d.descriptionType.name, d.descriptor.name) for d in s.descriptions) self.objectList.update(objects, formatter=lambda s : '{}: {}'.format(s, get_descriptors(s))) + + def modifier(status): + with plt.style.context(('dark_background')): + plot_temp(copycat.temperature, status) + self.graph1.status.modifier = modifier def reset_with_strings(self, initial, modified, target): self.primary.reset_with_strings(initial, modified, target) @@ -69,15 +77,12 @@ class GUI(object): tk.Grid.columnconfigure(self.root, 0, weight=1) self.app = MainApplication(self.root) self.app.grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W) - configure_style(ttk.Style()) def add_answers(self, answers): def modifier(status): - print('Here') - print(answers) with plt.style.context(('dark_background')): - plot_imbedded(answers, status) + plot_answers(answers, status) self.app.graph2.status.modifier = modifier def refresh(self): diff --git a/copycat/gui/plot.py b/copycat/gui/plot.py index 8583ff7..54d900b 100644 --- a/copycat/gui/plot.py +++ b/copycat/gui/plot.py @@ -2,7 +2,14 @@ import matplotlib.pyplot as plt; plt.rcdefaults() import numpy as np import matplotlib.pyplot as plt -def plot_imbedded(answers, status): +def plot_temp(temperature, status): + status.subplot.clear() + status.subplot.plot(temperature.history) + status.subplot.set_ylabel('Temperature') + status.subplot.set_xlabel('Time') + status.subplot.set_title('Temperature History') + +def plot_answers(answers, status): answers = sorted(answers.items(), key=lambda kv : kv[1]['count']) objects = [t[0] for t in answers] yvalues = [t[1]['count'] for t in answers] diff --git a/copycat/gui/workspacecanvas.py b/copycat/gui/workspacecanvas.py index 843e0b0..62ccb90 100644 --- a/copycat/gui/workspacecanvas.py +++ b/copycat/gui/workspacecanvas.py @@ -21,6 +21,7 @@ class WorkspaceCanvas(GridFrame): self.changed = False self.canvas = tk.Canvas(self, background='black') + #self.canvas['width'] = 1600 self.add(self.canvas, 0, 0) GridFrame.configure(self) diff --git a/copycat/temperature.py b/copycat/temperature.py index 83a7029..9941e70 100644 --- a/copycat/temperature.py +++ b/copycat/temperature.py @@ -123,6 +123,7 @@ class Temperature(object): self.ndiffs = 0 def reset(self): + self.history = [100.0] self.actual_value = 100.0 self.last_unclamped_value = 100.0 self.clamped = True @@ -133,6 +134,7 @@ class Temperature(object): if self.clamped: self.actual_value = 100.0 else: + self.history.append(value) self.actual_value = value def clampUntil(self, when):