Do old ladies like Prolog?

First, an Old Lady update. I’ve implemented a small but important subset of Standard American bidding into the computer players’ AI, as seen below:

Old Lady screenshot

As can be seen from that screenshot, for bidding sequences that start with a trump bid at the 1 level, the computer player can go as far as the opener’s rebid before not knowing what to do; otherwise there’s no way East would have settled for a 1♠ contract given his utter lack of support. (I believe the correct next bid for East would have been 2 to deny a spades fit and signal extra length in hearts.) For the record, the deal was:

West: ♠AQ96 K 642 ♣AQ853
North: ♠10732 J64 3 ♣J10976
East: ♠J54 AQ10873 AK108 ♣Void
South: ♠K8 952 QJ975 ♣K42

The bidding system itself is currently specified as an XML file that describes all possible bids at each state, and the conditions that must be satisfied in order to make them. To give you an idea of what this looks like, here’s the fragment that told West to rebid 1♠:

<!-- Up-the-line at the 1 level -->
    <exists name="suit">
            <denomination-range low="open" high="closed">
        <integer value="1"/>
        <variable name="suit"/>
    <transition state="1-respond-again"/>
            <integer value="13"/>
            <integer value="18"/>
                <variable name="suit"/>
            <integer value="4"/>

In human terms, that says that if there’s a suit greater than the last suit the partner bid but no higher than spades, bid that suit at the 1 level if you have between 13 and 18 HCP and at least four cards in that suit. Specifying the bidding rules as data means that the Python code that decides what to bid and the Python code that figures out what the partner’s bid meant work together properly. In principle, the bid interpretation code will see that a bid of 1♠ fits this rule, telling the AI that partner has 13-18 HCP and at least four spades. In practice, though, all it does is tell which state to go into for that player’s next bid.

Getting information about a bid is trickier than might initially be expected. In particular, let’s say we’re East in the above game, and our partner West bid 1♠. From the above, it’s pretty obvious what we just learned about our partner’s hand. But what if West didn’t bid 1♠? Logically, by de Morgan’s law, we know that West either does not have 13-18 HCP, or West has fewer than four spades, or possibly both. If we later learn that West has 13-18 HCP, or that he has at least four spades, then we can conclude which one of those two things in the disjunction holds, but until then, we can’t really act on it. In fact, since West had opened with 1♣, we know he has at least 13 HCP, so we should be able to deduce that West lacks four-card support for hearts. In this case, at least.

Now consider that we have this information learned from what our partner didn’t bid for each bid the partner didn’t make that has a higher precedence than the bid he eventually made. Continuing our example, 1♠ wasn’t the first option West had. In the full XML file, we see that the other options were to bid 2, 3, or 4 if West had at least four hearts and HCP in the appropriate range. We can quickly build a list of potential information known about our partner’s hand, but it’ll usually be in the form of “either this is false or that is false, or both”.

Stepping back a bit, it’s clear that just keeping a simple list of information learned from our partner’s bids is insufficient. In fact, we need to do some amount of logical reasoning on it to learn new information. And futhermore, new bids can refine previous information. For example, an opening bid might indicate 13+ HCP, but a later bid might indicate 17-18 HCP. At first we knew partner’s HCP could be 15, but later on learned that it couldn’t. (Unless partner was lying or screwed up, of course, but the AI will assume your bids mean what the system says they do.) That later bid’s information in a sense supersedes what we learned earlier, even though they don’t contradict each other.

So, being a virtuous programmer (at least as far as the Camel Book is concerned), I want to be too lazy to write my own logic deduction engine if I don’t have to. I’m wondering if I might be able to pawn that work off on something written in Prolog.

Prolog is a logic programming language, which is inherently different than any programming languages you’re probably familiar with. Prolog is all about the logical deduction; you can give it facts and rules for deducing new facts, and it will do the leg work of figuring out if something can be proven as true or not. I’m certainly no expert on Prolog — most of my prior exposure to it is from having taken a class with a professor who was a fan of it, and liked to use it to demonstrate reference monitor decisions for access control — but it seems like it might be a good fit here. Maybe. I’ll have to work through some tutorials and actually, you know, learn Prolog a bit before knowing if it’s a good idea to try using it or not.

