Showing posts with label games. Show all posts
Showing posts with label games. Show all posts

Sunday, August 18, 2024

317600 points in Eggsplode!

Here's my TwinGalaxies record run of Eggsplode! from last year. It's using NES emulation (fceumm, with my Power Pad support code) on the Raspberry 3B+ using fceumm, and I am using two overlapped Wii DDR pads in place of the Power Pad controller (instructions here). The middle of the video is sped up 20X.

To be fair, there were no other competitors on TG for the emulation track of Eggsplode! (The score was higher than their best original hardware score, but I don't know if it's harder or easier to get this score on emulation rather than original hardware. The main differences are that I was using a larger, but perhaps better quality, pad.)

Tuesday, February 13, 2024

Playing to win in order to lose

Let’s say I have a friend who needs cheering up as she has had a lot of things not go her way. I know that she is definitely a better badminton player than I. So I propose a badminton match. My goal in doing so is to have her win the game, so as to cheer her up. But when I play, I will of course be playing to win. She may notice if I am not, plus in any case her victory will be the more satisfying the better my performance.

What is going on rationally? I am trying to win in order that she may win a closely contested game. In other words, I am pursuing two logically incompatible goals in the same course of action. Yet the story makes perfect rational sense: I achieve one end by pursuing an incompatible end.

The case is interesting in multiple ways. It is a direct counterexample to the plausible thesis that it is not rational to be simultaneously pursuing each of two logically incompatible goals. It’s not the only counterexample to that thesis. A perhaps more straightforward one is where you are pursuing a disjunction between two incompatible goods, and some actions are rationally justified by being means to each good. (E.g., imagine a more straightforward case where you reason: If I win, that’ll cheer me up, and if she wins, that’ll cheer her up, so either way someone gets cheered up, so let’s play.)

The case very vividly illustrates the distinction between:

  1. Instrumentally pursuing a goal, and

  2. Pursuing an instrumental goal.

My pursuit of victory is instrumental to cheering up my friend, but victory is not itself instrumental to my further goals. On the contrary, victory would be incompatible with my further goal. Again, this is not the only case like that. A case I’ve discussed multiple times is of follow-through in racquet sports, where after hitting the ball or shuttle, you intentionally continue moving the racquet, because the hit will be smoother if you intend to follow-through even though the continuation of movement has no physical effect on the ball or shuttle. You are instrumentally pursuing follow-through, but the follow-through is not instrumental.

Similarly, the case also shows that it is false that every end you have you either pursue for its own sake or it is your means to something else. For neither are you pursuing victory for its own sake nor is victory a means to something else—though your pursuit of victory is a means to something else.

Given the above remarks, here is an interesting ethics question. Is it permissible to pursue the death of an innocent person in order to save that innocent person’s life? The cases are, of course, going to be weird. For instance, your best friend Alice is a master fencer, and has been unjustly sentenced to death by a tyrant. The tyrant gives you one chance to save her life: you can fence Alice for ten minutes, with you having a sharpened sword and her having a foil with a safety tip, and you must sincerely try to kill her—the tyrant can tell if you are not trying to kill. If she survives the ten minutes, she goes free. If you fence Alice, the structure of your intention is just as in my badminton case: You are trying to kill Alice in order to save her life. Alice’s death would be pursued by you, but her death is not a means nor something pursued for its own sake.

If the story is set up as above, I think the answer is that, sadly, it is wrong for you to try to kill Alice, even though that is the only way to save her life.

All that said, I still wonder a bit. In the badminton case, are you really striving for victory? Or are you striving to act as if you were striving for victory? Maybe that is the better way to describe the case. If so, then this may be a counterexample to my main thesis here.

In any case, if there is a good chance the tyrant can’t tell the difference between your trying to kill Alice and your intentionally performing the same motions that you would be performing if you were trying to kill Alice, it seems to me that it might be permissible to do the latter. This puts a lot of pressure on some thoughts about the closeness problem for Double Effect. For it seems pretty plausible to me that it would be wrong for you to intentionally perform the same motions that you would be performing if you were trying to kill Alice in order to save people other than Alice.

Sunday, January 28, 2024

Measure screen latency

Last weekend, I spent a while measuring screen latency (for gaming purposes) on our TV, using a Raspberry PI, a photodiode and an oscilloscope. Instructions are here.






Friday, January 26, 2024

The authority of game rules

I just set myself this task: Without moving my middle and index fingers, I would wiggle the ring finger of my right hand twenty times in ten seconds. I then fulfilled this task (holding the middle and index fingers still with my left hand). What was I doing by fulfilling my intention? I think I was playing and winning a game, albeit not a very fun one.

Here are four ways of describing a game fitting my intentions:

  1. Victory condition: Wiggle ring finger 20 times in 10 seconds. Rules: Don’t move middle and index fingers.

  2. Victory condition: Wiggle ring finger 20 times in 10 seconds without moving middle finger. Rules: Don’t move index finger.

  3. Victory condition: Wiggle ring finger 20 times in 10 seconds without moving index finger. Rules: Don’t move middle finger.

  4. Victory condition: Wiggle ring finger 20 times in 10 seconds without moving middle and index fingers. Rules: None.

