On Deckbuilding Games and Slay the Spire

Deckbuilding is a genre of games where players start with a (usually) standard deck of cards and then improve it over the course of the game. This can involve acquiring new cards that are usually more powerful than the initial set of cards and/or synergise in better ways, upgrading existing cards, or even removing cards that are weaker or less relevant so that one is more likely to draw the (better) remaining cards.

These games typically offer some replayability because the sequence of decisions one may have on how one can improve one’s deck differs from game to game; what it means for a deck to be successful can also vary depending on what the other players are doing.

Slay the Spire is a player-versus-environment RPG where combat is driven by a deckbuilding mechanic; players start with simple offensive (Strike) and defensive (Defend) moves plus possibly a few class-specific cards. The combat is turn-based. On a player’s turn, the player draws 5 cards. Cards have an energy cost, and players initially have three energy per turn to play as many cards from their hand as they want. Of course, there are cards and other mechanics that can be leveraged to obtain additional card draws or energy. Players are also shown their opponents’ next moves, which allows for some degree of planning; a simple example of this could be deciding to eliminate a specific monster in a group, because it is about to attack.

In terms of gameplay, the start of the game does feel relatively rudimentary as the player always has the same or a similar deck. However, each time a player defeats a group of monsters, he is given the option (but not the obligation) to add one of three cards to his deck.

The options that come up in the first few rounds will typically shape how the deck develops. For example, while most cards can be upgraded once only, there is a specific card called Searing Blow that may be upgraded multiple times; eventually, it can develop into a card that costs 2 energy but yet deals far more damage than Bludgeon, a 3 cost card that deals pure single-target damage. It is a viable strategy to build a deck around this, eliminating other cards from the deck so that one draws it on every turn; there are cards like Double Tap (which, for 1 cost, doubles another attack) that can further enhance this type of deck.

Conversely, I frequently play in a style which relies on combining cards that give a constant strength bonus to all attacks along with cards that attack multiple times for small amounts of energy. That said, some degree of flexibility is important, as the choices given to the player will be different on different plays; being wedded to a single strategy can be dangerous, as specific key cards may not be available.

Players can also acquire relics which further influence game mechanics; these can simply provide boosts (such as “every 10th attack does double damage”), make certain styles of gameplay more attractive (“the third Attack card you play each turn boosts your Dexterity by 1 for the rest of the combat”) or even significantly change game mechanics (“retain your hand rather than discarding it” or “if you empty your hand, draw 1 card”). These are random (and apart from at the shop / rewards from winning boss battles, players aren’t really given options here) so, as before, planning on specific relics becoming available is also typically not a good solution.

Winning the game unlocks a new-game-plus mode called ascension; players start at Ascension 1, which increases the rate at which elite enemies spawn. Winning the game on Ascension 1 unlocks Ascension 2, which applies the restrictions of Ascension 1 and makes normal enemies do more damage. This increases incrementally up to Ascension 20. I’ve got up to 16 on one of the characters. At high levels there’s not very much room for error; I have had a 10 win-streak without Ascensions, but struggle with high Ascensions quite a bit. I think I tend to force my deck to fit a certain mold perhaps too early on; this can get scuppered if I subsequently am unlucky.

Another challenge a player can take on, as with many other games, is speed-running, or attempting to win quickly. Playing fast (as shown in the screenshot above) limits one’s time for decision making. For example, I normally plan my entire route through the map for each level at the beginning of the level, but that of course takes a bit of time. A normal, more relaxed game can easily take 30-40 minutes, especially if I’m playing with a relatively less aggressive build.

I’ve played the game for about thirty hours or so. It has been enjoyable, and the Defect character (an automaton that manipulates a queue of orbs) is particularly fun, if difficult to use. In terms of educational value I think the game demands a decent intuition of probability, as well as understanding how cards may work together. There are some synergies that are explicit or clear, but others are often less obvious and require some thought/experimentation.

Travelling Songs

For a recent Palantir event, I was asked to state a song that I enjoy listening to whilst travelling. I had a few candidates in mind, but went with This Town by Niall Horan. I didn’t have to justify my choice – but I had several reasons in mind.

Most of my travel for work is done solo. This makes sense for going on-site, but even for larger company events and conventions I find that I end up travelling on my own fairly often. Also, quite a lot of my travel requires flying; even when it is not long-haul, the overhead of going through airports and ensuring that I am on time already adds quite a bit of travel time. I thus find that I have a fair chunk of time where I spend time thinking and reflecting on how things have been going. I thus picked a quieter, more downbeat song which gives me enough space to maintain a thread of reflective thought. That said, interestingly the other songs I had in mind were unlikely to be as conducive to that!

I should count myself fortunate to have travelled quite a fair amount for work (that said I’m sure there must be people who are sick of excessive travel). One “class” of songs that might be relevant for some would be a sense of adventure and anticipation; for me personally on work trips that is a bit less relevant. Many trips are to places I’ve already been to (I guess the company only has a few major offices) – in the past three years I think I have visited Palo Alto about eight times. Of course, that may change with university on-site recruiting picking up; I first visited both Denmark and Croatia on these trips, and I did enjoy those travels a fair bit.

I think of myself as fairly ambitious. There are often more things I like to do than have the time to execute on (and hence metaphorically “words I never got to say the first time around”). In some ways, this is especially true of my travels to Singapore, as I’m there only about three to four weeks a year out of 52. Separately, work trips often involve very intense iteration (that tends to be what motivates the trip in the first place), leaving little time to explore the place I’m in.

