My latest project was to write a Python program to run the card game Flip 7. Flip 7 is a simple push your luck game. This was a very simple task, but there were reasons I did it.
In Flip 7 you either hit and get a new card or stay and score the points you’ve accumulated this turn. If you get a new card you might bust and lose all the points from this turn. You bust when you draw a pair. The trick is that the cards go from 1 to 12, and the number of a given rank in the deck is equal to the rank itself. So there are twelve 12s in the deck, eleven 11s, ten 10s, and so on. The more valuable a card is, the more risky it is. The name comes from flipping seven number cards, which ends the turn for everyone and gives you 15 bonus points. There are also some bonus card and three action cards (second chance, freeze, and flip 3) to make things a little more interesting.
Like I said, not that complicated a game, not that hard to program. It only took me a week to program, at lazy retired guy pace. Of course, it would have been easier to program if I had actually bothered to do any planning before I started programming. But as usual I just wanted to dive right in. Which lead to a couple of rewrites and some internal communication that I’m not happy about. If I were to rewrite it a third time (and I probably will) I would correct the problem of everything needing access to the card deck by passing around a game state object. This would also give information needed for the various human and robot players to make their decisions.
The reason I started such a simple project is that I have been doing far too many complicated projects. I just came off the Thinking, Fast and Slow project, which was an incredible slog with a fart at the end. Then I went right into a huge programming project that left me too exhausted to make use of it, and then writing a whole new roleplaying game, and a rather complicated on at that. 160 pages in I realized that I wasn’t enjoying myself. And I had resolved after Thinking, Fast and Slow to do more things that I enjoyed.
I also realized I was pushing myself too hard with these big projects. I have noticed a tendency in my life to push myself harder and harder until I can’t keep up with how hard I am pushing myself. Then it all falls apart, and I fall apart, and spend a few weeks being horribly depressed. This whole 25 Year Plan was meant to even that out, and dialing it back was a big reason for doing such a simple program.
There is also another thing I can do with this program. A while back I saw a thread online about favorite packages people have when programming Python. Now, I’ve been programming Python for almost 25 years. I have my own particular style, and I am willing to admit that the way I do a lot of things may be outdated. So I pulled a list of more “modern” packages from that thread I saw, and I’m going to try to implement each one on this small program I just finished.
It certainly needs the new testing framework I’m looking at. I’ve programmed simulations of Flip 7 before, to test out different strategies. But while programming this version I noticed problems that may have slipped by with the simpler simulations. And that means there may be subtler errors in this code that need a full test suite to dig up.