It’s another weekend, isn’t it.

I’m out of deep things to say. I don’t usually have deep things to say. Sorry to anybody who subscribed hoping for more things like the last post. This is basically going to be a personal stream of consciousness post. But it’s a stream with a long ancestry, since I apparently wrote 400 words about it in a WordPress draft four years ago. This was way back before I even started writing post drafts in Markdown on my computer instead of directly in WordPress, so I guess it must be an interesting topic.

Four years ago, Brian2012 was suddenly struck by how many of the people he knew were such serious gamers. But let’s go back even earlier, shall we?

A long long time ago, when I was in elementary school or so, my parents had some sort of reward system where I had to do productive things, like study or do chores or write diary entries or practice the piano or something, to earn time on the computer for games. “Gaming time” was a currency. I enjoyed saving up lots of thirty-minute increments and knowing I had the freedom to using them slowly.

That much I remember; the details of how it worked are very fuzzy and I’m not sure what I played in those thirty-minute increments either. I think there was Neopets and Runescape and Club Penguin. (My Neopets account still sees sporadic activity, because I get really really bored sometimes…)

Continue reading


Jam-Packed Fun and Games

Did I say “fun”? That was short for function calls. Which are fun too, admittedly. Blah, I always go to such lengths to come up with snappy yet justified post titles and end up achieving neither.

One more complimentary breakfast later:

This is it.

Google Code Jam World Finals.

[Google Code Jam 2015 name tag with my name and handle and country]

Let me take a moment to reflect. Seriously. I do not know how I made it this far this year. I guess I might be a top-500-ish competitive programmer globally, maybe even top-150-ish, but definitely not top-25-ish. And Log Set, the hard problem that got me through Round 3, doesn’t seem like it plays to my forte particularly either. It’s a bit mathy, but the math bits aren’t the hard part; I think it’s largely implementation, with one psychological hurdle where you have to realize that, because of how few distinct integers there are in S′, you can efficiently solve the subset-sum instances you need to produce the lexicographically earliest answer. I’m actually kind of impressed I got that. It seems like the sort of hurdle I usually get stuck on. How did this happen?

Maybe randomness. Maybe I was just particularly clear-minded during the round and wrote less buggy code than usual, because I had no expectation of making it whatsoever and so could look at the contest detachedly (until midway through the contest I accidentally noticed that my rank was under 20, and even then I tried very very hard not to think about it, and it kind of worked).

But it happened, and now I’m here. Time to roll.

In some emails much earlier in the Code Jam logistical process, Google had asked for “requests for changes and/or additions” to the software that would be installed on our competition computers, and I had sent them a long list:

Here are some things I’d like if they were installed, in decreasing order of priority:

  1. The Vim plugin syntastic ( )
  2. a Haskell compiler (probably Haskell Platform 2014.2.0.0 even though it’s a year old)
  3. the Haskell package hdevtools ( ) so that the above two may be integrated
  4. (I don’t have enough Linux experience to name a specific thing to install, but command-line utilities that are the equivalent of pbcopy and pbpaste on Mac OS X, which allow me to redirect text into or out of the clipboard from the command line easily)

Of course, this is my first Code Jam and I don’t know how reasonable these requests are. Any nontrivial subset would be appreciated.

Continue reading

Ninety-nine (card game)

(Frivolous blog content, posted as part of a daily posting streak I have openly committed to; standard disclaimers apply)

It is quite interesting that Wikipedia’s article on Ninety-nine (addition card game), plus many of the following search results (ignoring the identically-named trick-taking game that is guaranteed to show up), have the same basic idea but wildly differing assignment of special cards from the one I’m familiar with, which everybody I can recall having played with agrees on. (Admittedly I’ve only ever played this among Taiwanese friends.) The only special-card assignment method that came close was a certain person’s “stuff from my old blog” dumping post I bumped into very accidentally. (His 5 is our 4; our 5 skips to an arbitrary player. The post also clarifies that negative totals bounce back to zero, and includes a clause whereby players must state the running total after playing and lose if they’re wrong. Interesting.)

Anyway, yes, I am documenting the rules to a card game on this blog. I think this deserves to exist online.

These rules are not completely rigorous because I don’t know them completely rigorously. You can use common sense to reach a consensus in corner cases.

Use a normal deck of playing cards, or two or more identical decks if you want. Deal five cards to each player and set the rest aside to form a draw pile. Cards are played into a discard pile in the center. Players sit in an approximate circle and take turns along the circle, playing one card and then, usually, drawing one replacement card from the draw pile, so in normal 99, hands stay at five cards. When the draw pile runs out, shuffle the discard pile to become the new draw pile.

Continue reading

[IOI 2014 Part 3] Games of Luck and Strategy and Really Weird Noises

Shamelessly getting unfinished business out of the way. Yup, that’s me.

Excursion Day 1. We traveled down to Yilan on a bus. I played guess-it with Paul.

I was quite surprised at myself for remembering this game, but I think it’s simple and little-known enough to be worth mentioning. Guess-it is a remarkably pure game of luck and bluffing from one of Martin Gardner’s columns, played with a small odd number of cards, e.g. the 13 cards of one poker suit. The cards are dealt evenly to players (who can look at them) with one card left over, which is kept face down; players take turns choosing one of two actions:

  1. Name a card and ask the other player if he or she has it. These questions must be answered honestly.
  2. Guess the left-over card. The guesser wins if correct; the other player wins if not.