Each of these generates the same gameplay: exactly the same things count as victory, since cheaters never win, and so you win only if you follow the rules. Ockham’s Razor suggests that they are all the same game. In other words, whether we put some constraints as rules or build them into the victory condition is just a matter of descriptive convenience.

If this is right, then here is a first attempt at a simple account of what we are doing when we play a game:

  1. To play a game is to try to achieve the game’s victory condition without breaking the rules.

This gives a neat, simple and reductive account of the authority of the rules: Their authority comes from the fact that according with them is a necessary condition for achieving an end that one has adopted. It is simply the authority of instrumental rationality.

Of course, all sorts of complications come up. One is that games sometimes have score instead of a victory condition. In that case, what you are doing is aiming at higher scores rather than trying to achieve a specific victory condition, with some sort of an understanding of how breaking the rules affects the score (maybe it sets the score to zero, or maybe it you get whatever score you had just before you broke the rules). This tricky, and I explored these kinds of directional aiming in my ACPA talk last fall.

A bigger problem is this. My story started with a single player game. But things are more complicated in a two player game.

Problem 1: According to (5), if you plan to cheat, then you aren’t trying to achieve the victory condition without breaking the rules, and hence you aren’t playing the game. But to cheat at a game you have to play it! So in fact you never cheated!

Response: I think this is the right result for a single player game you play on your own. By planning to cheat in some particular way, I am simply the changing what game I am playing—and I can do that mid-game if I so choose. For instance, speedrunners of video games sometimes set themselves rules for what kind of “cheating” they are allowed to do: Can one use emulation and save states? Can one use glitches? Can one use automation, and where? If they are playing solely on their own, none of that is really cheating, because it is allowed by the rules they set themselves: their goal is to complete the game faster within such-and-such parameters.

But if you are playing against another or there is an audience to the game, things are different. We could just say this: You are cheating in the sense that you are deceiving the audience and the other player into thinking you are playing the game. Or we could say that there are two senses of playing a game: the first is simply to try to achieve the victory condition without breaking the rules, and the second is an implicit or explicit agreement with other persons to be playing a game in the first sense (e.g., indicated by signing up for the game).

Problem 2: Suppose I plan to beat you at chess while following the rules. To that end I drive to your house. Then my driving to your house is an attempt to achieve chess victory without breaking the rules, and hence by (5) the driving appears to be a part of the gameplay.

Response: This seems to me to be a pretty serious problem for the account actually. There seems to be an intuitive distinction between an action according with the rules that promotes victory and a move in the game. Another example is taking a drink of water while playing chess and doing so with the intention of improving one’s mental functioning and hence chances at victory. In taking the drink, one isn’t playing.

Or is one? When I think about it, the distinction seems kind of arbitrary and without normative significance. Take an athlete who is training for the big game. We want to say that they aren’t playing yet. But notice that in most modern sports the training itself falls under rules—specifically, rules about performance enhancing drugs. We could easily say that the training is basically a part of the game, a part that is much more loosely regulated than the rest. Similarly, many sports regulate the breaks that players can take, and deciding how to apportion the allowed break time (e.g., to take a drink of water, to relax, to stretch, or to refrain from taking it in order to make the other player think one isn’t tired) seems like a part of the game. Or take bodybuilding. It seems quite a distortion of the game to think only of the time in front of the judges as the gameplay.

What about the drive? That sure doesn’t seem to be a part of the game. But is that so clear? First, in a number of settings not showing up yields a forfit, a kind of loss. So you can lose by failing to drive! Second, you can choose how to drive—in restful or a stressful way, for instance—based on how this will affect the more formal gameplay.

Note that in chess, thinking is clearly a part of the gameplay. But you can start to think however early you like! You can be planning your first move should you end up winning the toss and playing white, for instance, while driving. Or not. The decision whether to engage in such planning is a part of your competency as a player.

Problem 3: It seems possible to play games with small children without trying to win, hoping that they will win.

Response: Maybe in such a case, one is pretending to play the game the child is playing, while one is playing a different game, say one whose victory condition is: “My child will checkmate me after I have made it moderately difficult for them to do so.” This is deceitful (the child will typically be unhappy if they figure out they were allowed to win), and deceit is defeasibly wrong. Is there a defeater here? I have my doubts.

Problem 4: I can try to run to my office in five minutes as a game or in order to be in time for office hours. There is a difference between the two: only in the first case am I playing. But in both cases the definition of (5) is satisfied.

Response: Maybe not. In (5), we have an ambiguity: it is not clear whether the fact that the victory condition is the victory condition of a game is a part of the content of one’s intention. If it is a part of the content of one’s intention, then the problem disappears: when I run in order to be on time, I am not aiming to get there in time as a game. But if we require the ludic component to be itself a part of the intention, however, then we lose some of the reductive appeal of (5) absent an account of games.

Should we require a thought of a game to be a part of the intention? Maybe. Suppose you find an odd game machine that dispenses twenty dollar bills if you tap a button 16 times in a second (quite an achievement). You try to do this just to get the money. Are you playing a game? I suspect not. For suppose a friend on a lark took your driver’s license and loaded it into the machine, and the only way to get it back is to tap the button 16 times in a second. You aren’t playing a game!

