OddThinking

A blog for odd things and odd thoughts.

Achieving Achievements

After ploughing through some rather mundane coding in my “day job“, including, you will be happy to learn, some further improvement in unit-tests, I recently decided to reward myself with an interesting side-track.

A colleague once explained his theory of “Conservation of Interest” in software development. If a project isn’t interesting enough, coders will make it interesting. That can be bad for the project if unchecked. This is very much a case of that, but I am keeping it well in check. This does not count as “work”.

After our discussion recently of achievement badges for unit-testing, I wondered how you would implement such a thing for my business accounts.

Ultimately, there is only one metric that matters in our business – profit. But there are some proxy metrics that show progress towards that goal, like volume, return, and volatility, etc. What if I awarded myself achievements based on progress of those items.

So, it is a double-fun project. It seemed an intriguing coding problem, and, if implemented, may help keep my ongoing interest in how the accounts are doing. Maybe not as motivating as the raw profits themselves – but hey! We are currently in a continual slog period in the project lifecycle, and it is proving to be a teensy bit dull, so the idea of the computer popping up each morning and saying “Well done! You just hit your highest week’s turnover ever.” or “Oh dear! You had your worst continuous run of profit-less transactions in a row!” might make my job more interesting.

Two factors made my life easier. Unlike major games, I don’t have to maintain badges for thousands of users. Also, my entire database of records is tractable, so I can simply re-run the analysis over the entire thing, rather than persisting a running log of progress towards the various goals. Nothing in my architecture precludes such changes, but it isn’t something I worried about.

I took a pipeline approach, filling it with “events”.

At the start of the pipeline was a source that iterated over every transaction in date order, putting each one in the pipe.

Next in the pipe was an end-of-day detector. It monitored the stream, passing each transaction along. When it saw the date of the transactions change, it inserted an end-of-day-marker.

That wasn’t too useful, because the end of a (GMT) day is rather arbitrary. I created a new pipe section that would detect gaps in the transaction timeline, and insert an end-of-session marker. It quickly marked out more natural breaks determined by the nature of the business. End Of Month and End Of Week pipelines were also written. These sections were plugged together serially, so each type of token would appear in the pipeline. I set up I expect one day I will need to add End of Quarter or End of Year pipelines as well.

Then I wrote an aggregator, which would sum up the count, turnover and profit on each transaction. It was configurable to reset each time it saw an End of Session/Day/Week or Month token. It inserts a Aggregate Summary object into the pipeline, where it can be seen by the next pipe section.

Now for the achievements! I realised the achievements I wanted to award break-down into several types.

One set of achievements is a “lifetime” award. For example, when my profit reaches $1 million I want an achievement award. Then another award at $2m. Then I won’t need bit of encouragement another until $5m and $10m. So, I created a configurable pipeline that watches each bet, adds up the profits (or turnover, or other metrics), and has a scaling set of awards at 1, 2, and 10 times each order of magnitude. I started the awards at numbers a bit lower (just for testing purposes – of course). Also, purely for reasons of symmetry, I had it able to track negative profits (I believe they are called “losses”, in the lingo, but of course I have never, uh, had to use that expression.)

Another set of achievements is to beat your personal best. If my previous high-water mark in my accounts was $33m, and then it dropped down to $31.5m before shooting up to $43m, I get an achievement when it gets up past $33m the second time, even though it hasn’t hit the $50m mark yet (which the above achievement system would reward.) Note that I don’t continually get this achievement on every transaction after $31.5 million – just on the passing the threshold. Furthermore, there is a minimum duration that it needs to be below the high-water mark. A single, um, negative profit, in a continual run of wins doesn’t get you an award.

Talking of continual runs, that’s another type of achievement. If you have a continual run of profit-making transactions (or days, or weeks) that is longer than any previous run, it gives you an award. Again, the award is just once-off per successful run, not for every additional success in a row. However, if you make it to twice or ten-times your previous record for a run, it gives you extra special encouragement. (e.g. it changes from saying “Nice.” to “Bravo!” to “EPIC!!!”) A special check ensures that there has been at least 5 cycles of positive and negative before awarding you anything. These achievements shouldn’t be meaningless due to small sample sizes!

I once was awarded a special certificate in High School for coming the best in my year level in my high school in some competition. It was a rather hollow achievement because all it proved was that I beat the one other guy who entered.

All ideas these can be combined together with the pipeline approach. Long run of losing transactions. Longest run of winning weeks. Most transactions in a month. Biggest daily profit. The list goes on. It can be like a sports-commentator, always coming up with weird combinations of qualifiers that prove that that last play was an historical moment.

Yet, despite this… despite the dozens of trophies that it has retrospectively handed out… despite me adding additional combinations to try to give myself a better chance… it still hasn’t found any reason to pat me on the back (or even scare me with record losses – there, I said it!) for anything that has happened in the past two weeks.

Alas, my computer agrees. We are in a boring stage.

2 CommentsCategories: S/W Dev
Tags: achievements, software, software architecture

Comments

  1. I had a brilliant idea this morning. I added a new achievement with a single line of code. (I love frameworks that work!)

    Added to the end of the pipeline, this achievement counted runs of End-Of-Day markers versus runs of Awards, ignore all other Pipe Items.

    As a result, I now have a “Most Awards in a Day award” and “Most Boring Period – Most Days without an Award”. Yep, that’s how meta I swing.

    At last, I thought, an award that will have happened recently. Alas, it turns out this current period is so boring, it isn’t even interesting enough to be the most boring period.

    I lose.

  2. I lose.

    You don’t have to put it so harshly. You’ve just enjoyed negative success.

Leave a comment

You must be logged in to post a comment.