A User's view of Hledger

Learning about hledger

Playing games with hledger?

Some months ago after playing a boardgame, I wondered if I could have used hledger to track the points in the game. I don’t mean that using hledger would have been faster or anything like that, it was more “could this be done?”.

I was reminded of this question again after recently playing one of my favorite tabletop games, Roll Through the Ages. Would it be possible to use hledger to track the scoring? This would be a good exercise, not to replace the very useful scorecards that come with the game, but as a way to learn more about hledger.

The first idea that came to mind is that earning points in the game is like, well, earning money in real life. To take an example from the game, in Roll Through the Ages, you can earn points for developments you acquire. For example, if you obtain a development called Leadership, you get 2 points. Thus, the hledger transaction could look something like:

2024-06-25 development
Leadership -2 points
score:development 2 points

In addition, you can earn points for building monuments. The easiest monument to construct is the Step Pyramid, worth one point. In this case, the transaction might be expressed as:

2024-06-25 monument
Step pyramid -1 points
score:monuments 1 points

Alas, not everything in the game results in your earning points. If you fail to feed one or more cities, you lose a point for each city whose population goes hungry. Assuming that in one turn you failed to feed two cities, the hledger transaction could be:

2024-06-25 disaster
Food shortage 2 points
score:disasters -2 points

Finally, let’s find out our current point total. Here’s an hledger command and its output:

hledger areg score
Transactions in score and subaccounts:
2024-06-25 development Leadership 2 points 2 points
2024-06-25 monument Step pyramid 1 points 3 points
2024-06-25 disaster Food shortage -2 points 1 points

Answering the question “How could you use hledger to keep track of points scored in a game?” was a good learning exercise for me. Plus it was fun to think about one of my favorite games.