Perhaps we could say this. Instead of requiring the game part of (5) to be in the content of the intentions, we can require that something about the victory part be a part of the intentions. And perhaps what makes something a victory for you in the relevant sense is that in addition to whatever instrumental and intrinsic value it has, it is in part being pursued simply to achieve a goal one has set oneself as such. That’s what makes it not entirely serious. A game is a kind of whim: you just decided to pursue a goal, and off you go, because you decided to do so. (Of course, you might have good reason to have whims!)

Problem 5: Doesn’t the story violate the guise of the good thesis, since the victory need have no good in it apart from your setting it to yourself as an end, and hence your setting it to yourself as an end can’t be justified by its good.

Response: The case here is similar to one of my favorite family of edge cases for action theory, such as when you get a prize if you can induce electrical activity in the nerves from your brain to your arm, so you raise your arm. The raising of your arm has no value to you. But you have reason to set the rising of your arm as an end, since setting the raising of your arm as an end is a means to inducing the electrical activity in the nerves. In this case, the rising of the arm is worthless, either as an end or as a means, but aiming at it has value, since it causes the electrical activity in the nerves. (Depending on how one understands the response to Problem 4, it may be that one is then playing a simple little game with oneself.)

Similarly, if something is purely played as a game, the end has no value prior to its being set. But there are two values that you can aim at in setting victory-by-the-rules as your end: the value of achieving ends and the value of striving for achievable ends, to both of which the setting of achievable ends is a means. And maybe there is the good of play (which may or may not be subsumed under the values of striving for and achieving ends). So you have the guise of the good in an extended way: the end itself is not an independent good, but the adoption of the end is a good. That’s how it is in the electrical activity case.

Final remarks: The difficulties do not, I think, affect the basic account that the fundamental normative force of the rules of a game simply come from instrumental rationality: following the rules is necessary for the achievement of your goal. And there is a secondary normative force in multiplayer games, coming from general moral rules about compacts and deceit.

But perhaps we shouldn’t even say that there is normative force in the rules. They simply yield necessary conditions for achievement of one’s end. Perhaps they have no more, but no less, normative force than the fact that I need to exert energy to get to my office is.

Wednesday, May 24, 2023

Magnetic sensor arcade spinner

 For a while I've wanted to have an arcade spinner for games like Tempest and Arkanoid. I made one with an Austria Microsystems hall-effect magnetic sensor. The spinner is mounted on ball-bearings and has satisfyingly smooth motion with lots of inertia.


Build instructions are here.

Thursday, March 16, 2023

More on directed activity without ends

In my previous post I focused on how the phenomenon of games with score undercuts the idea that activity is for an end, for some state of affairs that one aims to achieve. For no matter how good one’s score, one was aiming beyond that.

I want to consider an objection to this. Perhaps when one plays Tetris, one has an infinite number of ends:

  • Get at least one point.

  • Get at least two points.

  • Get at least three points.

  • ….

And similarly if one is running a mile, one has an infinite number of ends, namely for each positive duration t, one aims to run the miles in at most t.

My initial worry about this suggestion was that it has the implausible consequence that no matter how well one does, one has failed to achieve infinitely many ends. Thus success is always muted by failure. In the Tetris case, in fact, there will always be infinitely many failures and finitely many successes. This seemed wrong to me. But then I realized it fits with phenomenology to some degree. In these kinds of cases, when one comes to the end of the game, there may always be a slight feeling of failure amidst success—even when one breaks a world record, there is the regret that one didn’t go further, faster, better, etc. Granted, the slightness of that feeling doesn’t match the fact that in the Tetris case one has always failed at infinitely many ends and succeeded only at finitely many. But ends can be prioritized, and it could be that the infinitely many ends have diminishing value attached to them (compare the phenomenon of the “stretch goal”), so that even though one has failed at infinitely many, the finitely many one has succeeded at might outweigh them (perhaps the weights decrease exponentially).

So the game cases can, after all, be analyzed in the language of ends. But there are other cases that I think can’t. Consider the drive to learn about something. First, of course, note that our end is not omniscience—for if that were our end, then we would give up as soon as we realized it was unachievable. Now, some of the drive for learning involves known unknowns: there are propositions p where I know what p is and I aim to find out if p is true. This can be analyzed by analogy with the the infinitely-many-ends account of games with score: for each such p, I have an end to find out whether p. But often there are unknown unknowns: before I learn about the subject, I don’t even know what the concepts and questions are, so I don’t know what propositions I want to learn about. I just want to learn about the subject.

We can try to solve this by positing a score. Maybe we let my score be the number of propositions I know about the subject. And then I aim to have a score of at least one, and a score of at least two, and a score of at least three, etc. That’s trivial pursuit, not real learning, though. Perhaps, then, we have a score where we weight the propositions by their collective importance, and again I have an infinite number of ends. But in the case of the really unknown unknowns, I don’t even know how to quantify their importance, and I have no concept of the scale the score would be measured on. Unlike in the case of games, I just may not even know what the possible scores are.

So in the case of learning about a subject area, we cannot even say that we are positing an infinite number of ends. Rather, we can say that our activity has a directedness—to learn more, weighted by importance—but not an end.

Tuesday, March 14, 2023

Of Tetris, ends, and the beatific vision

Suppose I am playing Tetris seriously. What am I aiming at?

It’s not victory: one cannot win Tetris.

