Auto-dialing Roads

I’ve been playing around with the api and have put together a little
something so that most of my roads will auto-dial. The idea is to capture
the momentum on occasions when I push a little harder by letting that
increase my average and basing the steepness of my roads on that average.

I don’t know if it’ll be useful to anyone else, but I like the idea of
starting with a wildly and unreasonably low requirement and letting my road
dial itself as I do more and more, forcing me to keep up the momentum once
I’ve proven I’m capable of doing more than I’ve planned. (I’ve combined
this, of course, with the ‘max safe days’ feature so that the road tightens
quickly at the beginning, too.)

One way to imagine using this is starting with a goal like 1 push-up per
week with a max of 2 safe days so that you’re forced to try and do at least
~some~ push-ups every second day. After the 3rd time (which falls on the
5th day), let’s say you now have an average of 20 push-ups for every second
day. The road would dial itself to 70 push-ups per week. Now you have to
maintain at least that momentum. If the next 3 attempts see you doing 25
each (with a day of rest in between), your weekly average would be up to
85.91, and your road would be dialled to that now. Continuous improvement
without having to think about it too much.

What’s below will only affect the goals you list and each only starts to be
affected after there are at least 5 days of data. It also sets the end date
to four weeks from this being run and leaves the total null. That’s plenty
easy to change. (There are a few additional tweaks that I have deleted
(hopefully without unwittingly mucking up a parenthesis anywhere in what’s
below) where there are max and min numbers for certain goals where I don’t
want to go over/under a certain rate.) I’m also sure there are better ways
to do this… but I just thought of this this morning and I’m not a
programmer… so I will be ignoring all comments of the type “omgodz! Don’t
you even know how to…” (Also, I’m doing other things with some of the
components, so there are pieces here that could easily be written more
efficiently for others.)

Anyway, hope this sparks some ideas for someone.

// Self-dialing Roads
foreach ($goals as $goal) {
if ((($goal->slug == “somegoal”) || ($goal->slug == “someothergoal”) ||
($goal->slug == “yetanothergoal”)) &&
(($goal->curday-$goal->initday)/(246060)>5)) {
$countDiff = ($goal->curval-$goal->initval);
$countDays = (($goal->curday-$goal->initday)/(246060));
if (($goal->runits == “d”)) {
$countAver = ($countDiff/($countDays-1));
if (($goal->runits == “w”)) {
$countAver = ($countDiff/($countDays-1)*7);
if (($goal->runits == “m”)) {
$countAver = ($countDiff/($countDays-1)*365/12);
if (($goal->runits == “y”)) {
$countAver = ($countDiff/($countDays-1)*365);
$change = $api->getGoalApi()->updateRoad($goal->slug, $rate = $countAver,
$date = $fourWeeks, $value = null);

1 Like