## Thursday, December 3, 2020

### Mahjong a la Hamming

This post is absolutely unrelated to D&D.  It is also not a particularly sober post.

I was introduced to mahjong last week (first the Old Hong Kong rules, then Japanese riichi mahjong) and it is surprisingly interesting.

I've never gotten into a traditional (pre-20th-century) game before.  I learned a little about the theory of chess while writing a chessbot in school, but I don't really enjoy trying to play deterministic, perfect-information games many moves deep; it has always felt sort of like fencing, in trying to make the second-to-last mistake (and then your opponent makes the last mistake).  I tried to wrap my head around go briefly but that was as deterministic and perfect information as chess, with even more spooky action at a distance (pieces influencing actions across the board via laddering potential, for example).  Poker was a little more to my tastes, because it is probabilistic with hidden information, so the best you can do is math rather than tree-search to infinite depths, but the betting strategy and deception are too central for me.  How can I deceive when others expect me to deceive?  I was into blackjack as a kid, which was nice because it was partial information and random but not entirely adversarial, but not really that interesting because relatively soluble and simple.

Mahjong, though.  Like poker, it is probabilistic and partial-information.  Unlike poker, betting strategy and deceiving your opponents are not so central; reading your opponents is useful (particularly for not losing by feeding them tiles that they need), but in order to win you pretty much have to be able to "play your own game" of building up a good hand from the drip of random tiles given to you, balancing the speed with which you can get a hand to a "victory if I draw the right tile" state against the probability that that draw will happen against the value of the hand if it is drawn.  So it's a game about a partially-controlled traversal of the lattice of hands; you don't control your draws, but you do control your discards.  As with forking in chess, there's a fair bit of trying to build win-win structures into your hand; if you have a 2-2-3 of the same suit, you can turn it into 1-2-3 if you draw a 1 and discard a 2, 2-3-4 if you draw a 4 and discard a 2, and 2-2-2 if you draw a third 2 and discard the 3.  So you try to build these structures that maximize your options for capitalizing on randomness.

It reminds me of Hamming's lecture, You and Your Research (Hamming, for those unfamiliar, did computing at Los Alamos and then Bell Labs, invented the error-correcting codes whose descendants are used to detect cosmic-ray-induced bit flips in your RAM, and has a lot of stuff named after him in computing).  Hamming remarks that a lot of people think success/fame is all luck, but that "luck favors a prepared mind...  you prepare yourself by the way you lead your life from day to day, and then luck hits you...  It is luck, but it isn't luck."  The mahjong player might say that luck favors a prepared hand, and you prepare your hand by the way you discard from turn to turn.

There are a number of other odd parallels between mahjong and Hamming's talk.  Hamming discusses the Matthew Effect - those who have had success have an easier time having more success, while those who fall behind tend to fall further behind over time.  Many mahjong variants have a rule where if the dealer wins a hand, he gets more score than he would if he weren't the dealer, and he remains the dealer for the next hand.  So one success at the right time can enable a string of high-value successes.  So the Matthew Effect is built in, beyond the usual level of "oh I'm up, I can afford to absorb some losses".

Another remark Hamming makes is that it isn't enough to do good/novel work quickly, to be prepared for the lightning - you have to do the work in a way which makes it valuable.  The story he tells is about an engineering problem that he was solving, which had wider implications for the debate over the primacy of analog vs digital machines for solving certain kinds of problems.  He could have just solved the problem for his use case, but he realized he was on to something more general and more important, and put the extra work in to elaborate on that, and consequently his work was of greater value.  The parallel in mahjong is that creating a hand which satisfies the constraints for winning a round is not that hard, but a hand which only satisfies the winning constraints is of low value; it scores you few points.  Recognizing the potential for high point-value structures within the hand and bringing those to fruition yields exponentially more points.  The exponential scoring system is terrifying and wondrous; it means that you can afford to make exceedingly low-probability plays and have the expected value still work out, because the payoff can be exceedingly huge.  But I think Hamming would absolutely agree that the impact of science and engineering work is scored exponentially; he talks about how Poincaré had relativity figured out before Einstein, but his formulation wasn't as clear, while Einstein's formulation was in a relatively accessible style and that made all the difference.

The correspondences continue.  Hamming's remark that you can't be working on important problems all the time, you have to pick small, insignificant problems that will grow into important problems, parallels the strategy of growing a lone middle tile into a group.  His remarks on having a direction that you're going in and not vacillating are absolutely a problem that I have in developing hands, where I try to pursue too many directions for development at once.  His discussion of courage vs stubbornness and Shannon's willingness to hold out for good randomness in his technical work correspond to the potential big payoffs of the scoring system for holding out rather than abandoning a potentially big hand.

Hamming tells a story about how Bell Labs wouldn't let him have enough programmers.  Eventually this led him to ask the question if he could get the machine to do the programming, which "put me immediately at the forefront of computing.  What had seemed to be an obstacle turned out to be an asset.  Admiral Hopper has said similar."
And then in mahjong, what seem to be obstacles can often turn into assets in scoring, like pinfu (a hand with no tiles that are worth points on their own, which instead earns bonus points as a whole) or a hand with too many winds and dragons (which has the potential to become a very high-scoring "13 Orphans" hand).

"Is what you're working on important, or likely to become important?  If no, why are you working on it?"  "Is the hand structure that you're building one that lets you either win quick or win big?  If no, why are you pursuing it?"

It's just bizarre to find a game where a philosophy that I recognize as legitimate is so...  embodied.  If Hamming's views on the world are accurate, and mahjong is applied hammingism in the small, then...

There is a moment in Iain Banks' The Player of Games where the protagonist observes that the society with which he is interacting treats its central game as descriptive of life, and thinks of life in terms of the game.  I am, obviously, the rankest of novices, which makes this obvious cringe, but: I don't think I've ever met a game with the same potential to correspond to reality as mahjong seems to have.  An abstract tradgame has never hit me in the gut like this before.

Maybe part of the staying power of traditional abstract games is that like the abstractions of mathematics, you can understand more situations through their lenses / metaphors than through the lenses of more concrete games; the mahjong lens is more general than the D&D lens or the Stargrunt lens, because there are parts of the D&D lens or wargaming lens that obviously do not apply to most situations.

Perhaps when I say that perfect-information deterministic games are "not to my taste", what I really mean is that I believe that they're sort of irrelevant because life is subject to a great deal of chance and uncertainty about the world beyond just what is in the head of my opponents.  Perhaps when I say that poker is not to my taste it is because I believe that generally there are things that you can do to strengthen your own position besides communicating, that randomness isn't so strong in reality as it is in poker, so poker is likewise not a very good model of reality.

But if a traditional game does seem to correspond to reality, then one of the things which was an obstacle to me in chess, learning the opening books and studying the accumulated understanding of the game, seems much less burdensome.