A good score, yes. But I wouldn’t stop playing after reaching a good score. So a merely good score isn’t all I am aiming at. An excellent score? But, again, even if I achieved an excellent score, I wouldn’t stop, so it’s not all I am aiming for. A world-record score? But I wouldn’t stop as soon as my score exceeded the record. An infinite score? But then I am aiming at an impossibility.

A phrase we might use is: “I am trying to get the best score I can.” But while that is how we speak, it doesn’t actually describe my aim. For consider what “the best score I can get” means. Does the “can” take into account my current skill level or not? If it does take into account my skill level, then I could count as having achieved my end despite getting a really miserable score, as long as that maxed out my skills. And that doesn’t seem right. But if it does not take into account my current skill level, but rather is the most that it could ever be possible for me, then it seems I am aiming at something unrealistic—for my current skill level falls short of what I “can” do.

What is true of Tetris is true of many other games where one’s aims align with a score. In some of these games there is such a thing as victory in addition to score. Thus, while one can time one’s runs and thus have just a score, typical running races include victory and a time, and sometimes both enter into the runner’s aims. This is not true of all games: some, like chess, only have victory (positions can be scored, but the scores are only indicative of their instrumentality for victory).

It’s worth noting that a score can be either absolute, such as time in running, and relative, such as one’s place among the finishers. In the case of place among finishers, one may be aiming for victory—first place—but one need not be. One might, for instance, make a strategic decision that one has no realistic hope for first place, and that aiming at first place will result in a poorer placement than simply aiming to “place as well as one can” (bearing in mind that this phrase is misleading, as already mentioned).

Insofar as aims align with a score, we can say that we have directed activity, but there seems to be no end, so the activity is not end-directed. We might want to say that the score is the “end”, but that would be misleading, since an end is a state you are aiming at. But typically you are not just aiming at the state of having a score—in Tetris, you get a score no matter what you do, though it might be zero. In timed fixed-distance sports, you need to finish the distance to have a time, and for some endurance races that in itself is a serious challenge, though for “reasonable” distances finishing is not much of an accomplishment.

I think what we should say is that in these activities, we have a direction, specified by increasing score, but not an end. The concept of a direction is more general than that of an end. Wherever there is an end, there is a direction defined by considering a score which is 1 if one achieves the end and 0 if one fails to do so.

So far all my examples were games. But I think the distinction between direction and end applies in much more important cases, and helps make sense of many phenomena. Consider our pursuits of goods such as health and knowledge. Past a certain age, perfect health is unachievable, and hence is not what one is aiming at. But more health is always desirable. And at any age, omniscience is out of our grasp, but more knowledge is worth having. Thus the pursuits of health and knowledge are examples of directed but not always end-directed activities. (Though, often, there are specific ends as well: the amelioration of a specific infirmity or learning the answer to a specific question.)

(Interesting question for future investigation: What happens to the maxim that the one who wills the end wills the means in the case of directed but not end-directed activity? I think it’s more complicated, because one can aim in a direction but not aim there at all costs.)

I think the above puts is in a position to make progress on a very thorny problem in Thomistic theology. The beatific vision of God is supremely good for us. But at the same time, it is a supernatural good, one that exceeds our nature. Our nature does not aim at this end, since for it to aim at this end, it would need to have the end written into itself, but its very possibility is a revealed mystery. Our desire for the beatific vision is itself a gift of God’s grace. But if our nature does not aim at the beatific vision, then it seems that the beatific vision does not fulfill us. For our nature’s aims specify what is good for us.

However, we can say this. Our nature directs us in the direction of greater knowledge and greater love of the knowable and the lovable. It does not limit that directedness to natural knowledge and love, but at the same time it does not direct us to supernatural knowledge and love as such. As far as we naturally know, it might be that natural knowledge and love is all that’s possible, and if so, we need go no further. But in fact God’s grace makes the beatific vision possible. The beatific vision is in the direction of greater knowledge and love from all our natural knowledge and love, and so it fulfills us—even though our nature has no concept of it.

Imagine that unbeknownst to me, a certain sequence of Tetris moves, which one would only be able to perform with the help of Alexey Pajitnov, yields an infinite score. Then if I played Tetris with Pajitnov’s help and I got that infinite score, I would be fulfilled in my score-directed Tetris-playing. However, it would also be correct that if I didn’t know about the possibility of the infinite score, it wasn’t an end I was pursuing. Nonetheless, it is fulfilling because it is objectively true that this score lies in the direction that I was pursuing.

Similarly, our nature, as it were, knows nothing of the beatific vision, but it directs us in a direction where in fact the beatific vision lies, should God’s grace make it possible for us.

This also gives a nice explanation of the following related puzzle about the beatific vision. When one reads what the theologians say about the beatific vision, it appears attractive to us. That attractiveness could be the result of God’s grace, but it is psychologically plausible that it would appear attractive even without grace. The idea of a loving union of understanding with an infinite good just is very attractive to humans. But how can it be naturally attractive to us when it exceeds our nature? The answer seems to me to be that we can naturally know that if the beatific vision is possible, it lies in the direction we are aimed at. But, absent divine revelation, we don’t know if it is possible. And, trivially, it’s only a potential fulfillment of our nature—i.e., a good for us to seek—if it is possible.

