Saturday, February 26, 2011

Cribbage

Cribbage is a fun card game. In it, you're dealt six cards, and you have to discard two. Afterwards, a starter card is drawn. The four cards you're left with and the starter card determine how many points your hand has. (There's of course more to the game than just that, but that's what's relevant.)

The scoring works like this:
His nobs - If you have a jack of the same suit as the starter card, that's 1 point. (If that starter card is a jack, that's something different and gets counted at a different time.)
Flush - If your hand has all cards the same suit, that's 4 points. If the starter card is the same suit too, that's another 1. After this, there's no difference between the starter card and the ones in your hand.
Pairs - For each pair you have, you get two points. Note that cards can be counted multiple times, so if you have a 4H, 4D, 4S, that's three pairs (4H, 4D), (4H, 4S) and (4D, 4S) for 6 points.
Straights - If you have three or more cards in a row (like 3, 4, 5) you get as many points as the straight is long. Personally, this seems somewhat inconsistent, since a straight of four is also two straights of three, which would get you 6 points instead of 4.
Fifteens - For each sum of fifteen you can make, you get 2 points. All face cards count as ten. Cards can again be counted multiple times, so if you have two tens, and two fives, that's four fifteens for 8 points.

Anyway, I was curious as to what the average hand value would be if you always discarded so as to give your hand as many points as possible (which you don't actually always want to do, because of other parts of the game, but oh well). So I made a program which goes through all 20,358,520 possible hands of six you can be dealt, and finds the best two to discard, taking into account the different possible starters cards.

All told, it ended up running for about 18 days. But it did finish. And here are the results.

The average hand value is 8.29 points.

The most frequently discarded rank is king at 11.56% of all discards.
After that is queen at 9.85%
8 at 9.30%
7 at 8.85%
Ace at 8.78%
9 at 8.37%
2 at 8.27%
10 at 8.02%
3 at 6.72%
6 at 6.55%
Jack at 6.14%
4 at 5.39%
5 at 2.17%

Wednesday, February 2, 2011

The Ship of Theseus a.k.a. Grandfather's Axe

There's an old philosophical puzzle. Suppose you have a wooden boat. You notice some of the planks are getting rotten, so you replace them. Is it still the same boat? As time goes on, you replace the planks one by one, until every single plank making the boat has been replaced. Is it still the same boat?

Alternatively, your grandfather's axe is a family heirloom. But when your father got it, he replaced the head, and when you got it, you replaced the handle. Is it still the same axe?

I posit that identity cannot be determined by the identities of the constituent parts.

First, I'll assume that identity is something that can be discerned - that is it's something that can be determined by observation. Intuitively, this makes sense. If you see two boats, you can distinguish them by how they look, even if they switch positions, or change by small amounts. Even if you have two boats made the same, there will be minute differences that can distinguish them. And the same with the planks. You can tell two planks apart.

But the fundamental constituents of matter have no such identity. An electron is an electron is an electron. All electrons are indistinguishable, and provably so. If you had an electron, and you put it in a box full of other electrons, it would not be possible to find your initial electron again. In fact, there isn't such a thing. Initially, there was one electron in your hand, and many electrons in your box. Then there were many+1 electrons in your box. The one electron cannot be uniquely tracked. It has no identity.

What this means is that if you have, say, a hydrogen atom, and then instantaneously swap out the electron with a different one... Then nothing has changed. Nothing has been done. If that hydrogen atom had an identity, it could not have changed, even if every single subatomic particle in it had been swapped at the same time.

On the macroscopic scale, things can have identity, because they aren't indistinguishable. They have different particles in different configurations following different patterns.

Identity is one of those things that makes sense in our experience, but which breaks down in extreme thought experiments because it has no fundamental truth to it and our flawed conceptions were only meant to work with what we have experience with.

Saturday, December 25, 2010

Capitalism Opposes Progress

No, not all progress. And it can be a very powerful engine for innovation. But there is progress it opposes. In particular, scarcity, or rather, the end of it.

Capitalism requires scarcity to work. If you have unlimited amounts of something, its supply is infinite, and its value is 0. No one would pay for something they can just effortlessly pick off of a tree. And because you can't make a profit off of it, capitalism will never attempt to end scarcity, and will oppose anyone who does.

And it has. Even though we don't have the technology to end physical scarcity (Well, not completely anyway. If it weren't for stupid political situations, we could easily feed every human on the planet.), there's no reason we can't end digital scarcity. Any kind of digital information is just a string of 1s and 0s and can be copied infinitely, for free. But capitalist forces such as the RIAA oppose that kind of thing tooth and nail.

