Thursday, February 21, 2019

Mapping constants to names in GTKWave

GTKWave (a circuit wave viewing tool) displays multi-wire signals as numbers by default. If those signals correspond to constants for control (e.g. instruction operation codes), it may be useful to display human-readable, human-assigned names for them instead of numbers. GTKWave can do this with Translate Filter Files.

Such a file contains one mapping per line: the number (in any base you like - you'll set this later), a tab, and the desired name. Then in GTKWave, right-click the signal in the Signals pane and choose Data Format | Translate Filter File | Enable and Select. Click the "Add Filter to List" button to open a file, then select its new entry in the top list and click OK. The  lookup seems to operate on the string displayed instead of the numeric value, so set the data format again to whatever base you used in the translate filter file. (This preserves the file selection.)

Monday, February 18, 2019

Exotherm - Quiet

I've been leaving Exotherm running (unregistered) on my computer recently. I noticed that I get an audible ding when a move occurs in one of its games. I suspect the FICS is including bell characters in move messages, which Windows plays when Exotherm prints the line to the terminal. I tweaked the script to strip bell characters out of received messages before printing them, so Exotherm is quiet now.

Sunday, February 17, 2019

When Robolectric crashes with a "not mocked" error

One student was trying to run our Robolectric-based test suite, but found that it always crashed, saying that a method in android.util.SparseArray was not mocked. It looked like that was being used internally by Robolectric, not by the student's code. The problem was solved by removing the .m2 cache folder in the user profile folder, thereby forcing Robolectric to redownload some libraries.

Friday, February 15, 2019

Robolectric's shadow of ViewTreeObserver is no more

An Android app I'm testing with Robolectric uses ViewTreeObservers to listen for sizing information to be ready. Those needed to be triggered before the functionality I wanted to test would appear. On the web, I found mention of ShadowViewTreeObserver, Robolectric's shadow (internals-exposing) version of that. But the shadow version seems to now be gone because it didn't provide any advantage over the real version. ViewTreeObserver has a displayOnGlobalLayout function that triggers layout notifications.

Thursday, February 14, 2019

Robolectric's issues with spaces in the path should be fixed soon

Previously I discovered that Robolectric can't run when the current Windows user's profile path contains a space. I reported the issue on their GitHub repository. I noticed recently that the issue has been assigned to the "4.2" milestone, indicating that it should be fixed in the 4.2 release. There are some commits starting to address the problem.

Monday, February 11, 2019

ViewTreeObserver instances might need to be fresh to remove listeners

In an Android app I'm working on, I needed to get notified when layout occurs, so I got a ViewTreeObserver for the relevant view and called addOnGlobalLayoutListener on it. Since I only wanted one notification, I called removeOnGlobalLayoutListener on that observer inside the callback. But I noticed that the callback was called over and over - clearly not removed. When I changed the callback to get a fresh observer from getViewTreeObserver(), though, the remove operation appeared to work.

Saturday, February 9, 2019

Exotherm - Automatic rematch

To make sure changes are actually improving Exotherm's strength, I sometimes have a modified version of the engine play against an older version. I connect both to the FICS as guests, have one challenge the other, and watch to see which version wins more often. To make this a little smoother, I recently added an INI configuration option to have the bot automatically issue a rematch offer after the game ends. That way, the two versions will keep playing each other over and over without my needing to poke them again each time.

Thursday, February 7, 2019

Robolectric isolation is between SDK levels, not for security

The CS class I'm on staff for grades some parts of student submissions using Robolectric-based tests. Since we're automatically accepting and running student code (which could attempt all sorts of things), we want to isolate the testing environment from the host machine. We noticed that Robolectric runs tests inside a sandbox, but on further inspection that appears to only isolate tests at different SDK levels from each other. Tested code can still freely read and write files on the host. It also doesn't appear to be possible to restrict the code with a Java security policy and still let Robolectric work at all. So for now, we're running untrusted code inside Docker containers.

Wednesday, February 6, 2019

Robolectric doesn't like spaces in the path to the user profile

Some students were trying to run our Robolectric tests, but found that they crashed with a FileNotFoundException:

java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\John%20Smith\.m2\repository\org\robolectric\android-all\9-robolectric-4913185-2\android-all-9-robolectric-4913185-2.jar (The system cannot find the path specified)
It looks like a path to some kind of cache folder is getting URL-encoded, which turns spaces into %20, making the path wrong. Therefore, users with spaces in their user profile folder name are unable to run Robolectric tests.

For now, we're working around it by creating symbolic links (mklink /d) in C:\Users from the mangled name to the real one.

Sunday, February 3, 2019

Policy Plus - List fix

A Policy Plus user noticed that POLs resulting from the official Local Group Policy Editor differed from those generated by Policy Plus in one policy. That particular policy happened to contain only a list element and didn't even have a Registry value associated with the policy itself. Sure enough, trying to enable and configure it with Policy Plus had no effect; it remained Not Configured. The problem was that the policy state determiner didn't look for list entries, so it found never found evidence that the policy is enabled (or disabled for that matter).

While I was investigating that issue, I also noticed that the Find by Registry feature didn't detect keys used for list storage. Both problems should now be fixed - the changes are live on GitHub.

Saturday, February 2, 2019

Exotherm - Evaluation tweaks

Today I tried to improve Exotherm's strength by adjusting the evaluation function. First I made pawns increase in value as the amount of material on the board decreases; this way Exotherm should be more inclined to sacrifice a minor piece to help promote. (My first attempt at the math made the value boost way too big in some cases, ironically causing the bot to avoid promotion because the resulting queen was valued less than the pawn.) This turned out to be a smaller strength improvement than I expected, but maybe there's still tweaking to do.

I also changed the threat part of the evaluation function to highly value queens next to the opposing king because that arrangement nearly always leads to checkmate. Ideally that case would be handled by the normal tree search, but sometimes the checkmate is just over the edge of what the bot can see in time, so this pushes the bot towards the mate even if it doesn't yet know for sure that the game is over.