Does this mean that we should reject the language of “end” with respect to the beatific vision? Yes and no. It is not an end in the sense of something that our nature aims at as such. But it is an end in the sense that it is a supreme achievement in the direction at which our nature aims us. Thus it seems we can still talk about it as a supernatural end.

Saturday, February 18, 2023

Two tweaks for Internet Arcade games on archive.org

The Internet Arcade has a great collection of browser-playable arcade games. But I ran into two problems: (1) the aspect ratio goes bad in full-screen mode (no black bars on the sides of 4:3 content), and (b) mouse support is turned off, which makes trackball games like Marble Madness less fun and spinner games like Blasteroids not great for those of us who have a USB spinner (I just made one myself using a magnetic rotary sensor). 

It took me a while to find a solution, but finally I managed to inject options into the underlying MAME emulator and thereby fix both problems:

First, go to a game, but don't click the start button.

Then put the following into the URL bar and press enter
javascript:MAMELoader.extraArgs=(z)=>({extra_mame_args:['-mouse','-keepaspect']});AJS.emulate()

(Note that Chrome will not let you past the "javascript:" prefix into the URL bar. You can copy and paste the rest, but you have to type "javascript:" manually.) The game will start, and the mouse will be enabled. You can add other MAME options if you like.

You can also turn this into a bookmarklet. Indeed, you can just drag this to your bookmark bar: Emularity Mouse .

There is still a minor aspect ratio problem. If you go to fullscreen and go back to windowed view, the aspect ratio will be bad in windowed mode.

Monday, January 9, 2023

Three non-philosophy projects

Here are some non-philosophy hobby projects I’ve been doing over the break:

  • Measuring exercise bike power output

  • Dumping NES ROMs

  • Adapting Dance Dance Revolution and other mat controllers to work as NES Power Pad controllers for emulation.



Tuesday, November 29, 2022

An odd poker variant

Suppose Alice can read your mind, and you are playing poker against a set of people not including Alice. You don’t care about winning, just about money. Alice has a deal for you that you can’t refuse.

  • If you win, she takes your winnings away.

  • If you lose, but you tried to win, she pays you double what you lost.

  • If you lose, but you didn’t try to win, she does nothing.

Clearly the prudent thing to do is to try to win. For if you don’t try to win, then you are guaranteed not to get any money. But if you do try, you won’t lose anything, and you might gain.

Here is the oddity: you are trying to win in order to get paid, but you only get paid if you don’t win. Thus, you are trying to achieve something, the achievement of which would undercut the end you are pursuing.

Is this possible? I think so. We just need to distinguish between pursuing victory for the sake of something else that follows from victory and pursuing victory for the sake of something that might follow from the pursuit of victory.

Monday, November 28, 2022

Games and consequentialism

I’ve been thinking about who competitors, opponents and enemies are, and I am not very clear on it. But I think we can start with this:

  1. x and y are competitors provided that they knowingly pursue incompatible goals.

In the ideal case, competitors both rightly pursue the incompatible goals, and each knows that they are both so doing.

Given externalist consequentialism, where the right action is the one that actually would produce better consequences, ideal competition will be extremely rare, since the only time the pursuit of each of two incompatible goals will be right is if there is an exact tie between the values of the goals, and that is extremely rare.

This has the odd result that on externalist consequentialism, in most sports and other games, at least one side is acting wrongly. For it is extremely rare that there is an exact tie between the values of one side winning and the value of the other side winning. (Some people enjoy victory more than others, or have somewhat more in the way of fans, etc.)

On internalist consequentalism, where the right action is defined by expected utilities, we would expect that if both sides are unbiased investigators, in most of the games, at least one side would at take the expected utility of the other side’s winning to be higher. For if both sides are perfect investigators with the same evidence and perfect priors, then they will assign the same expected utilities, and so at least one side will take the other’s to have higher expected utility, except in the rare case where the two expected utilities are equal. And if both sides assign expected utilities completely at random, but unbiasedly (i.e., are just as likely to assign a higher expected utility to the other side winning as to themselves), then bracketing the rare case where a side assigns equal expected utility to both victory options, any given side will have a probability of about a half of assigning higher expected utility to the other side’s victory, and so there will be about a 3/4 chance that at least one side will take the other side’s victory to be more likely. And other cases of unbiased investigators will likely fall somewhere between the perfect case and the random case, and so we would expect that in most games, at least one side will be playing for an outcome that they think has lower expected utility.

Of course, in practice, the two sides are not unbiased. One might overestimate the value of oneself winning and the underestimate the value of the other winning. But that is likely to involve some epistemic vice.

So, the result is that either on externalist or internalist consequentialism, in most sports and other competitions, at least one side is acting morally wrongly or is acting in the light of an epistemic vice.

I conclude that consequentialism is wrong.

Wednesday, February 9, 2022

Game Boy Fiver [Wordle clone]: How to compress 12972 five-letter words to 17871 bytes

Update: You can play an updated version online here in the binjgb Game Boy emulator. This is the version with the frequency-based answer list rather than the official Wordle list, for copyright reasons.

There is a Game Boy version of Wordle, using a bloom filter, a reduced vocabulary and a reduced list of guess words, all fitting on one 32K cartridge. I decided to challenge myself and see if I could fit in the whole 12972 word Wordle vocabulary, with the whole 2315 word answer list. So the challenge is:

  • Compress 12972 five-letter words (Vocabulary)

  • Compress a distinguished 2315 word subset (Answers).