Thinking about it, the song does also mention the act of travelling (“drive highways and byways to be there with you”). I didn’t pick the song for that reason, though – identifying work as the thing one is always chasing is dangerous.

The other songs I had in mind included Fury of the Storm by DragonForce; that follows the “sense of adventure” theme. That song also brings back memories of my first internship at Palantir, which involved a decent amount of travel. I’m not sure I could imagine listening to metal for ten straight hours or so, though. I also considered James Arthur’s Back from the Edge which I featured in a review about a year and a half ago; travel certainly doesn’t provide a clean or blank slate, but it does provide a temporal boundary for how I categorise things, I think.

During the event, nine other engineers volunteered their choices. There was a fairly broad range of picks, ranging from rather bubbly dance pop (Elastic Heart by Sia) to harder rock picks, and a couple of alternative choices I was completely unfamiliar with. It was nice to see this variety, though.

Algorithmic Problem-Solving: On Pigs and Poison

A teammate asked me a computer science / algorithm question over lunch. It took me somewhere between 30 to 40 minutes of thought and discussion with teammates to solve the problem, inclusive of writing about 20 lines of Java; I can see it being a kind of ‘brain teaser’ interview question (and thus generally best avoided). That said, genuinely not having heard this problem before, I think it was interesting to see the thought process I went through to get to the final answer.

You have 1,000 buckets of water, 1 of which is poisoned. It is known that the poison if ingested will kill a pig within 15 minutes. You have one hour to determine which bucket contains the poison. What is the minimum number of pigs that you need, and how would you do it? (Eventually, of course, you want to generalise your answer.)

After some initial “lateral thinking”-style questions (does the poison only kill pigs? is the death timing exact?), I determined that it was intended to be a genuine algorithms problem. As a computer scientist, I then thought of binary encodings. This gives a quick solution to the case where you have just 15 minutes to determine which bucket is poisoned – if you convert each number to a 10-bit binary number (so the first bucket is 0000000000, the second is 0000000001, and so on) and give the first bucket to no pigs, the second to pig number 10, the third to pig number 9, the fourth to pig numbers 9 and 10 and so on, the final state of the pigs 15 minutes later allows you to determine the poisoned bucket. If we used this method and only pigs 5 and 7 died, then the poisoned bucket has binary representation 0000101000, which corresponds to bucket number 40. In any case, we know the answer is bounded above by 10.

I then considered ways of extending this solution given that we can run four trials instead of one. I did consider partial experiments, but didn’t see a way this would be helpful. One quick possibility we came up with was to linearly split the buckets among a number of pigs to cut down the search space – though this risks losing one pig at each iteration. Still, we determined that 6 pigs would work:

  • On trial 1, you have 1000 buckets and 6 pigs – divide into 7 groups of at most 143.
  • On trial 2, you have 143 buckets and possibly 5 pigs – divide into 6 groups of at most 24.
  • On trial 3, you have 24 buckets and possibly 4 pigs – divide into 5 groups of at most 5.
  • On trial 4, you have 5 buckets and possibly 3 pigs – the binary method can distinguish 8 buckets.

Yet, this same method wouldn’t work with 5 pigs. We were ready to settle on 6 as the answer, but the question asker revealed that it was possible to do better than 6. The idea of imbalanced groups then came up – the ‘no risk’ group of buckets should be larger, because in that case we could guarantee that we would still have all our pigs if we needed to investigate that group.

I guess I haven’t done algorithm interviews for a good while, and it thus took me to this point before I thought of setting up a recurrence relation. Define W(n, p) as the maximum number of buckets distinguishable with n trials and p pigs remaining. I then set up this relation:

W(n, p) = \begin{cases} 2^p & n = 1 \\ 1 & p = 0 \\ W(n-1, p) + pW(n-1,p-1) & \text{otherwise} \end{cases}

The last case comes about because we can safely allocate a group of W(n-1, p) buckets to be given to no pigs, since with one fewer trial we can distinguish between them. For each of the pigs present, we need to prepare to continue the investigation with one fewer trial and one fewer pig, hence pW(n-1,p-1).

This is more efficient, but doesn’t quite get us there yet. I noted that p(4, 5) was somewhere in the 800s, which established that strategies based on risking one pig in every round apart from the last would be insufficient. Thinking a little more about it, I realised that in the extreme case, you could always have a special bucket each round that you gave to all pigs – if they all died that round, we would know that bucket was poisoned. However, you couldn’t have more than one of these per round – if they all died, you wouldn’t know which bucket was the cause.

More generally, you could split the groups of buckets into groups that are given to zero, one, two… up to p pigs, where p is the number of pigs still left. The groups given to smaller numbers of pigs could likely be larger, to account for the additional resources available in later rounds. The following recurrence relation then drops out:

W(n, p) = \begin{cases} 2^p & n = 1 \\ 1 & p = 0 \\ \sum_{i=0}^p \binom{p}{i} W(n-1, p-i) & \text{otherwise} \end{cases}

This actually has a closed form solution. I didn’t notice it when looking at the recurrence, though it became apparent when I coded up a program to calculate the required W(4, 5) = 3125. I was surprised to see how much additional discriminatory power five pigs had, though four wouldn’t be sufficient. Interestingly, five pigs and three periods were sufficient. The general closed form solution is simply W(n, p) = (n + 1)^p and our argument provides a method for actually identifying the relevant bucket.