The only reason that someone who wants it shouldn't be able to get it for free is that the person who made it couldn't get paid. I'm not saying that that person shouldn't get compensated for their effort, but the capitalist model clearly isn't be the most efficient way. And sometimes, people aren't looking for compensation. Look at the open source movement. People make programs and then give them away for free. Hell, that's what I did with AlDraw.

Although the end of physical scarcity seems like science fiction now, I don't see why it would be impossible, and technology like RepRap is gradually taking us in that direction. But if Star Trek style replicators were invented tomorrow, they'd encounter exactly the same resistance that digital copying does today.

Tuesday, December 21, 2010

Earth's 23.4° Axial Tilt is the Reason for the Season

Both literally and metaphorically.

Earth's tilt physically causes the season, including of course, winter. When the northern (or southern) hemisphere is pointing at the sun, the longer days and more direct sunlight make it warmer. When it points away from the sun, the shorter days and less direct sunlight make it colder. Hence the seasons. The solstices are when the Earth is pointing most directly towards or away from the sun and they mark the transition between days getting shorter and days getting longer.

Earth's tilt is also the cause for the holiday season. Wikipedia lists no fewer than 36 celebrations related to the winter solstice, from cultures all around the world. And it's hardly surprising when you think about it. Even before the discovery/invention of the calendar, I'm sure it was clear to people that longer days were warmer days. Also, when the sun was up determined when you could go hunting and get things done. So the reversal of the shortening day must have been extremely important.

Among that list from Wikipedia are some holidays you might recognize. Saturnalia, Yule, Hanukkah, Christmas. Christmas isn't really any different from the others, and most of our celebrations of it don't have much of anything to do with Christianity. The Christmas tree for example, has roots in a pagan celebration.

Also, the date of Christmas has nothing to do with the story of Jesus's birth in the bible. The bible never gives a date, and it says that the shepherds are in the fields with their flocks, which they would only be during a warmer time of year. Most likely, the early church selected the date of Christmas to match a Roman holiday.

Jesus isn't the reason for the season, Earth's 23.4° axial tilt is.

Wednesday, December 8, 2010

Chance vs. Luck

Chance exists. Luck does not.

What's the difference?

Chance is merely unpredictability. Things happening for little or no reason. Bad things happening to good people. Winning the lottery, or getting cancer.

Luck is chance that takes sides. Chance that can be swayed by a charm, or a ritual or that's just attracted to some people over others.

It's more complicated in that people can get lucky, but they can't be lucky. Getting lucky just means that, by chance, something fortunate happened to you. You pulled the lever and got the jackpot. But being lucky would mean that you would actually be more likely to get the jackpot than other people who are not lucky.

AlDraw on SourceForge

Back in August, I said I was working on improving AlDraw. And I have been. Slowly, but surely.

And now, it's on SourceForge. https://sourceforge.net/projects/aldraw/

AlDraw-src.jar is, as your  might have guessed, all the source files. AlDraw.zip is contains an executable jar, among other things. All you need to try it out is java installed on your computer.

I'm still calling it a beta version. I've made significant progress, but there's still a ways to go. Particularly on the new features front. I've added hardly any of the features I've been wanting to. Most of my efforts have gone to the code design and usability goals. And fixing the things I broke while refactoring.

But it's in a workable, usable state now. Go try it out! And if you know Java, take a look at the code and tell me if it still looks like a total mess. It's released under GNU GPLv3 so you can copy, modify and redistribute it nearly however you like.