I managed it (download ROM here), and it works in a Game Boy emulator. There is more than one way, and what I did may be excessively complicated, but I don’t have a good feel for how fast the Game Boy runs, so I did a bit of speed optimization.

Step 0: We start with 12972 × 5 = 64860 bytes of uncompressed data.

Step 1: Divide the 12972 word list into 26 lists, based on the first letter of the word. Since in each list, the first letter is the same, we now need only store four letters per word, along with some overhead for each list. (The overhead in the final analysis will be 108 bytes.) If we stop here,

Step 2: Each four letter “word” (or tail of a word) can be stored with 5 bits per letter, thereby yielding a 20 bit unsigned integer. If we stop here, we can store each word in 2.5 bytes, for a total of 32430. That would fit on the cartridge if there was no code, but it is some progress.

Step 3: Here was my one clever idea. Each of the lists of four letter “words”, is in alphabetical order, and encoded the natural way as 20 bit numbers, the numbers will be in ascending order. Instead of storing these numbers, we need only store their arithmetical differences, starting with an initial (invalid) 0.

Step 4: Since the differences are always at least 1, we can subtract one from each difference to make the numbers slightly smaller. (This is a needless complication, but I had it, and don’t feel like removing it.)

Step 5: Store a stream of bytes encoding the difference-minus-ones. Each number is encoded as one, two or three bytes, seven-bits in each byte, with the high bit of each byte being 1 if it’s the last 7-bit sequence and 0 if it’s not. It turns out that the result is 17763 bytes, plus 108 bytes of overhead, for a total of 17871 bytes, or 28% of the original list, with very, very simple decompression.

Step 6: Now we replace each word in the alphabetically-sorted Answers list with an index into the vocabulary list. Since each index fits into 2 bytes, this would let us store the 2315 words of the Answers as 2315 × 2 = 4630 bytes.

Step 7: However, it turns out that the difference between two successive indexes is never bigger than 62. So we can re-use the trick of storing successive differences, and store the Answers in 2315 bytes. (In fact, since we only need 6 bits for the differences, we could go down to 1737 bytes, but it would complicate the code significantly.)

Result: Vocabulary plus Answers goes down to 108+17763+2315=20186 bytes. This was too big to fit on a 32K cartridge using the existing code. But it turns out that most of the existing code was library support code for gprintf(), and replacing the single gprintf() call, which was just being used to format a string containing a single-digit integer variable, with gprint(), seemed to get everything to fit in 32K.

Example of the Vocabulary compression:

  • The first six words are: aahed, aalii, aargh, aarti, abaca, abaci.

  • Dropping the initial “a”, we get ahed, alii, argh, arti, baca, baci.

  • Encoding as 20-bit integers and adding an initial zero, we get 0, 7299, 11528, 17607, 18024, 32832, 32840.

  • The differences-minus-one are 7298, 4228, 6078, 416, 14807, 7.

  • Each of these fits in 14-bits (two bytes, given the high-bit usage), with the last one in 7-bits. In practice, there are a lot of differences that fit in 7-bits, so this ends up being more efficient than it looks—the first six words are not representative.

Notes:

  • With the code as described above, there are 250 bytes to spare in the cartridge.

  • One might wonder whether making up the compression algorithm saves much memory over using a standard general purpose compressor. Yes. gzip run on the 64860 bytes of uncompressed Vocabulary yields 30338 bytes, which is rather worse than my 17871 byte compression of the Vocabulary. Plus the decompression code would, I expect, be quite a bit more complex.

  • One could save a little memory by encoding the four-letter “words” in Step 2 in base-26 instead of four 5-bit sequences. But it would save only about 0.5K of memory, and the code would be much nastier (the Game Boy uses library functions for division!).

  • The Answers could be stored as a bitmap of length 12972, which would be 1622 bytes. But this would make the code for generating a random word more complicated and slower.

Saturday, July 10, 2021

Reading a Game Boy Tetris cartridge

I saw a small rectangular PCB on the sidewalk not far from my house. It looked interesting. I left it for a couple of days in case someone lost it and returned for it. A web search showed it was the PCB from a Game Boy cartridge. Eventually, I took the PCB home, and made it a challenge to extract the data from it with only the tools I had at home and without harming the PCB (so, no soldering).

This PCB was from a ROM-only cartridge, 32K in size (I was able to identify it from the part number and photos online as likely to be Tetris), so it should have been particularly easy to read. The protocol is described here.

While the Game Boy cartridges run at 5V, the only microcontroller I had available with enough GPIOs  and ready to use was an stm32f103c "black pill" which runs at 3.3V. Fortunately, it has a number of 5V-tolerant GPIOs, so there was some hope that I could run the cartridge at 5V and read it with the microcontroller.

The Game Boy I didn't have a cartridge connector, but fortunately the PCB had plated through-holes on all but two of the lines, and they fit my breadboard jumper wires very nicely. I used test clips for the remaining two lines (VCC and A0). After some detours due to connection mistakes and a possibly faulty breadboard or GPIO, I ended up with this simple setup (what a mess on the breadboard!).