Finally, an interesting challenge here was to establish that it wasn’t possible to achieve this with four pigs (so that 5 would be the minimum). One way to do this was to reason in terms of information theory – a pig either survives all the way or dies after a given round, and then it stays dead. This is n + 1 many possibilities, and there are p pigs, so it seems that we can’t do better than (n+1)^p. Clearly 5^4 = 625 < 1000 so four pigs isn’t enough; also, this expression matches the value obtained by our recurrence-based method, suggesting that that is indeed optimal.

Tactics and Strategy (2018 Q2 Review)

I generally interpret strategy to refer to thinking about broader goals and general approaches for achieving these goals; conversely I think of tactics as finer-grained methods for effectively completing smaller tasks (that hopefully contribute to fulfilling one’s strategic goals). As a software engineer who works with databases, strategic concerns could be “the database should be able to serve requests quickly”, or “you shouldn’t be able to shoot yourself in the foot too easily”; tactics could involve using B-trees or clever data structures, or being careful about what APIs one exposes respectively.

For individual endeavours and also at work, I often need to play both a strategist and a tactician. I’m responsible both for determining what to seek at a high level and for implementing the required steps. There’s some tension in devoting resources towards getting better at either of these; I’d say the skills are certainly distinct (though not independent; good strategic thinking requires knowledge of what may be tactically plausible, and one should implement suitable tactics to optimise for outcomes that one strategically favours).

Strategically things have been a bit foggy this quarter. To some end there has been progress in terms of general quality as a developer, at least by some metrics. Getting better technically is good, though it seems to have been more of a focus than I remember prioritising it to be.

I have to some extent been struggling to find satisfaction in things, as well (there was a very relevant series of sermons on contentment in church – but practical application is often much harder than theory). I think some of this was a change from working with a preponderance of ‘shiny’ features leading to patent applications or other forms of explicit external recognition. I even forgot about some features that were clearly valued by other teams or people until they reminded me that I wrote them when discussing what I’d been working on in general!

Outside of work, also, I need to find strategic direction (there hasn’t been very much). With regard to computer science, I need to think where I go from here. AAMAS’18 in Stockholm is coming up and I’ll be presenting there about model checking LDLK on finite traces. This paper was very challenging to write; differently from the first two, I actually had to develop a substantial amount of novel content. I found myself guilty of excessive handwaving in the original proof presented in the thesis – there was a detail which I claimed to be trivial that turned out to require a full column of argument! I also have one more paper to write. I’ve also not been doing as much independent study of both computer science and software engineering as I would like.

In terms of finance, one of the good things about index investing is that there isn’t that much to do once the system is set up. There’s even less if you’ve automated some of the workflows (as I have)! After that, much return is subject to the random walk of the markets – with the (I’d say justified) belief, of course, that that walk trends upwards. The main ‘action’ required then is to stay the course, which requires patience and persistence.

Markets have been a bit of a mixed bag. Equities have gone up a lot apart from emerging markets, but a good chunk of this is likely to be currency effects as the pound fell hard. The usual table follows:

(Disclaimer: I hold the Fidelity World Index Acc, Vanguard LS80, iShares EM index, iShares property index, BTC, GBP and USD in various quantities, among other things.)

Spending has exploded (well, relatively) this quarter. Some of this is due to periodic expenses with a period greater than three months coming in in this quarter – renewing the servers and domain name for this website and brokerage fees. There is also some (I’d say permissible) lifestyle inflation too – frugality or cheapness to the detriment of daily happiness is usually not something worth doing unless one is forced into that position.

My budget also has a category called ‘Learning and Development’, which includes books for reading and fees for various educational activities (such as conferences, lessons, exams and the like). This swelled in Q2. I haven’t been reading substantially more. Most of this was the fees for AAMAS’18, FLoC’18 (more logic!) and music lessons.

I’ve made a conscious decision to spend more time outside of work on various recreational pursuits (even if the precise details of these aren’t clearly directed). I’ve gotten faster and better at solving logic puzzles and Sudoku; it’s difficult to come up with clear performance metrics, but I’m usually able to score in the 70th percentile or so in online contests, and can occasionally squeak into the 80s in broader contests (where the average skill level is slightly lower). I know that I was in the 20s or 30s when I first started trying these. I ranked 42 of 157 in the UK Sudoku Championship 2018, and less impressively 50 of 141 in the UK Puzzle Championship 2018.

I’ve continued writing here – a bit less frequently than I would like, admittedly. I also had my first vocal lesson in about three years or so – it’s good to be back. To some extent I strive for quality in what I do, even in recreation (I told my teacher “I enjoy sounding good” – I didn’t go as far as “I only enjoy it if I’m sounding good”, though that’s probably more true than I like to admit…)

I traditionally feature a song I’ve listened to a lot over the quarter in these reviews; I’ve done this for about five years now, and it can be interesting to see what I was listening to several years ago. In many cases I liked most of the songs then and I still do now; I tend to select quite heavily for a meaningful message or idea, and I like to think I’m quite resistant to faddish qualities in songs.

I first heard this song on a plane (like many others!) when flying from London to Singapore for a one-week vacation in May. I have listened to a couple of songs by the British boyband The Wanted before. One of their heavier pieces, Warzone (about leaving an abusive relationship) featured in my 2014 Q2 review, where I decided the 90- and 100-hour weeks I worked then were a bit too much of a cost. I also quite like Chasing the Sun, and a couple of their album-only tracks as well.

Unfortunately, the band dissolved a few years ago. They weren’t quite as successful as One Direction, so as far as I know only one member, Nathan Sykes, has continued with a solo career. I didn’t actually know this until I came across his new album Unfinished Business (yes, quite apt). The opening track is titled Good Things Come To Those Who Wait. It reminded me a fair bit of James Arthur’s Back From The Edge both aurally and thematically.