Guess-it is not trivial because sometimes you should ask the other player if he or she has a card that you already see in your hand; otherwise whenever you answered “no” to a query you’d immediately guess that the asked card is the hidden one. It is actually a solved game in the sense that the probabilities of the Nash equilibrium strategy for when to guess and when to bluff have been worked out already, but they’re not simple probabilities by any means and humans are terrible randomizers anyway. A few rounds of it sure beats rock-paper-scissors. I was very amused to lose almost all our games with 11 cards but win almost all of our games with 13.

Okay, no more gratuitous narrative excursions into game-theory. The first stop, National Center for Traditional Arts, was a very laid-back culture place with old-fashioned retro shops and streets.

We watched a 3D glove puppetry (布袋戲) video, in the same session as a lot of the leaders.

Continue reading


HabitRPG: harnessing the addiction of web games with cheap leveling mechanisms to destroy bad habits, avoid procrastination, and improve your life.

(Ironically, I discovered it on /r/InternetIsBeautiful.)

These claims sound a bit hyperbolic, but they are actually working on me. Most notably: for the three days after I discovered it, most of which has been spent at IOI selection camp away from school and worldly concerns, I’ve only gone on reddit once — and only for about two minutes. Instead, when I got bored of programming, I worked on economics homework, which is something that never came close to happening during the earlier iteration of camp. I just finished it and checked the to-do item off; as a result, I leveled up to Level 2 and unlocked the item shop. Yay! The sense of achievement is every bit as real as it is ludicrous.

I don’t know if I should be happy that I finally found such an effective way to psychologically manipulate myself out of procrastination, or sad that I’m so susceptible to psychological manipulation. I also don’t know if this game will be so effective after its novelty wears off, but considering the fact that I stuck with my last equally ridiculous sort-of-RPG for about three years, I can hope it’ll work for a while.

One of the unproductive things I’m trying not to do is staring at blog posts that don’t really have a solid conclusion and spending half an hour writing and deleting the last sentence, so I’m going to avoid doing that. Let’s be productive together!

Chinese New Year

A habit, almost a ritual, to see off the old year and usher in the new: gambling games.

The basic idea of 十點半 “Ten and a Half Points” is like Blackjack. Ace to ten are worth their face value in points; face cards are worth half a point; the basic hand for player or dealer is just one card; you bust if your total value hits 11 or higher, and you get double payoff with hitting 10.5 exactly or until you have five cards without busting. With an infinite, evenly-distributed deck you have better-than-even odds of not busting with an extra card at any point value 6.5 or lower. Of course, that doesn’t mean that’s the optimal hitting threshold. If I had any homework, I would probably start compiling a table.

Games of Mahjong as usual as well. Yesterday Charley, my younger cousin, joined the table for the first time and became vaguely anxious because he won twice in a row, which meant he had to continue playing as dealer, and was coaxed to stay instead of apparently computer games. It also marked my first “gàng blossom”, a win with the replacement tile for a drawn-onto-melded gàng, which is just moderately rare but very dramatic to execute and experience. At least for me. Probably not for my elder relatives, who have easily played thousands of games. (The canonical minimum for a game is four rounds of four hands each, plus any dealer-win extensions. On the rare occasions when our parents take out the tile set at home, we usually stop at one round. Time is crazy.)

In the movies, drama is injected into mahjong games rather differently. Aside from complicated blackmails and threats outside any given game, it’s hard to portray strategic considerations very interestingly, so mostly, it’s completely ridiculous luck or cheating techniques. Luck: things like the dealer winning with his/her starting hand, which is worth a crazy number of points. It happened in The Murder of Roger Ackroyd (I strongly doubt this is a spoiler; if the chapter of Mahjong accomplished anything plotwise, it was strictly in the conversation. Anyway, the ending is, I don’t know, epic. I digress.) Cheating: people who can crush a perfect-looking circle into the middle of a Four Circles tile with their bare hands. Circles with millimeter-thick designs in them. I know that checking for reality in a movie of this type is completely missing the point, but seriously.

Anyway, the basics of this game are not too complex but there are amazingly many corner cases. Of course 90% of the opportunities I have to play are holidays and family gatherings like these in Taipei, but that’s been enough to respond smoothly with three other experienced players. I’m still learning of obscure rules: apparently there’s a rule that you can’t declare mahjong on the tile drawn from claiming a discard for a kong. How many games does one have to play to know something like this?

And this is only in the Taiwanese variation; Wikipedia lists sixteen of them and an outside source has 23+2, or, er, 26. We play with three more tiles than everybody else, which makes cool winning hands harder, and is presumably the reason we don’t have a lower bound on point count. How interesting. I’ll probably have to get all confused about learning a variant if I ever want to play in the distant future.

I still can’t keep track of the prevailing winds and seat winds while playing, or reflexively count out where the dice start the tile draw. The algorithm goes a bit like: count sides counterclockwise with the dealer as 1 for the starting wall, then count tile-pairs clockwise with the same number (wat) for the offset, and start taking tiles four by four. Scoring is so intricate it gets its own Wikipedia article, which doesn’t even have any of the interesting parts. The Taiwanese scoring criteria table has… no, I’m not going to bother to count how many rows there are.

What else happened? I didn’t eat as crazily as a couple days before (but still pretty crazily) and have not yet gotten a second stomachache. Tada. Some people were setting off firecrackers or fireworks or something very loud and noisy at pretty darn exactly six in the morning. Note to self: acute = áéíóú, grave = àèìòù. That is all.