1. Connect D0-D7 on the cartridge to 5V-tolerant inputs, connect A0-A14 on the cartridge to outputs, ground GND, A15 and RD (CS and RS were not connected to anything on the cartridge), and connect VCC to a power supply (it turned out that all my worries about 3.3V/5V were unnecessary: supplying 3.3V, 4.5V or 5V all worked equally well). 

2. Write a 15-bit address to A0-A14. Wait a microsecond (this could be shaved down, but why bother?). Read the byte from D0-D7. Increment address. Repeat. Check the header and ROM checksums when done. Arduino code is here.  (I just copied and pasted the output of that into a text file which I then processed with a simple Python script.)

It works! I now have a working Tetris in an emulator, dumped from a random PCB that had been lying on the sidewalk through torrential rains!

I've played many versions of Tetris. This one plays very nicely.

Some technical notes:

  • I got advice from someone to set pulldown on the D0-D7 lines. Turns out that makes no difference.
  • Cartridges that are more than 32K would need some bank switching code.

Wednesday, June 30, 2021

Android Shogi app with Bonanza engine

I updated an old Android Shogi (Japanese chess) app that uses the Bonanza engine to work better with newer devices (and I also simplified it a bit). I also added optional animal-themed pieces (like in Dobutsu Shogi in the Greenwood) as that's what I'm more used to from playing with my kids.

Google Play: https://play.google.com/store/apps/details?id=mobi.omegacentauri.shogi

APK: https://github.com/arpruss/AndroidShogi/tree/main/app/release

Source Code: https://github.com/arpruss/AndroidShogi

[Note: the Bonanza engine is for non-commercial use only]



Wednesday, July 15, 2020

Gamifying planking

There is research that some video games can relieve pain. And boredom saps endurance. So the Stealth board product which lets you play games on your smartphone while doing core exercise on a specially shaped balance board seems to be a rather fine idea. But it's too expensive for me. So instead I cut a foam overlay with a phone slot and put it on my home-made balance board (with grippy skateboard tape). And the two free games for the Stealth board work great with this (I haven't bought their premium games).


Trivial Instructable here.

Result: I can plank more time on this than I can endure ordinary planking. Admittedly, the fact that the games involve some motion make the exercise less static. But it's still probably good core exercise.

Monday, June 15, 2020

Multidimensionality of game scoring

One obvious internal good of a game is victory. But victory generally isn’t everything, even when one restricts oneself to the internal goods. Score is another internal good: it is internally better to win by a larger amount—though a narrower victory (but not so narrow that it look like it was just a fluke) is typically externally more enjoyable. Similarly, there can be the additional internal good—often created ad hoc—of winning without making use of some resource—winning a video game without killing any character, or climbing a route while using only one hand. But there are other internal goods that are not just modifications of victory. For instance, in role-playing games, being true to your character’s character is an internal good that can be in conflict with victory (this is important to the plot of the film The Gamers: Dorkness Rising). There is an honor-like internal good found in many games: for instance, in versions of cut-throat tennis with rotation, it makes sense to throw a game to prevent your doubles partner from winning—but it would feel dishonorable and like poor sportsmanship. Elegance and “form” are other internal goods found in many sports.

Enumerating these internal goods would be an endless task. Probably the better thing to do is to say that we have the normative power of creating a plurality of internal-value partial orderings between possible playthroughs and labeling them as we wish, often using terms that provide an analogy to some external value comparison: “more honorable than”, “more peaceable than”, “more victorious than”, “more elegant than”, etc.

Sunday, May 24, 2020

Wii Remote Lightgun

The Wii Remote sort of works like a lightgun, but not quite. It has a camera that can track four infrared LEDs, but the LEDs it uses are normally arranged in a straight line in the Wii sensor bar, which is mathematically insufficient for figuring out where exactly the Wii Remote is pointed. If, however, we put two infrared LEDs on top of a TV and two on the bottom, then one could use homography calculations to figure out where the Wii Remote is pointing, and use it as a lightgun. I wrote some code for my Raspberry PI that does this, and together with a 3D printable handle and sights the Wii Remote becomes a nice lightgun for retro games. Instructions are here.


Monday, May 18, 2020

Wobble board, gamified

Last year, I made an adjustable wobble board for balance practice: a plywood disc with a 3D-printed plastic dome rocker. One thing that I always wanted was some sort of a device that would measure how long I was staying up on the board, detecting when the board edge hit the ground. I imagined things like switches under the board or even a camera trained on the board.

But what I forgot is that I already carry the electronics for the detection in my pocket. A smartphone has an accelerometer, and so if it’s placed on the board, it can measure the board angle and thus detect the edge’s approximately touching the ground. I adapted my stopwatch app to start and stop based on accelerometer values, and made this Android app. Now all I need to do is lay my phone on the board, and when the board straightens out the timer starts, going on until the board hits the ground. There are voice announcements as to how long I’ve been on the board, and a voice announcement of the final time.

Source code is here.

Instructions on building the wobble board and links to the 3D printable files are here.

One forgets how many things can be done with a phone.

I think my best time is just under a minute, with the board set to a 19 degree maximum angle.

Gamification

Most philosophers don’t talk much about games. But games actually highlight one of the really amazing powers of the human being: the power to create norms and to create new forms of well-being.

