Wed 21 December 2022
Kristin and I have been playing Sixty-Six for quite a few years now. We learned it from the Hoyle book when we were looking for a good card game for two. It fits the bill well, having something of a Euchre pace and vibe - quick-paced, easy to play and fun.
About a year ago I was bored (you know, winter!) and went looking for an online version of 66 that I could play by myself against the computer. I was not impressed with what I found. Some games clearly cheated, some did not implement the rules fully, or there were other flaws.
Being the computer geek I am, I decided that I could do better, and began writing a 66-playing game. I chose to use Lua, my favorite little language, as a way to become an even better Lua programmer. I also wanted to try my hand at machine learning, but as I learned more about that, I realized I needed to be able to evaluate the quality of play, which meant that I would have to implement brute-force play as well (and there's lots of detail on this that doesn't really matter for this discussion). And on top of all that, I wanted to make it network playable so that Kristin and I could play each other using the computer, or play individually against the computer; that effort turned out to be a ton of work that was harder than I anticipated, and it didn't get finished.
Over a couple months of puttering and coding, I ended up with a command-line computer game that was surprisingly quite good. It was so good in fact that I learned some new strategy that I had not previously known about, and which I used on Kristin to good effect until she learned it after I trounced her a few times. The game play snip below shows what it looks like.
As last winter came to and end, and we started getting busy with house selling and other stuff, I set the code aside. Since then I've given the code some occasional thought, and sometimes looked over it a bit, and realized that I had quite tangled the game engine code, which captures the rules and mechanics of play, with the computer play part. I also thought I might approach the networking in a different way. Eventually, I thought maybe I should take another run at it, so a couple weeks ago, when I started getting bored (you know, winter!), I jumped back in.
At this point I've rewritten most of the core game engine, and have started testing. There's not a lot to show yet, but it's looking good. I'll write more about it as the effort advances.
Output from new code
Deal object: lead: Phil follow: Kristin closed: false done: false carry: 0 p1: Player object: Phil hand: K♠ 9♠ K♣ T♥ 9♥ K♦ GP: 0 TP: 0 MP: 0 DCL:---- p2: Player object: Kristin hand: T♠ J♣ A♥ Q♥ A♦ T♦ GP: 0 TP: 0 MP: 0 DCL:---- stock: J♦ 9♣ A♣ T♣ Q♠ A♠ J♥ 9♦ K♥ Q♣ J♠ Q♦ trump: Q♦ 9♦ play: nil dead: nil remarks: testing... testing...
Game play from last year's code
++++++++++++++++++++++++++++++++++++++++ PLAYING ROUND 1 ++++++++++++++++++++++++++++++++++++++++ predicted winner: p(Phil) = 0.501 p(Computer) = 0.499 Phil's advantage = 0.003Phil GP: 0 TP: 2 MP: 0 Computer GP: 0 TP: 0 MP: 0 dead cards: J♣ 9♠ carry points: 0 trump card: J♥ ---Phil--- Q♠ 10♣ 9♣ A♥ 9♥ 9♦ lead: -A- -B- -C- -D- -E- -F- swap nine of trump: -M- declare close: -N- Select an option --> m Phil exchanges the nine of trump ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Phil GP: 0 TP: 2 MP: 0 Computer GP: 0 TP: 0 MP: 0 dead cards: J♣ 9♠ carry points: 0 trump card: 9♥ ---Phil--- Q♠ 10♣ 9♣ A♥ J♥ 9♦ lead: -A- -B- -C- -D- -E- -F- declare close: -N- Select an option -->
Phil GP: 0 TP: 0 MP: 0 Computer GP: 0 TP: 0 MP: 0 dead cards: carry points: 0 trump card: J♥ ---Phil--- 9♠ 10♣ 9♣ A♥ 9♥ 9♦ lead: -A- -B- -C- -D- -E- -F- swap nine of trump: -M- declare close: -N- Select an option --> a Phil leads 9♠ ---Computer--- thinking... Computer follows with J♣ Phil wins this trick Press Enter to continue... discard and draw