Life & much, much more

Competitive weight loss with

So last year (or perhaps even the year before, time flies!) two people close to me participated in a friendly weight-loss competition. To do this, they used

WeightRace is a small web application I built a while ago for fun, which allows up to four contestants to compete towards a weight goal which they would set. They would be prompted daily for weight updates, and would set a reward for the winner. It also used some lightweight gamification so contestants could earn bonus “wobbly bits” when achieving things like their BMI.

But enough talking about the application — applications are boring! Much more interesting are results! Let’s see:

WeightRace - competitive weight loss

The two contestants — whom we shall refer to as Rob and Julie, which may or may not be their real name — and their results are shown in the graph above. Julie is red, Rob is blue, and their linear trajectories towards their weight goal is shown via the corresponding coloured dotted line.

If I could hear a sped-up commentary of the results, it would truly be exciting! Rob makes an excellent head-start well ahead of his trajectory, whereas Julie is having trouble beginning. As we near the holiday (Christmassy) season, we see Rob’s progress plateauing, whereas Julie gets her game on and updates with a rigorous discipline. Also great to notice is the regular upward hikes in Julie’s weight – those correspond with weekends! As the holidays pass, Rob makes gains and is unable to recover.

In the end, although Julie wins the Race, neither Julie or Rob met their weight goal (note that in terms of absolute figures, Rob actually wins). However, this was all not in vain. Given that almost another year has passed since this race finished, and I can see that Rob’s weight is now well under control and has indeed achieved his goal, I’d like to think that the WeightRace has played a role.

In particular, the WeightRace helped raise daily awareness. I believe that it was this daily awareness of the current weight that helped most in the long-term. In addition, the WeightRace helped Rob’s body to stabilise around 90kg for half a year! I suspect his body figured out that it could manage at that weight, which made it easier for him to (after the WeightRace) continue to lose weight at a healthy pace.

For those interested in playing with the WeightRace, you can check it out online at Note though that it is not actually complete, but works good enough for a competition. For those interested in the source, it’s up on my GitHub.


Tech tip #7: Using PlayOnLinux to run applications already installed by vanilla WINE.

RTS is an acronym for real-time strategy. It’s a game genre. There’s a classic RTS game known as StarCraft. Although only a casual gamer (say, might I recommend Machinarium?) I have played (and somewhat enjoyed) a few more "hardcore" games – like for instance, StarCraft. Although being pretty pathetic at it, I did enjoy it and appreciated the balanced strategy between the various "races" you could control in the game. With StarCraft II already out (hell, it’s about time!) I decided to revisit the original StarCraft: Brood War game to refresh my memory.

I downloaded the game from, installed the latest version of WINE (1.3.0), ran the Blizzard downloader flawlessly, ran the installer flawlessly – and true to its Gold ranking on the WINE AppDB, ran the game flawle- no wait. It was laggy. Not particularly laggy. But it wasn’t as fast as it should’ve been, and too many critters on the screen would make it choke. I tried all the lag-fixes suggested on the AppDB submission to no effect. It was a sort of phantom, website-loadingish lag.

However one comment on the AppDB page said that using PlayOnLinux to install WINE 0.9.14 to run StarCraft fixed all lag issues. I decided to give it a shot. Turns out any version below 1.0 is no longer supported (as any sane developer would do) and no longer available in portage. PlayOnLinux was, however – and PlayOnLinux did still allow WINE 0.9.14 to be installed. Unfortunately it wasn’t particularly intuitive to tell PlayOnLinux to run my installed .exe file with WINE 0.9.14, so perhaps this blog post might help others in my situation. Using these steps I was able to install a prehistoric version WINE via PlayOnLinux, and tell it to run the already installed version of StarCraft on my computer:

  1. Install PlayOnLinux, Tools -> Manage wine versions -> install v0.9.14. Should be straightforward.
  2. mkdir /home/username/.PlayOnLinux/wineprefix/starcraft && env WINEPREFIX=/home/username/.PlayOnLinux/wineprefix/starcraft wineboot
  3. cp -r /home/username/.wine/drive_c/Program\ Files/StarCraft /home/username/.PlayOnLinux/wineprefix/starcraft/drive_c/Program\ Files/ (or mv it, doesn’t make a difference)
  4. touch /home/username/.PlayOnLinux/configurations/installed/StarCraft
  5. Place the following in the StarCraft file:

export WINEPREFIX="/home/username/.PlayOnLinux/wineprefix/starcraft"
export WINEDEBUG="-all"
cd "/home/username/.PlayOnLinux/wineprefix/starcraft/drive_c/Program Files/StarCraft"
wine "StarCraft.exe" $@

And that’s it! Run PlayOnLinux and you’ll be able to run the program from there. This guide should be able to work for other scenarios as well so feel free to adapt it.

Oh, and as for the lag? Yep – oddly enough it did get completely fixed. Regression time.


ADOM: Game review.

I’m not a gamer. I don’t mind playing games, they’re fun. However I don’t see any sense in wasting a good majority of my day playing a game. Games attract me because of the intellect and flexibility within them, not so much the advance in graphics. Replay-value is probably what I weigh as most important for a game.

A good while back I was – I admit – searching for a game for my computer. As I was on Linux, the game had to be 1) Linux-compatible, 2) Free, and 3) Not lag. A quick public question in IRC came up with the answer: ADOM – Ancient Dungeons of Mystery.

