Commit Graph

124 Commits

Author SHA1 Message Date
c90dbd91e7 WIP 2017-09-28 15:44:41 -06:00
6d42f2c1a4 Changes default window size to 1200x800 2017-09-28 15:37:09 -06:00
33e2eb980d Fixes slipnode display 2017-09-28 15:35:15 -06:00
70494daf2c WIP gui changes 2017-09-28 10:53:37 -06:00
ae24034288 WIP add gui elements 2017-09-27 12:30:42 -06:00
9a2a30ea4c Adds very simple gui to copycat 2017-09-27 11:38:32 -06:00
4348554fa7 Add simple matplotlib bar plots per run 2017-09-26 21:16:20 -06:00
bc848e8f2d Ports to Python3 2017-07-31 17:08:26 -06:00
318d0e2349 Fix a lot of crashes with empty or single-letter inputs. 2017-05-03 02:01:57 -07:00
2a48245c15 Add "frames per second" to the CursesReporter.
You can now set the FPS goal with `--fps=10` (or whatever) on the command line;
and the current (measured) FPS is displayed in the lower right corner.

During the run, you can bump the FPS goal up and down with `F` and `f` respectively!
2017-05-02 18:37:40 -07:00
0eec6a5259 Massively improve CursesReporter.
The Slipnet itself turns out to be boring to look at.
More interest is found in the Workspace structures, such as bonds,
groups, and correspondences.

The old behavior of `curses_main.py` is still accessible via

    python curses_main.py abc abd xyz --focus-on-slipnet
