How to play turbo hearts

The game is a slight variation on regular Hearts, with a few cards having extra meaning, the possibility for a trick to go around twice, and “special” cards being “charged” (doubling their value). In Turbo Hearts, points are bad.

In Turbo Hearts, the 10♣ doubles your score final score, the J♦ gives you -10 points (good), the Q♠ is worth 13 points, and each heart is worth 1 point. “Running” is defined as taking the Q♠ and all of the hearts. This is equivilant to “shooting the moon” in regular hearts. Nines are also special in Turbo Hearts; if they are played in suit, they make a trick go around twice. Charging is a technique that happens before a hand begins that has a few effects:

  • The charged suite is now worth double. A charged Q♠ is now worth 26pts, a charged A♥ makes all hearts worth 2pts, a charged 10♣ is worth 4x your final score, and a charged J♦ is worth -20pts.
  • The charged card must be placed face up in front of the player until they play it
  • There is a caviate to charging a card however, you cannot play a charged card on the first trick in suit unless you are forced to do so. An example: You charge the 10♣ and the only other club you have is the 9♣. On the first club trick, you cannot play the 10♣ since you have another club, so you play your 9, making the trick go around again. Now, you have to play a second time and since your 10♣ is the only card in suit, you must play that card.

The game consists for 4 hands with the flow of the game as follows:

  1. Passing – in order of the 4 hands: 3 left, 3 right, 3 diagonal, no passing.
  2. Charging – anyone with a chargeable card (10♣, Q♠, J♦, A♥) can now charge.
  3. Play starts – the person with the 2♣ plays first.
  4. Tricks – gameplay continues until all tricks have been claimed
  5. Scoring – scoring is tabulated and saved for later; more details below

Scoring may be the most complicated part of playing Turbo Hearts but it is really easy once you get the hang of it. Scoring is performed by totally up everyones points, multiplying if they got the 10♣, making negative if they “ran” and totally it up with the previous tricks. We keep a notebook of scores, with each hand taking a line, the hand total on the left and the cumulative sum on the right. Negatives are wrapped in parens. It looks like this:

RF TW KB EA
0 – 0 0 – 0 72 – 72 11 – 11
16 – 16 32 – 32 (10) – 62 16 – 27
12 – 18 4 – 45 16 – 78 16 – 43
0 – 18 0 – 45 0 – 78 (248) – (205)

These are your hand scores and as you can see, I did really well on the last hand (ran for 248 pts!)

These scores are then kept cumulatively across multiple games and multiple players. Your final game score is calculated by “paying out”. What this means, is your total number of points, you must pay to all other players (and they must pay to you). It is good to have a low hand score but the opposite is true for a game score; higher scores are better.

So the final games scores are:

RF -18*3 + 35 + 78 – 205 =  -146
TW -35*3 + 18 + 78 – 205 =  -214
KB -78*3 + 18 + 35 – 205=  -386
EA 205*3 + 18 + 45 + 78 =  756

We keep these numbers are a long term tally. You can just sum up everyones game scores to see their standings.

The best way to think of these game scores is as pennies. In this game, I would be making $7.56 while the others would be paying out $1.46, $2.14, $3.86 respectively.

In my next post, I will lay out some basic strategy, but now you know how to play.

Archiving a message via keyboard shortcut in Microsoft Entourage

This has been driving me nuts for a long time and I finally figured out the applescript for this so I figured I should share.

The script is:

This script assumes you have an exchange account and a folder in that exchange account you want to use.

If you want to use an archive folder that is a subfolder of another folder, you’ll want to tweak the script to say something like “to folder archiveFolderName in folder parentFolderName in Exchange account exchangeAccount” and add a parentFolderName variable to the top of the script.

Now all you have to do is save the script in: “~/Documents/Microsoft User Data/Entourage Script Menu Items/Archive\cA

This will put it in your script menu and set the keystroke ctrl+a to “Archive”.

Enjoy!

Rant: Using error codes in user messages

In short: DON’T!

What in the world was Apple thinking when you try to upgrade/register/sync your iPhone/iPod and you get “Error: -19″ or “Error: -20″?? What good does this do any one? How am I supposed to fix the problem if I don’t know what the problem is? Isn’t Apple the king of user-friendliness?

When you write software, you should use good error messages. You should use good exceptions. You should use descriptive values.

Granted, some things the user cannot fix. Telling the user the database connection was lost on a web application does very little good for the user. You can however tell the user that an error that was not their fault occurred. At least then I know I can come back and try again later.

Luckily, after rebooting my iPhone I was able to install the recent software update. This may not have been the problem, but certainly Apple could have notified me that I should attempt rebooting.

In any case, be nice to your damn users!

Tagged: , | Posted August 5, 2008

Using EclEmma to write better unit tests

If you don’t already write unit tests you should be. (Hey, why aren’t you writing unit tests?) Unit testing has so many benefits and the upfront developer cost to write some unit tests can pay huge dividends later when you aren’t spending time debugging broken code nor attempting to save face due to clueless mistakes. You can also use them as a contract to the expectations of your implementations.

So, assuming you have some unit tests, how useful are they if they don’t test everything? At some level you will want to have a good idea that you’re testing everything. (NOTE: I mean everything really important. Writing perfect 100% coverage like this would likely be too expensive for the entire codebase.) This is where Emma comes in (and more importantly for us, EclEmma, an Eclipse plugin for Emma). Emma is a code coverage tool which lets you visual which parts of your code get executed during some execution (regular or JUnit).

Lets walk through using EclEmma to ensure that we have adequate testing being done. Lets test the following two classes.

GuessTheNumber.java:

And SequentialStrategy.java:

Finally, we’ll write up a basic StrategyTest.java:

So the question is, how good is our test? If you installed EclEmma, you can right click on your Unit Test in Eclipse, head to “Coverage As” -> “JUnit Test”

This will run your unit test against your code and when complete, highlight the code green, yellow, or red for covered, partially-covered, and not-covered respectively.

According to EclEmma, our code coverage when running StrategyTest is:

Thats not too bad, lets take a look at the output for SequentialStrategy:

We may want to test the IllegalStateException since we currently don’t and we are expecting it to happen if we’ve guessed everything between min and max and haven’t solved the problem. This would ensure if someone else comes in behind us and changes this code, the unit test will fail if they take that out and change it to return, say, Integer.MIN_VALUE.

Lets also take a look at some of GuessTheNumber:

It appears we also want the contract to include an IllegalStateException being thrown if you have already solved the guessing game. It also looks like we don’t ever call resetCount() and possibly retest after doing that. We also never check if getValue() fails prior to having a solution.

If we modify the test slightly to:

And now our code coverage is:

I know this was a very basic example that really didn’t test any complex logic or conditions, but I hope it gives you a good idea of how you can use code coverage to improve your unit tests.