It’s a command-line run game – a roguelike. For those unaffiliated with this genre a picture speaks a thousand words:


Ok – it already looks ancient. As you might’ve guessed, it’s all text based, and you move about just like you would in any modern day RPG. The story revolves around you as a young explorer trying to discover the source of some evil thing called chaos that is destroying your world. You complete quests and learn through experimentation how to survive in this magical and mysterious world.

Being text-based, it allows me to play it when SSH’ed in remotely. This is a very ideal scenario for people who don’t do gaming seriously like me. It also helps that you can pretty much stop playing anytime and resume later exactly where you were without fear of the consequences.

What makes it fun is the flexibility and complexity of the game. There are a lot of things you can do – there are even several ways of winning. For example, I can attack a monster by throwing my hat at it – it probably won’t be very effective, but you get the idea. Or I could kill some rats and eat their corpses – or if there was a cat nearby I could feed it some rat corpses and it might become my pet. There are spells, races, classes, potions, herbs, weapons, shields, clothing, amulets, gods, quests, pets, shops, skills, talents, curses, special effects – you get the idea: it’s detailed. You can do a lot of stuff – and stuff you do affects stuff that happens to you. Heck, locations are randomly generated every single time you play the game. If that’s not awesome replayability, I don’t know what is. ADOM’s Wikipedia entry says a lot more about it than I can mention in this post.

Don’t be fooled by the hideous graphics – or lack of graphics. It’s a challenging and interesting gaming experience. I still haven’t won it – not even come close. True I’ve only played it 20 times or so (savefiles are limited to one per character, and once dead, that’s it. No saves), but yes, it’s challenging. You actually have to reason once in a while.

Just because it’s a console-based game doesn’t mean it doesn’t play nice with Windows or Macs. If you’re looking for an interesting gaming experience to try out next weekend I would recommend ADOM. Just a note: it takes time to learn, and it’s hard – don’t be discouraged if you keep on dying.


A Little 21 Fun with C++.

Given the recent love I’ve shown to a great deal of languages, including but not limited to making a text editor with Python (Ssss!), challenging your manliness with LaTeX (what real men useā„¢), and most recently a tribute to a great deal of languages that all mesh together in the most wonderful way in “How to Make a Website part 1 – The Environment“, I’ve decided it’s time to give C++ a chance to show itself on this blog.

When I decided to learn application programming (from web programming), I chose the languages Python and C++. Python for the ultimate rapid application development it can be used for, as well as the ease of syntax that should introduce the application programming concepts a lot quicker to me, and C++ for, well, it’s pure power. C++ can be described as the swiss-army-knife of a programming language … a decently low level language, strictly typed, nicely object orientated, efficient, and it’s actually compiled, unlike what I’m used to (oh my, what a spoiled generation I live in). Another reason being that C++ is the main language used in KDE development, of which I would like to contribute to someday.

Today, being a Friday, was the be-all and end-all of the week, where I enter my weekend early, and take a break from the ongoings in my life. Therefore, I decided to poke again into C++. Armed with nothing but with whatever little I remembered from the first peek at the language more than 2-3 months ago, the man pages, and general knowledge of language syntax (well, the syntax highlighter gave some clues), I decided to make myself a BlackJack game. Suffice to say that the process was pain-free, and within 15 minutes I was playing BlackJack!

It is, of course, a CLI app, but I don’t see why it shouldn’t be cross platform. However, since I don’t have a Windows computer I can compile it on, you Windows folks will have to do it yourselves. For the technophobes, I give you a screenshot (hahaha):


…and for the more logic inclined, well … a combination of basic common sense and mathematics should be enough for you to get the gist of what the code is doing. (It’s even commented for the hard of thinking) Take a look:

#include <iostream>
* Generate random number that represents a card (1-13)
int generate_card()
return rand() % 13 + 1;

* The AI will always have a card between 15-21. This will generate their card.
int generate_ai_card()
return rand() % 7 + 15;

* Let's play the game!
int main()
// This creates a random seed for rand() based on the time.


bool play;
int ai_card, my_card;
char x;

std::cout << "Welcome to a very simple BlackJack game to kill time.\n";

play = true;

// Get the AI's card.
ai_card = generate_ai_card();

// Get your first card.
my_card = generate_card();

std::cout << "You have " << my_card << " - (h)it or (s)tay?: ";

// Ask for a hit or stay.
std::cin >> x;

// If they have hit...
if ( x == 'h' )
// Generate a card, and add it on.
my_card = my_card + generate_card();

// Have they bust?
if ( my_card > 21 )
std::cout << "You got bust (" << my_card << ").\n";
play = false;
std::cout << "You now have " << my_card << " - (h)it or (s)tay?: ";
// If they stayed...
else if ( x == 's' )

// ... See who is bigger.
if ( my_card > ai_card )
// You WIN!
std::cout << "You won! (" << my_card << " vs " << ai_card << ")\n";
play = false;
// You have FAILED.
std::cout << "You lost! (" << my_card << " vs " << ai_card << ")\n";
play = false;
std::cout << "Please either type \"h\" to hit or \"s\" to stay: ";
while ( play == true );
// Some credits and stuff.
std::cout << "Thank you for playing Dion Moult's C++ BlackJack game.\n";
return 0;

Again, it amazes me how I can turn a quick 15 minutes of nothing into an entire blog post. Perhaps I should finish off one of my drafts and give you something interesting for once.