But even if the answer turns out to be “no”, I’ll still have learned some things about the logic programming paradigm, which is bound to be helpful in the future. Even if I never use Prolog, it’s good to be exposed to different ways of thinking about programming, just like learning functional programming can help you see new ways to solve problems even if you stick with object-oriented languages.

Or, if nothing else, you can use that kind of knowledge to write breathtakingly misguided code.

At least they’re apologetic

The past couple of weeks there’s theoretically been an uptick in the amount of spam hitting this blog. I say “theoretically” since it’s all getting caught by the spam filter.

All this spam takes the form of a meaningless one-word comment like “Nice” or “Cool” followed by a bunch of (often malformed) links apparently to some sort of automobile sites. I guess I’m supposed to believe the “Nice” or “Cool” makes it a legitimate comment or something.

Anyway, scrolling through the moderation queue to make sure nothing worthwhile got trapped, I noticed that for a few of them, the intro word was “Sorry :-(“.

Comments Off

HOWTO: Be a homeopathic bioterrorist

  1. Buy a carton of orange juice and 30 1-gallon jugs of water.
  2. Place one drop of orange juice into one of the jugs of water. Shake.
  3. Take one drop of that dilution and place it into the next jug of water. Shake.
  4. Take one drop of that dilution and place it into the next jug of water. Shake.
  5. Repeat the process until you reach the last jug of water.
  6. Take a drop of that final dilution and place it into your municipality’s water supply.
  7. Everyone gets scurvy!

Frequently Asked Questions


According to homeopathy, diluting a substance makes it more potent. While traditional homeopathy creates medicine by diluting harmful subtances, we can apply the same principles to weaponize healthy substances. Since orange juice has lots of vitamin C, a homeopathic dilution of orange juice would induce a crippling vitamin C deficiency in anyone who drank it.

How does diluting something make it more powerful?

Because some guy in the eighteenth century decided it does.

How does diluting something make it have the opposite effect it normally does?

Because that same guy decided it does.

Neither of those makes any sense.

I’m sorry, I didn’t know you were in the pocket of Big Pharma, you soulless corporate shill.

I mean, at that level of dilution, it’s unlikely there’s even a single molecule of orange juice in the water.

So? There doesn’t have to be. The water remembers what was in it.

How does that work, exactly?

Dissolved silica from the container. Or aerosols that get mixed in during shaking. Or quantum entanglement. Or friction with a fancy-sounding name. Which one sounds the most sciency? Because it’s that one. I was just joking about those other ones. Though they’re also true. Even though they’re mutually contradictory.

Is there any scientific evidence any of those are actually the mechanism?

Sure! I totally know a guy who knows a guy who tried it, and it totally worked.

No, I mean is there any scientific evidence? You know, double-blind tests and controls and null hypotheses and everything.

Well, no, not with those kinds of tests. It’s well-known that double-blind tests don’t work for homeopathy.

Why is that?

Why, since well-controlled double-blind tests of homeopathy always fail to show any difference between homeopathic treatments and placebo! Since we know homeopathy is true (as you’ll recall, some guy in the eighteenth century decided it’s true), that proves double-blind tests don’t work. Besides, so-called “scientists” are also all in the pocket of Big Pharma, just because if homeopathy were true it would invalidate everything they “know” about chemistry and medicine.

Wait, aren’t there trace amounts of just about any water-soluble compound you can think of in tap water? Shouldn’t the water that comes out of my faucet cure every ailment known to man?

No, that’s stupid.

Why is that?

The water didn’t get shaken the right way.

So there’s a special way you’re supposed to shake the water now?


Are you just making all this up to defend the ridiculous idea that homeopathy actually works?


How do I know you’re right?

You think selling bottled municipal tap water for $1 a bottle is a ripoff? Think of the margins on selling small amounts of water as medicine!

Equivalent to Mega Man 18

This video is simultaneously awe-inspiring and terrifying.

It’s a play-through of Mega Mans 3, 4, 5, and 6, simultaneously, using the exact same controller input for all four games. It’s tool-assisted, of course, but the mere fact this is even possible is impressive. I can’t even imagine how someone would go about figuring out how to pull this off.

If you’re not a fan of YouTube’s standard ruin-video-quality filter, there’s a much cleaner version of the video available too.