The second verse is relevant to some issues I’ve been thinking about this quarter:

Some people run and fall
They don’t even walk at all
There’s nothing to prove, just to feel you exist

It’s important to balance aggressive implementation (“running”) with careful evaluation of whether what one’s implementing is relevant to what one wants to do – especially if the path ahead is unclear. In some cases, it can be better to move more slowly and carefully.

The last line sounds weird, but in context is a reason why the speaker takes his time with things. The converse of feeling a need to prove oneself to others is understandable. I do fall into that trap sometimes, though I know it can be a dangerous thing to do.

More generally, the idea that good things come to those who wait can be contentious. I think it depends on what kind of waiting is involved – waiting to strike when opportunity arises is great (which I think is the point of the song – “I prefer to stick when the others would twist”), but idle, muddled waiting might not work so well.

As far as the album is concerned, I also found I Can’t Be Mad to be excellent. There were also a number of other good songs; I think it was a reasonably strong offering.

Scoring Points

I think it would be reasonable for me to describe myself as competitive. Through my years at university I had a goal of scoring a GPA of 90 percent (where a first-class degree is awarded at 70 percent); I added a clause of working a part-time job later on. I’ve enjoyed participating in a variety of contests from young, both in terms of work (Singapore Math Olympiad, ICPC) and play (Sims 4, music exams, puzzles).

Speaking of puzzle contests, I participated in the UK Sudoku Championship 2018 at the beginning of this week. Participants were given 2 hours to solve 16 puzzles of varying difficulty. To keep things interesting, the puzzles aren’t just standard or “classic” sudoku, but also feature additional constraints – for example, the highest-scoring puzzle had an additional constraint where both major diagonals had to have the digits 1 to 9 once each as well. I solved 13 puzzles, which led to a placement of 42 out of 136 (or 157, depending on whether one considers zero scores). I finished the remaining puzzles after the time ran out and would have needed about 2:20 overall; the fastest solver cleared everything in 1:09, just under half that!

I think one of my weaknesses can be a tendency to over-index on pursuing things that I think are worth doing. This may not work out so well if my thoughts turn out to be incorrect or misguided, or if the pursuit causes unpleasant side-effects. Writing this reminds me of the 90 to 100-hour weeks I used to pull in second year when studying for the exams then.

Anyway, one of the things I’ve been looking at recently has been building up a healthy portfolio. I had a conversation with my parents today, and one of the things that came up as part of the discussion was something I used to do in high school.

In Singapore, most food courts and hawker centers have an economy rice stall. The stalls offer steamed white rice accompanied by various cooked dishes. These include meat-based dishes like fried chicken or Chinese char siu, vegetable dishes and tofu, among others. Ordering from an economy rice stall is typically cheap (as the name suggests); thinking about it, it also bears similarity to the low-cost model for airlines in that one chooses and pays specifically for what one wants, and has flexibility in choosing what is included.

My high-school canteen had an economy rice stall, and I remember budgeting S$1 (now 56p; then probably more like 45p or so) for lunch every day. This would typically result in fairly unhealthy meals, admittedly, with rice plus one hot-dog and a small portion of nuts and anchovies. For comparison, many meals in the canteen ranged from S$2 to S$3. Note that cooked food in Singapore is generally much cheaper than in London, and food in school canteens is typically subsidised.

Some of this frugality continued when I entered university. I had similar ‘adventures’ in my first year at Imperial, where I somehow maintained a grocery budget of £7 per week (£1 per day) for a full academic term. Things relaxed over time, especially as I convinced myself that I did have reasonable earning power. To be fair, there was increasing evidence of that as I did several internships and part-time jobs while I was at Imperial.

Clearly, if one is trying to build a portfolio quickly, one factor that can be optimised on would be maximising fresh inflows to the portfolio. Minimising one’s expenses and thus increasing one’s savings rate helps with that, of course.

However, aggressive expense minimisation often leads to other appreciable costs in terms of health, happiness and stress. Apart from direct opportunity costs (for example, from foregoing higher quality or safer food), there are secondary effects as well (affecting socialisation, for instance). The mental overhead of needing to evaluate many small financial decisions every day can be significant as well; I’ve found it to be the case in my personal experience.

Having a sizable portfolio can be useful; I don’t think I have to be convinced of the value of financial independence even though I don’t necessarily have early retirement plans at this stage. However, as an end in and of itself it is not particularly satisfying. I’m fortunate in that I haven’t taken on large debt obligations, and right now (though I may regret saying this later) bumping the numbers in some brokerage account or on my spreadsheets is nice, but brings very little marginal happiness.

It may well be obvious that, to quote a blog post I read this week, life is more than compounding money. In general, reducing it to an arbitrary single end is difficult. Nonetheless, when pursuing a goal I sometimes lose some sight of broader things, and it’s thus important to remind myself of this.

It has been said that “what gets measured gets managed”, and for me at least most goals tend to be fairly quantitiative and measurable in nature. I often place these in some kind of OKR framework which often isn’t as friendly to softer, more qualitative tasks. That probably explains to some extent “losing sight of broader things”. Some may have a very clear and specific view of what they want to do, but I’m not there yet.

On Challenges that Build

