Generic decision logic, Part I

Unfinished changes, but not a broken build.  The name of "stimulus" will
need to change...