Commit Graph

16 Commits

Author SHA1 Message Date
bc848e8f2d Ports to Python3 2017-07-31 17:08:26 -06:00
25d73785de Further Pythonicity. NFC. 2017-05-01 13:07:19 -07:00
48c45e4b0a Fix more flake8 cruft; remove a bunch of logging. 2017-04-29 15:55:54 -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
25ba9bfe93 (Almost) contextualize all the things! NFC.
The only top-level imports now are needed for inheritance relationships.

The only function-level imports are HACKS that I need to FIXME; they
all `from context import context as ctx` and then fetch whatever they
actually need from the `ctx` just as if `ctx` had been passed in by the
caller instead of fetched from this magical global storage.
2017-04-18 01:12:25 -07:00
3096c49fb9 This is working! 2017-04-18 01:12:24 -07:00
cc288161a4 Major overhaul of temperature logic. Behavioral change.
I think the reason the temperature logic was so confused in the old code
is because the Java code has a class `Temperature` that is used for
graphical display *and* two variables in `formulas` that are used for
most of the actual math. But somewhere along the line, some of the code
in `formulas.java` started reading from `Temperature.value` as well.
So the Python code was just faithfully copying that confusion.

The actual abstraction here is a very simple "temperature" object
with a stored value. It can be "clamped" to 100.0 for a given period.
The only complication is that one of the codelets (the rule-transformer
codelet) wants to get access to the "actual value" of the temperature
even when it is clamped.

The Python rule-transformer codelet also had a bug: it was accidentally
setting `temperature.value` on the `temperature` module instead of on
the `temperature.temperature` object! This turned some of its behavior
into a no-op, for whatever that's worth.

Lastly, the calculation of `finalTemperature` in the main program can
now report 100.0 if the answer is found while the temperature is clamped.
I don't fully understand why this didn't happen in the old code.
I've hacked around it with `temperature.last_unclamped_value` for now,
but I should TODO FIXME.
2017-04-18 01:12:24 -07:00
daeff3d9bf Pylint the code 2014-12-22 23:44:09 +00:00
94a0ecae48 PEP 008, mostly lines too long 2014-12-22 16:38:10 +00:00
2281870cf2 removed unnecessary utils 2012-12-01 02:10:33 -05:00
33cf41b585 fix linter errors and warnings 2012-12-01 02:00:03 -05:00
cfaebd150f tabs to spaces 2012-11-30 02:12:44 -05:00
b12ae322eb Make a package from the python scripts 2012-10-26 17:40:20 +01:00