On my return flight from Singapore to London, I listened to quite a few hours of music. Two of the songs I listened to and enjoyed at least partially for similar reasons were It’s Gonna Be Me (by NSync), and I Can’t Be Mad (by Nathan Sykes). It’s a bit of a strange pairing as the former seems to be an upbeat, relaxed pop song while the latter is a fairly moody piano ballad. However, the common element I latched on to here was that both songs feature sections that are repeated multiple times, with the vocals developing additional complexity on each iteration (thinking about it this is fairly common in songs that are critically reviewed well, and also in songs I like). For example, in It’s Gonna Be Me there is a line in the chorus which is sung four times over the course of the song, and its complexity develops:

The challenges in I Can’t Be Mad have a couple of changed notes, but also (if trying to reproduce the original) demand different productions of the notes (falsetto vs not, belts, etc). There’s always a risk of adding too many embellishments, though I find expanding upon base melodies can be quite interesting. Singing these, and considering what would be reasonable for my voice (adding a closing run to the last syllable above, for instance) and what would not be (adding a +1 semitone key change after the second chorus in I Can’t Be Mad – original is already awfully hard), can be enjoyable too.

Generalising this, I quite like the idea of “increasingly complex variations on the same theme” when learning concepts and when teaching them. This already seems to happen for many concepts in mathematics. Over the course of an A-level student’s mathematics education, he/she might understand how to write a quadratic expression as a product of linear factors (e.g. converting 6x^2 - 19x - 7 into (2x-7)(3x+1)). This could first begin with expressions where inspection works feasibly. However, students should also be presented with some examples where inspection is extremely difficult or even impossible (though probably only after gaining some confidence with the cases where inspection is plausible). For general expressions, one could try to use both the quadratic formula and factor theorem to factorise something like 6x^2 - 19x - 8 into -\frac{1}{24}(-12x + \sqrt{553} + 19)(12x + \sqrt{553} - 19). However, there will be some expressions like 6x^2 - 19x + 16 where the solutions to the quadratic are not real; later, with some understanding of complex numbers, these would make sense. Students will also learn about problems which may not obviously be quadratics but can be written as such (like x^4 + 2x^2 + 1); the ability to synthesise the various techniques can then be tested with something like 7x^8 - 10x^4.

To some extent my Masters project also had this theme – linear time logic, adding knowledge, adding dynamic modalities, generalising that to full branching time logic, and then switching out the infinite traces for finite traces. I haven’t written a course or a book on a computer science topic yet, but I can imagine that there might at least be sections that follow this kind of sequence.

This pattern also occurs a fair bit in many technical interviews I’ve seen as well, where problems start easy, but additional and progressively more challenging constraints are repeatedly introduced. The purposes here could include testing for a breaking point, seeing how candidates react to problems without an obvious solution, or whether they are able to synthesise additional information to come to a solution.

I find that I often learn best by practicing on smaller examples at first, and then (attempting to) generalise their conclusions to larger models, considering when these conclusions may fail or not. Having multiple variations of progressive difficulty can be useful as they can give a sense of achievement as partial progress towards an overall goal is made. Furthermore, I find understanding how changes in the problem scenario leads to the base solution method being applicable or inapplicable to be a key part of understanding as well; there is a clear need to reason about this when considering incremental variations. Going back to It’s Gonna Be Me, for example, aiming downwards at the word ‘love’ and not conserving sufficient air or energy for it might work for the first three passes, but it’s unlikely to on the last round.

There is a risk that the method can be frustrating in that it seems like it is consistently ‘moving the goalposts’, especially if one forgets that the partial goals are partial goals (and starts to think of them as complete ends in and of themselves). The standard I’m using for understanding (ability to critically evaluate applicability in novel contexts) may be seen as a little high. I also haven’t covered how to bootstrap the method (that is, how to develop an understanding of how to attack the base problem before any variations are introduced). Nonetheless I think there are some contexts where this works well. I’ve found it to be useful in singing, mathematics and interviewing at least!

Colour Rush (Board Game: FUSE, Kane Klenko)

While I’m not sure I would go the full length to say that efficiency is the highest form of beauty, I’d certainly say that I can find efficiency to indeed be beautiful. In controlled environments, I enjoy testing my own efficiency (typing tests, programming and Sudoku competitions, competitive Sims). Many of these environments feature elements of uncertainty, meaning that managing probabilistic outcomes is key to being efficient (in Sudoku bifurcation can sometimes be faster than reasoning through complex logical chains; in a programming contest, you might luck out on some buggy or sub-optimal algorithm actually passing all test cases anyway). I’ve recently enjoyed a challenging game which has probability management at its core.

FUSE is a real-time dice game from designer Kane Klenko. Players play bomb defusal experts who are trying to defuse bombs; this is represented by rolling dice and placing them on ‘bomb’ cards to match constraints. The team rolls some number of dice, and then allocates them to the cards, incurring penalties if some of the dice cannot be allocated. The game itself has a hard time limit of 10 minutes, so quick thinking is encouraged as players get more turns (and thus more rolls of the dice).

The dice are almost standard six-sided dice; interestingly, I noticed that it was not the case that opposite faces of each die added up to seven (2 was opposite 4 and 3 opposite 5, for some reason). The dice come in five colours (red, blue, black, yellow and green), and there are five dice of each colour. Card constraints may involve numbers, colours or both, and vary widely in the difficulty; easy cards have requirements like “two dice matching in either colour or number” or “A – B = 2”, while more difficult ones can involve building a six-die pyramid where each die is a specific colour. The bombs are rated in difficulty from 1 to 6, skipping 5.

Some bombs also introduce ordering constraints, requiring players to build a tower or pyramid (and players are not allowed to build unsupported structures). There is also a dexterity element here, as the penalty for knocking over a tower or pyramid is losing all progress on that card.

