Tag bridge (3)
bridge update (or: programming is hard)
Posted on 2010-10-27 14:00:00
Tags: bridge projects programming
After vacation and traveling and such, I've been working on the bridge program again. I'm at the point in the webOS client where I can now play a complete hand, bidding and all. It even looks relatively nice with cards sliding around, things fading into view, etc. Ask me to show it off if you're interested sometime!
So the next task is adding the AI for playing cards. I've decided to go with a rule-based system, where there are a bunch of rules that can decide if they apply. So I have "second hand low" and "third hand high" rules that go near the end (since they're fairly generic).
Last night I tried to sit down and really hammer out the rule that applies if you can determine exactly what will be played. If you're the last player on the trick, this is relatively easy - see if your partner is winning, if not win as cheaply as you can, if so (or if you can't win) throw some trash.
Even this is a little vague - what card should I throw away? Well, if there's only one suit I can play it's easy, but if not then it's hard. So I put this off with a TODO.
The tricky part is if you're the third player on the trick and the fourth player is the dummy. Then it's something like: look at all dummy's cards and the declarer's card that was played (if it's currently winning), then see if I can beat all these. If so, play the cheapest. If not....well, we are in the third hand and we'd like to force dummy's best card if we can. So find dummy's second best card and see if we can at least beat that. If not...well, at least we should try to beat the current high card played by declarer. If we can't do that, then just toss something.
This took a while to code up, and I need to test it thoroughly because I'm very much not confident in it. And it still leaves a lot of details out - what if dummy has AK6 and I have the 57 - under the algorithm I'd play the 5 which is pretty clearly wrong. It seems like to handle this case I should have been keeping track of which cards are winners in their suit, which is another layer of complexity!
And all this is for a (all things considered) pretty simple case where I can see all the cards. I'd also like to keep track of how many cards of each suit each person has (based on the bidding), which would help but would also add enormous complexity.
Maybe the AI should cheat and see all the cards? Is there some better thing to keep track of?
It could be a long time before the game seems to play intelligently...
minnesota, civ 5, bridge
Posted on 2010-09-20 12:07:00
Tags: pictures bridge projects programming
I went to Minnesota last week on a recruiting trip and took a few pictures:
Civilization 5 is releasing tomorrow! The full manual is available online (warning: 233 page .pdf) and it look spretty good. I do miss having a paper manual, though.
I've been working on the bridge program for webOS. It's coming along nicely - the framework is all in place to bid and play, and I've done some of the graphical stuff so you can almost actually play a hand on the webOS emulator. The next big thing to do is the AI for bidding and playing, which will probably be big tasks. We're going to be fairly busy over the next month or two so I'm not expecting much progress for a while. (also, Civ 5 coming out certainly doesn't help :-) )
Eric Fischer took census data on race and mapped where people live in major cities. (here's Houston, Austin, and San Antonio) Some patterns definitely jump out at you, but if you zoom in you can see there's nowhere that's exclusively one race, which is a good thing.
Friday bridge math puzzle!
Posted on 2007-01-19 08:19:00
Tags: bridge math
onefishclappin forwarded me this fascinating puzzle yesterday, and I thought "Ooh, I should figure this out", then started thinking about it, then went back to work for about 5 seconds, then gave up and worked it out (roughly). Here it is:
After you've dealt out a hand, are there more different legal ways to play out the hand, or more ways to bid the hand?
Here, only legal plays and bids are counted, so no bids or plays out of turn, insufficient bids, revokes, etc. Other than that, the plays or bids don't have to make any particular bridge sense, they just have to be legal.
This backup was done by LJBackup.