Lately I’ve been playing this vague game with vague rules and vague non-numerical points when out and about:

  • Gain bonus points if I can stay at least nine feet away from non-family members in circumstances in which normally I would come within that distance of them; more points the further away I can be, though no extra bonus past 12 feet.

  • Win game if I avoid inhaling or exhaling within six feet of a non-family member. (And of course I have to be careful that the first breath past the requisite distance be moderate in size rather than a big huff.)

When the game goes well, it’s delightful, and adds value to life. On an ordinary walk around campus, I almost always win the game now. Last time I went shopping at Aldi, I would have won (having had to hold my breath a few times), except that I think I mumbled “Thank you” within six feet of the checkout worker (admittedly, if memory serves, I think I mumbled it quietly, trying to minimize the amount of breath going out, and then stepped back for the inhalation after the words; and of course I was wearing a mask, but it's still a defeat). Victory, or even near-victory, at the social distancing game is an extra good in life, only available because I imposed these game norms on myself, in addition to the legal and prudential norms that are independent of my will. Yesterday, I think I won the game all day despite going on a bike ride and a hike, attending Mass (we sat in the vestibule, in chairs at least nine feet away from anybody else, and the few times someone was passing by I held my breath), and playing tennis with a grad student. That's satisfying to reflect on. (At the same time, playing a game also generally adds a bit of extra stress, since there is the possibility, and sometimes actuality, of defeat. And it's hard to concentrate on the Mass while all the time looking around for someone who might be approaching within the forbidden distance. And, no, I didn't actually think of it as a game when I was at Mass, but rather as a duty of social responsibility.)

I think the only other person in my family who has gamified social distancing is my seven-year-old.

Friday, August 16, 2019

Why do the basic human goods hang together as they do?

According to prominent Natural Law theories, the human good includes a number of basic non-instrumental goods, such as health, contemplation, truth, friendship and play. Now, there is a sense in which the inclusion of some items on the list of basic goods is more puzzling than the inclusion of others. There does not seem be anything deeply mysterious about the inclusion of health, but the inclusion of play is puzzling.

Yet there is an elegant metaphysical explanation of why these goods are included in the human good, and this explanation works just as well for play as for health:

  1. The human good includes play (or health) because it is a fundamental telos in the human form to pursue play (or health).

This explanation tells us what makes it be the case that play is a basic human good. But I think it leaves something else quite unexplained. Compare to this the unhelpfulness of the answer

  1. Because its molecules have a high mean kinetic energy

to the question

  1. Why is my phone hot?

Now, in the case of my hot phone, the reason (2) is unhelpful is because when I am puzzled about my phone being hot, I am puzzled about something like the efficient cause of the phone’s heat, and (2) does not provide that.

That’s not quite what is going on the case of play. When we ask with puzzlement:

  1. Why is play a basic non-instrumental human good?

we are not looking for an efficient cause of play being a basic human good. Indeed, it is dubious that there could even be an efficient causal answer to (4), since it seems to be a necessary truth that play is a basic human good, since this is grounded in the essential teleological structure of the human form. I think that when we ask (4), we are not actually clear on what sort of an explanation we are looking for—but if the puzzlement is the kind I am thinking about, the desired explanation is not the one given by (1).

We do become a bit less puzzled about play being a basic human good once it is pointed out to us how play promotes various other human goods like health and friendship. When we ask questions like (4), a part of what we are looking for is a story of how play hangs together with the other basic goods. If, as many Natural Lawyers think, there is a greatest human good (e.g., loving knowledge of God), then we hope that a significant part of the story will tell us how the good of play fits with that greatest good.

But now we have a curious meta-question:

  1. Why is it that telling a story about how play hangs together with the other basic goods contributes to an answer to (4), given that play’s promotion of other basic goods seems to only make play be an instrumental good?

Here is another part of the story that helps with (5). Not only does engaging in play promote the other goods, but engaging play as an end in itself promotes the other goods more effectively. Playing Dominion with a friend purely instrumentally to friendship just wouldn’t promote friendship as effectively as playing in a way that appreciates the game as valuable in and of itself. Thus, a part of our story is now that it would be beneficial vis-à-vis the other goods if play were in fact to be non-instrumentally good, as then it could be pursued as an end in itself without this pursuit being a perversion of the will (it is, I take it, a perversion of the will to pursue mere means as if they were ends).

But it is still puzzling why even this enriched story is an answer to our question. The enriched story might make us wish that play were intrinsically good, but it doesn’t make play be instrinsically good. How does the enriched story help with our question, then?

I think that here is one of those places where Natural Law needs theism. It is a good thing for God to make beings whose basic goods exhibit unity in diversity. Thus, amongst the infinity of possible kinds of beings that could have been created, God chose to create beings with the human form in part because the basic goods encoded in the teleological structure of that form hang together in a beautiful way. God could have instead created beings where play was merely instrumentally good, but the teleological structure of such beings, first, wouldn’t exhibit the same valuable unity in diversity and, second, such beings would not as effectively achieve the other basic goods: for either they would be perversely pursuing a means as an end, or they would be missing out on the benefits of pursuing play as an end.

In other words, the story about how the goods hangs together provides a genuine answer to questions like (4) given God’s wise selection of the natures to be instantiated. It is difficult to see a plausible alternative story (here's an implausible one: there are no possible natures where goods don't hang together; here's another implausible one: we live in the best of all possible worlds). Thus, answering questions like (4) seems to call for theism.