I’ve only played solo or in a team of two. Playing solo, a player draws and rolls three dice at the beginning of his/her turn, and then allocates them to a pool of four active cards, possibly placing multiple dice on a single card. At any time (except towards the end of the game), there are four active cards and five cards in a ‘market’ ready to become active when an active card is completed.

I’ve been able to complete the single-player “Elite” difficulty (getting through 23 cards in 10 minutes) about half of the time if playing with a random mix of 27 cards, and have done it (once in ten attempts or so) if playing with cards drawn from the most difficult sets (i.e. all the level 6s and 4s, with all remaining cards being level 3s).

I made some simple tactical observations regarding card constraints. For example, there is a level 2 card requiring three numbers that sum to 11. If I have a free choice of a number to play there, I would play as close to 4 as possible (considering that two dice most likely sum to 7).

I think the main strategy in solo play involves ensuring that one’s cards don’t end up having conflicting demands, as far as possible. For example, consider the following set of cards.

This is an awful situation to be in, because apart from one space for a 1, all of the cards here demand high numbers to start. Four decreasing numbers only admits a 4 or higher (and even then, I find starting that card with a 4 very restrictive as it forces 3-2-1); the 15 sum only admits a 3 or higher (and then forces 6-6; I usually play one six and then on a later turn find a pair adding to 9). Misaligned numerical constraints can be painful; misaligned colour constraints might be even worse because colours are sampled without replacement (well, until card(s) are cleared or penalties are incurred). There is a level 4 card that demands four dice of the same colour, which I try not to pick up.

There are many cards that have rather specific requirements (e.g. a specific colour and number); I tend to try to carry one or maybe two of these at a time, while trying to ensure the rest of the cards cycle regularly. The penalty for a unused die involves re-rolling it, and then removing a die that matches in terms of colour or number (if possible).

Although the game only lasts ten minutes (or less, if the deck is cleared in time), I’ve found it to be highly addictive, especially difficult runs on the elite difficulty. I’d expect times to vary quite widely as it’s a dice game, though I’ve noticed that I run out of time with between one and three cards from the end most of the time. I’ve never counted, but it wouldn’t be unreasonable to average fifteen seconds for a turn, and to some extent things average out over 120 selections and rolls. As mentioned above, I think a key part of solo FUSE strategy involves managing interactions between the requirements of active cards.

Minor criticisms would include some disconnect in the difficulty of the cards. I find that most of the level 6s are less luck-dependent than some of the lower level cards, like the level 3 “any 5, a yellow die, and a green 2”. More bizarrely, the ‘6-5-4 pyramid’ card in the photo above is only level 2, though it’s considerably more restrictive than the ‘sum to 15’ card also in the photo (level 3). There might be a case for a more permissive card being rated higher if the cost of verifying correctness is higher (e.g. ‘three digit prime number’), but I don’t think adding three numbers introduces much overhead.

The ceiling for individual card difficulty also isn’t very high. The highest stacks are of height 5 (with very loose constraints) and pyramids of height 3 (using six dice). I’d imagine there would be scope to define some level 8 cards that might use seven or more dice and/or require combinations that are stricter or more complex, like a six-die pyramid where each die not placed on the ground level must equal the sum of the two dice directly underneath it, or even something like this:

I’ve played this with a friend from Imperial as well. With two players, each player has two active cards, four dice are rolled and each player must take two dice. We only played up to the standard difficulty. I’d like to play this with a bigger group, though; communication gets much trickier, and also with two I am able to maintain sufficient context in my head to compute a good allocation of four dice across two sets of two cards. With five, there are 10 active cards, which would probably be unreasonable to keep track of.

In summary, I’d highly recommend this game based on my solo/pair experiences. I’ve probably had about twenty to twenty-five playthroughs in total, and have enjoyed it thoroughly even though I generally don’t enjoy real-time games. Each run is short, but can generate an adrenaline rush, and the difficulty level is highly configurable so it should be possible to find a level that works well. I might even extend the game with some custom “hard mode” cards (this can be done by getting opaque sleeves so the backs are indistinguishable). I haven’t yet had the opportunity to play with a larger group, which should bring new and interesting challenges too.

Making Heads of Tail Risks

I remember that I was fairly anxious at the beginning of my fourth year at Imperial. I was concerned about securing work after university. Looking back, this seemed patently ridiculous; I had topped my class for the third time and already had a return offer in hand from Palantir. However, owing to sweeping government rhetoric about controlling post-study work visas at the time, I saw “not being able to get a work visa” as the primary risk then, even if it was remote. That statement in and of itself was probably correct, though the time I spent to monitor and mitigate that risk (reading up on government committee reports, and considering alternatives like a H1B1, EU blue card or doing a Tier-2 ICT after a year) was excessive.

Of course, this never materialised; and even if it did, the only likely impact would be that I’d have to fly home to Singapore in between finishing uni and starting work (I did not; though on hindsight that might have been a good thing to do).

I’m not sure when I first became aware of the concept of probability distribution functions (or, for that matter, continuous random variables). These functions are continuous, take on nonnegative values and integrate (across all variables) to 1. In the case of single variable functions, one can plot them on a two-dimensional graph; one may get results looking somewhat like the picture above, in some cases.

Areas of regions underneath the graph are proportional to the probability that a value falls in that region. For example, a uniform distribution would have a probability function that’s just a horizontal line. The graphs for the return of investments 1 and 2 in the example above follow what’s called a normal distribution; investment 3 follows a Student’s t distribution which has fatter tails.