2017-05-02 18:01:46 -07:00
ef4a9c56c5 Try to fix up breakGroup.
With the new CursesReporter, I'm able to observe groups getting built
and broken; and I observed that sometimes a Bond (between a Letter and
a Group) would apparently survive the Group's breaking.
Reorder the operations in `breakGroup` so that the higher-level ones
("detach this Group from its external bonds") come strictly before
the lower-level ones ("ungroup this Group's members and remove this
Group from the Workspace, thus destroying it").

However, the "buggy" behavior I observed turned out to be due to a bug
in my display code and not due to anything wrong with `breakGroup`.
I suspect this patch is actually purely cosmetic.
2017-05-02 17:46:25 -07:00
730239f464 Rip out dead Bond.destinationIsOnRight and Bond.bidirectional. NFC. 2017-05-02 12:37:15 -07:00
5793fb887c Rip out dead method morePossibleDescriptions. NFC.
This code is already present in `getPossibleDescriptions`... which is
also a terrible function from the philosophical point of view, because
it secretly encodes knowledge about every predicate known to the system.
2017-05-02 11:33:43 -07:00
864c28609c Smartness update! A single letter is both "leftmost" and "rightmost".
Before this change, Copycat was unable to formulate more than the empty rule for
    abc : abd :: f : f
    abc : dbc :: f : f
    abc : aac :: f : f
After this change, Copycat strongly prefers
    abc : abd :: f : g  ("Replace the rightmost letter with its successor")
    abc : dbc :: f : d  ("Replace the leftmost letter with d")
    abc : aac :: f : e  ("Replace the middle letter with its predecessor")
2017-05-02 11:17:23 -07:00
ecc2c2e407 Add report_workspace() to Reporter, and remove dead rules from the workspace.
I think the change to `workspace.breakRule()` is harmless. In theory, it
should make Copycat less hesitant to come up with rules that conflict with
the already-broken rule.
2017-05-01 15:28:38 -07:00
25d73785de Further Pythonicity. NFC. 2017-05-01 13:07:19 -07:00
ceaf640147 Remove some more logging cruft. NFC. 2017-04-30 15:26:19 -07:00
c4e30f7399 Make possibleGroupBonds into a member function of Bond. NFC. 2017-04-30 15:18:19 -07:00
7947e955d7 More Pythonicisms. NFC. 2017-04-30 14:45:20 -07:00
ddfb34973d Rip out unused coderack.postings and coderack.runCodelets. NFC. 2017-04-30 10:38:42 -07:00
f9fc255151 Refactor coderack.probabilityOfPosting. NFC. 2017-04-30 10:27:55 -07:00
48c45e4b0a Fix more flake8 cruft; remove a bunch of logging. 2017-04-29 15:55:54 -07:00
c9bc26e03d Minor Pythonicisms. NFC. 2017-04-29 14:29:43 -07:00
11e9571ee0 Oops, add Reporter to the list of exported names. 2017-04-23 01:36:40 -07:00
34157be1f9 Shorten the setup.py for the copycat module. NFC. 2017-04-22 22:46:22 -07:00
9a2a1d6010 Add the Slipnet to the curses reporter.
This isn't terribly useful to the human observer, actually.
It seems like the most useful factors that ought to be displayed
are really the groups/bonds in the workspace and the current
"rule" (if any). Particularly, with the current design of Copycat,
it seems like the "rule" should be part of the displayed output
just the same as the modified target string.
2017-04-22 19:00:57 -07:00
16aae98c59 Fix a bunch of flake8 spam. NFC. 2017-04-22 18:41:48 -07:00
ec2c172ce0 Rip out some unused members of Slipnode. NFC. 2017-04-22 18:37:55 -07:00
b5b04c77a1 Remove a redundant "opposite" link from the slipnet.
This does change the micro behavior of Copycat. I would hope it doesn't
change the macro behavior, or at least changes it for the better.
2017-04-22 17:59:32 -07:00
e3e6b051d3 Whitespace. NFC. 2017-04-22 17:56:46 -07:00
3de933dbfa Redo all the argument parsing with argparse. 2017-04-22 17:53:06 -07:00
192ec2f106 Clean up some overly Java-ish base class stuff. NFC. 2017-04-18 23:44:38 -07:00
f2ffac4e66 Add a curses front-end. This is looking good now!
And clean up some logic in `rule.py`. This is the place where the
"brains" of Copycat really live, it seems; Copycat can only succeed
at solving a puzzle if it can take the `Rule` it deduced and apply
it to the target string to produce a new string. And it can only
do that if the necessary *actions* have been programmed into `rule.py`.
Right now, it explicitly can't deal with "rules" that involve more
than one local change; that involve reversal; or more importantly,
IIUC, rules that involve "ascending runs", because the idea of a
successor-group is(?) known to the Slipnet but not to `rule.py`;
the latter deals only in "strings", not in "workspace objects".
This seems like a major flaw in the system... but maybe I'm missing
something.
2017-04-18 23:18:26 -07:00
9f8bc8e66e Remove all print statements from the Copycat library.
Convert the most important one to logging; kill the rest.
2017-04-18 20:55:56 -07:00
65124fa45d Add a "setup.py" for pip-installing from GitHub.
You can now install Copycat into your Python virtualenv without even
checking out this repository! Just run this command:

    pip install -e git+git://github.com/Quuxplusone/co.py.cat.git#egg=copycat

To check out a specific branch,

    pip install -e git+git://github.com/Quuxplusone/co.py.cat.git@branch#egg=copycat
2017-04-18 18:22:32 -07:00
a3b977846e git mv context.py -> copycat.py; and start work on a "reporter" API.
The goal here is to use `curses` to display the coderack, slipnet,
and temperature in real time. A further goal would be a reporter
that sent the data over websockets to a browser, at which point
I could throw this thing up on Heroku and let people mess with it.
(Not that that would be very entertaining, yet.)
2017-04-18 01:59:51 -07:00
189bce2aa2 Remove one not-very-useful logging line. NFC. 2017-04-18 01:31:39 -07:00
db7dc21f83 Fix a crash on main.py aa b zz.
The "leftmost object" in the string `b` does span the whole string,
but it's not a `Group`, so the old code would crash when it got
to the evaluation of `group.objectList` (since `Letter`s don't have
`objectList`s).
2017-04-18 01:12:27 -07:00
fd74290d39 Clean up the handling of codelet arguments. NFC.
Just make all argument-passing explicit; which means the coderack
no longer cares about `oldCodelet` (which was being used only to
get the implicit arguments to the new codelet).
2017-04-18 01:12:27 -07:00
f08c57fac3 Fix some flake8 spam. NFC. 2017-04-18 01:12:27 -07:00
7388eaec54 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)`!
2017-04-18 01:12:27 -07:00
12283b0836 Move some harmless imports to file scope. NFC. 2017-04-18 01:12:27 -07:00
30f8c623e5 Demagic workspaceFormulas.py. NFC. 2017-04-18 01:12:26 -07:00
3732ae8475 Major overhaul of "randomness" throughout.
- Nobody does `import random` anymore.

- Random numbers are gotten from `ctx.random`, which is an object
of type `Randomness` with all the convenience methods that used to
be obnoxious functions in the `formulas` module.

- Every place that was using `random.random()` to implement the
equivalent of Python3 `random.choices(seq, weights)` has been updated
to use `ctx.random.weighted_choice(seq, weights)`.

This has a functional effect, since the details of random number
generation have changed. The *statistical* effect should be small.
I do observe that Copycat is having trouble inventing the "mrrjjjj"
solution right now (even in 1000 test runs), so maybe something is
slightly broken.
2017-04-18 01:12:26 -07:00
8fdb9d06e6 Demagic everything in formulas.py. NFC.
Only one file left to go!
2017-04-18 01:12:26 -07:00
6165f77d3c Move a couple single-use helpers from formulas to codeletMethods. NFC. 2017-04-18 01:12:26 -07:00
ff389bd653 Move temperatureAdjustedFoo into the Temperature class. NFC.
And demagic all the callers of this function. Notice that with this
move, it becomes *harder* for these "getAdjustedFoo" functions to
access other contextual state, such as the state of the coderack
and the state of the workspace. This is a good thing for modularity
but possibly a misfeature in terms of flexibility-re-logic-changes.
2017-04-18 01:12:26 -07:00
99dc05f829 Demagic everything except the formulas and workspaceFormulas. NFC. 2017-04-18 01:12:26 -07:00
7581a328f7 Give WorkspaceString a self.ctx. Demagic all WorkspaceObjects. NFC. 2017-04-18 01:12:26 -07:00