Since areas are proportional, a simple technique for generating random values from an arbitrary distribution is called rejection sampling; if one draws a box around the distribution and throws darts randomly at it, one can take the x-coordinate of the first dart that lands underneath the function as a representative random sample.

That’s a basic mathematical introduction. If we had to rank the quality of the return profiles above (remember: right means higher returns), a lot would depend on what we were trying to do. I would personally rank investment 2 (the green curve) on top; it has a considerably higher mean return than investment 1 (blue) and adds only a small amount of variability. We can calculate what’s known as the standard deviation of a given distribution; this is a measure of how much variability there is with respect to the mean. In fact, the blue curve has a standard deviation of 0.6; this is 0.7 for the green curve.

Ranking investments 1 and 3 is more difficult; the mean of 3 is higher, but you add a lot of uncertainty. I’d probably rank them 2, 1, 3. However, there is also an argument in favour of investment 3 – if one is only interested if the returns exceed a certain level. It’s a similar line of argument where if you’d ask me to double a large sum of money (nominally) in 20 years, I’d pick a bond; 10 years, a general stock index fund, and 10 minutes, probably blackjack or aggressive forex speculation.

Whichever investment we pick, it’s possible that we may get unexpectedly awful (or excellent!) results. The standard deviation could give us some measure of what to expect, but there is still a non-zero probability that we get an extreme result. For the normal distributions (the blue and green curves), there is a 99.7% probability that a single observation will be within three standard deviations of the mean; this does also mean that there’s a 0.3% probability it does not, and about a 0.15% probability it’s lower than three standard deviations below the mean.

Tail risk refers to the risk of events that may have severe impact but are low-probability; considering them is important. Going back to the work visa situation, I think I correctly identified visa policy changes as a tail risk, though in hindsight controlling the amount of time spent mitigating them was done poorly – akin to spending $10 to insure against a 1% probability of $100 loss (provided the $100 loss wasn’t crippling – which it wouldn’t have been).

I also spent a lot of time focusing on mitigating this specific tail risk, when perhaps a better solution could be developing resilience to general tail risks that may affect my employment. The obvious routes at the time would have been continuing to do well academically and develop my skills, though others exist too – such as having a greater willingness to relocate, living below one’s means and building up an emergency fund. There are still further tail risks that the above wouldn’t address (e.g. a scenario where computers and automation are universally condemned, all countries practice strict closed-border policies and the global fiat money system collapses) but the costs in mitigating those risks seem untenably high. I haven’t read Antifragile yet (what I describe here is weaker, as it doesn’t demonstrate benefiting from low-probability events), though that’s planned to be on my reading list at some point in the future.

Irreversible Changes (2018 Q1 Review)

When I was a student, the academic year was a rather friendly source of periodicity in doing reviews. The ends of the various academic terms lined up reasonably well with Q4, Q1 and Q2 reviews, and a Q3 review was typically reflection about what I got up to over the summer. I don’t think there has been a single large and direct visible change in my circumstances compared to that a year ago. I can see how under such conditions, days and weeks may all blend together into a mush of time. Of course, one can argue that there are still other distinctive events; there are obviously the seasons in weather terms, and also other cyclic patterns (e.g. college recruiting season with high interview volume, winter holidays).

In terms of development, while quantifying growth is always challenging I like to think that I’ve started to see some distinct improvements this quarter. I’m basically the product owner of a rather small but absolutely platform-critical service, and have also started driving some tasks that involve cross-team coordination. The computer-scientist part of me is also satisfied; a paper on model checking multi-agent systems against LDLK specifications on finite traces received an acceptance at AAMAS18, and there is another patent going into the pipeline. Referencing the goals I set at the beginning of the year, performance is along the lines of 0.7 for growth as a developer, 1.0 for paper submission and 1.0 for patent submission (not achieved yet, but more than on track).

I have been spending quite a lot of time on work, and I noticed that I’ve been sleeping more as well – I’m not sure why, but it’s crept up from about 7 to 8 hours pretty consistently. Some of this might be stress-related and some of it might be owing to the colder weather, though I can’t quite put my finger on it.

In terms of skill development, I’m generally slightly behind my desired pace in the various disciplines I considered at the start of the year:

  • This is the ninth post I’ve written this year (interpolation: 13).
  • I’ve only visited Singapore and Switzerland so far this year (interpolation: 3).
  • I’ve walked a daily average of 9,578 steps per day (target: 10,000).
  • I don’t have metrics for singing. I can sing B4 most of the time nowadays, but haven’t focused my efforts on developing a strong upper range to a song in particular. Interestingly my lower range seems to have weakened a bit – I used to hit E2 rather easily, while now it’s a stretch.

Financially, the markets haven’t been the smoothest.

I guess this is my first significant paper loss. I easily stayed invested and even bought more through both the corrections in mid-2015 and early 2016 (e.g. considering VWRD, a USD-denominated Vanguard world stock ETF, these were drops of 13.8% and 10.9% respectively). This time around, VWRD has “only” shed around 9.5%, so it’s not even a technical correction yet. I don’t explicitly hold VWRD, but it’s likely that my portfolio has fallen by a similar amount – except that that’s actually months of income now. There is a price to pay for that equity risk premium.

In terms of friendships, most things have been ticking over acceptably well; I guess stability here is a good thing, and that for the most part has been the case. Some bumps, but nothing out of the ordinary.

I’m very aware that I’ve been spending a larger than normal amount of time this quarter thinking about philosophy and planning, mainly along what direction I’d like to take myself in. Rather expectedly, I find this more mentally taxing than working through even the nastiest and most technical parts of my Masters thesis. I don’t quite have answers yet – and even if I did, my thoughts might easily shift given a day or two (or suitable events).

This quarter, I’ve been listening to “These Days” (Rudimental with Dan Caplen, Jess Glynne and Macklemore) a fair bit. While there are parts of the song that feel a bit formulaic (the progression in the first part of the chorus, in particular), I nonetheless enjoy listening to it. It’s also fun to sing along to, with a fairly broad vocal range and numerous runs, falsetto flips and tough notes to belt out (the middle of the chorus). The song discusses a failed relationship, though all speakers seem to have accepted its failure, and express hope that they may make the best of the situation going forward.

Three years of ups and downs, nothing to show for it now
And I know it ain’t pretty when the fire burns out

I find that the idea also works well unilaterally – having failed and/or aborted ventures is fairly normal (one could argue that a complete absence of failure correlates well with not setting one’s targets to be sufficiently ambitious). Failure does hurt, especially if one has invested lots of effort in pursuing something. Nonetheless, reaching this point implies coming to terms with one’s failure, which is a very good step.

Reading List: ‘Absolutely Nasty Sudoku, Level 2’ (Frank Longo)

I enjoy logic puzzles (not just in a formal context, to be clear). Probably one of the most well-known genres of these is sudoku, a grid-based constraint satisfaction problem made popular by the Japanese publisher Nikoli. Given a 9 by 9 grid which may be decomposed into three 3 by 3 sub-grids (boxes), fill in numbers such that there is precisely one number from 1 to 9 in each row, column and 3 by 3 sub-grid. Some numbers are already given as clues; there is usually only one unique solution for a given clue set.

Solving a sudoku puzzle, in general terms, is NP-complete (of course, for a 9 by 9 grid, solving can be done in constant time). ‘Obvious’ strategies involve finding the only place in each row/column/box where a given number could go (since each of these must contain each digit once), or finding the only number that could be assigned to a given cell.

The next step would then involve considering interactions between cells – for example, ‘these two cells in this row can only contain 3 and 5, so no other cells can contain a 3 or a 5’, or ‘both of the cells where 7 could go in this box are in the top row, so there can’t be a 7 in the top row of the other two boxes that are horizontally aligned’ (called a pointing pair). Complexity only develops from there; there are a myriad of clever strategies as shown on the sidebar here.

Sudoku (sudokus?) are often featured in newspapers, and there are many compilations of these. However, as one gets familiar with the strategies, these can become less interesting. For example, consider this hard sudoku from the Guardian; a not-that-smooth solve yielded a 5m11s time, and the most complex technique I used was the ‘pairs’ reasoning I outlined above.

I recently discovered Frank Longo’s Absolutely Nasty Sudoku series, and thankfully this is one series which seems to live up to its name. Consider this grid (which is the puzzle above, converted into an easier to read format):

The grid pictured above is from a puzzle towards the tail end of the Level 2 book. Although no cells are obvious (and it doesn’t look like the pairs/triples logic yields anything), there are several ways to proceed from here:

  • In row 3, you can have an 8 only in columns 2 and 9. This is also true in row 6. This means that no other rows can have 8s in columns 2 and 9; in particular, the second cell in the bottom-most row can’t be an 8, and has to be a 4. (This strategy is called X-Wing.) This is arguably the most straightforward deduction here, though it wasn’t the one I saw.
  • Consider that if row 5 column 1 was a 5, then row 8 column 1 must be an 8; that forces row 9 column 2 to be a 4, and row 9 column 7 to be an 8. Alternatively, row 5 column 1 can be an 8. Either way, row 5 column 7 can’t be an 8, and must be a 4. (This strategy is called an XY-Chain.)
  • Suppose row 6 column 7 was a 9. Then, the rectangle of cells with vertices in rows 1 and 3 and columns 4 and 7 admits two solutions; without affecting other cells, I can have either a 3 or 7 be in the top left corner. Thus, row 6 column 7 can’t be a 9, and must be a 3. (This strategy is called a Unique Rectangle.) This was actually the next step I made when solving this puzzle!

A key criterion when evaluating whether a Sudoku book (or a puzzle book in general) would be the difficulty and quality of the puzzles. The difficulty level for Level 2 is well-placed for someone like me, if maybe a little on the easier side; I’m familiar with most/all of the ‘basic’ techniques, and am aware of though not confident with trickier techniques like the aforementioned Unique Rectangle. I might have preferred Level 3, actually; there were several puzzles at the beginning of Level 2 that seemed like they could be solved with techniques I’d consider as basic. I also haven’t found any “broken” puzzles which couldn’t be solved (presumably, the author would have checked these with a solver before publication)!

I also have other criteria for evaluating Sudoku books, though. I tend to write down cell candidates as well as other annotations when solving. These help me more easily remember observations like pointing pairs; I’d prefer the grids to be sufficiently large that I can comfortably write these out. The grids in this book were certainly of adequate size. While my handwriting tends to be quite small, I don’t think grid size would be problematic for most people.

The choice of ring binding seems to make sense, too; the book needs to remain open when one is solving. Generally I found the paper to be very smooth to write on. I don’t have many complaints here.

The book has a very brief foreword, and then gets straight into the puzzles (with solutions at the back). The target audience is clearly people who are well-accustomed to Sudoku. As mentioned earlier, this is the second in a five-part series and based on online reviews I determined this to be a good place to start. I wouldn’t recommend this for someone just starting out with Sudoku, though.