Dominion Strategies

What is Dominion?

I was recently introduced to a game called Dominion. As any nerd would do, I wrote a program that pits different strategies against each other over thousands of games and collects statistics about how each strategy did. This is some early data.

Note that this entire post will only make sense if you know how to play the game.

Strategies

These are the three strategies I’ve coded so far:

  • BigMoney
    • Summary: Build up your buying power and buy provinces whenever you can
    • Action phase: No action cards to use
    • Buy phase:
      • If it has 0-2 buying power: Buy nothing
      • 3-5: Buy silver
      • 6-7: Buy gold
      • 8+: Buy province
  • 1Smithy
    • Summary: Do the same thing as BigMoney, but buy a smithy at the first opportunity
    • Action phase: Whenever the smithy is drawn, use it to draw 3 more cards
    • Buy phase:
      • 0-2: Buy nothing
      • 3: Buy silver
      • 4-5: If it has no smithies, buy one; otherwise, buy silver
      • 6-7: Buy gold
      • 8+: Buy province
  • GardenWorkshop
    • Summary: Using workshops to gain more cards, buy lots of cards to maximize the points from gardens
    • Action phase: Whenever a workshop is drawn, use it to:
      • Gain another workshop until there are no more
      • If there are no more workshops, gain a garden
      • If there are no more gardens, gain an estate
    • Buy phase:
      • 0-1: Buy copper
      • 2: Buy estate
      • 3: Buy workshop
      • 4+: If it has no workshop, buy one; otherwise, buy garden

Methodology

I pitted each of the strategies against each other over 10,000 games and plotted the results below.

  • The blue line shows the victory points of the first strategy as the games progressed
  • The red line shows the victory points of the second strategy as the games progressed
  • The green bars show how many games out of those 10,000 actually had that many turns. When the green bar is low, that means the blue and red lines don’t mean much because the sample size is small. This means that you should just pay attention to the blue and red lines up until the green bars start to fall below 10,000.

1Smithy vs. BigMoney

Deck stats:

1Smithy BigMoney
Average Buying Power: 32.8 36.1
Average Deck Size: 26 25.5

Turn and win stats:

Average Turns: 16.4185
Wins:
1Smithy: 4966 49.60%
BigMoney: 1745 17.40%
Ties: 3289 32.80%

GardenWorkshop vs. 1Smithy

Deck stats:

GardenWorkshop 1Smithy
Average Buying Power: 11.7 36
Average Deck Size: 38.1 28

Turn and win stats:

Average Turns: 19.517
Wins:
GardenWorkshop: 8808 88.00%
1Smithy: 1192 11.90%
Ties: 0 0.00%

GardenWorkshop vs. BigMoney

Deck stats:

GardenWorkshop BigMoney
Average Buying Power: 11.6 40.3
Average Deck Size: 38 28.1

Turn and win stats:

Average Turns: 19.5507
Wins:
GardenWorkshop: 9702 97.00%
BigMoney: 298 2.90%
Ties: 0 0.00%

Conclusion

BigMoney is a pretty good strategy. It can end the game pretty quickly and it racks up provinces pretty fast.

1Smithy improves on that by getting those extra cards when you draw the Smithy. I tried 2Smithy, 3Smithy, etc. but they all performed worse than 1Smithy.

I was surprised just how much better 1Smithy performs over BigMoney. 50% win rate / 33% tie rate is quite good.

The most unexpected result from this initial data was just how good GardenWorkshop performed. It completely blows both BigMoney and 1Smithy out of the water.

Next time you play me in Dominion, you know what strategy I’ll go =]

I’d love to hear other strategies you want me to code up. Leave a comment if you like!

Bible in 90 Days Reading Plan Comparison

While I’ve been reading the Bible in 90 Days, I noticed several disadvantages of their reading plan:

  1. The daily passages are not delimited on chapter boundaries. For example, Day 2’s passage ends in the middle of Genesis 28 instead of at the end of the chapter. This makes it difficult to remember where the passage ends and it interrupts the flow of the scripture.
  2. The daily passages are very unevenly distributed. For example, using word counts from the NETBible, Day 8 (Lev 1:1 – Lev 14:32) is 11,604 words, whereas Day 68 (Zec 11:1 – Matt 4:25) is 5,767 words. The standard deviation for the word count over all the passages is 1,438.

I wanted to fix both of these issues by creating a new reading plan [docx] for the Bible in 90 Days program. To do so, I wrote a Java package to model the Bible, then wrote an algorithm that minimizes the standard deviation for the word count over 90 days by adjusting each day’s passage.

Here’s a word count comparison between my reading plan and the original reading plan:

As you can see, my new Bible reading plan is much more consistent in passage size while respecting chapter boundaries:

  • The original standard deviation of word count was 1,438 while mine is 328
  • The original maximum was 11,604 while mine is 8,420
  • The original minimum was 3,190 (the last day, day 88) while mine is 6,707

[Download my Bible in 90 Days reading plan in PDF] [Download my Bible in 90 Days reading plan in DOCX]

Bible Book Chapter, Verse, and Word Counts

I did some word counts on the Bible because I was trying to construct a Bible in 90 Days plan that is more evenly distributed per day than the original one. I came up with this improved Bible in 90 Days reading plan. The standard deviation of the number of words in each day’s reading is much lower in my improved version. I also published a DOCX version of my new reading plan so you can change the dates accordingly. Here’s a high-level snapshot of the data I gathered. The translation I used was the NET Bible since it has a very open copyright.

Book Chapters Verses Words
2 John 1 13 315
3 John 1 14 335
Philemon 1 25 486
Jude 1 25 661
Obadiah 1 21 667
Titus 3 46 972
Haggai 2 38 1041
2 Thessalonians 3 47 1084
Jonah 4 48 1263
Nahum 3 47 1275
Habakkuk 3 56 1513
Zephaniah 3 53 1620
2 Peter 3 61 1640
2 Timothy 4 83 1709
Malachi 4 55 1795
1 Thessalonians 5 89 1929
Joel 3 73 1989
Colossians 4 95 2057
Philippians 4 104 2293
1 Timothy 6 113 2360
James 5 108 2367
1 Peter 5 105 2395
Ruth 4 85 2543
1 John 5 105 2658
Song of Songs 8 117 2960
Micah 7 105 3106
Ephesians 6 155 3136
Galatians 6 149 3290
Lamentations 5 154 3443
Amos 9 146 4181
Hosea 14 197 5302
Ecclesiastes 12 222 5518
Esther 10 167 5651
Zechariah 14 211 6122
2 Corinthians 13 257 6547
Ezra 10 280 6843
Hebrews 13 303 6939
1 Corinthians 16 437 9528
Romans 16 433 9603
Nehemiah 13 406 10000
Daniel 12 357 11192
Revelation 22 404 12128
Mark 16 678 14160
Proverbs 31 915 15272
Joshua 24 658 15746
Judges 21 618 16862
Job 42 1070 18165
1 Chronicles 29 942 18256
2 Samuel 24 695 19379
John 21 879 19648
2 Kings 25 719 21284
1 Kings 22 816 21557
Matthew 28 1071 22755
2 Chronicles 36 822 22968
1 Samuel 31 810 23765
Acts 28 1007 24029
Leviticus 27 859 24130
Luke 24 1151 25132
Deuteronomy 34 959 25717
Numbers 36 1288 30752
Exodus 40 1213 31464
Isaiah 66 1292 35348
Genesis 50 1533 36381
Ezekiel 48 1273 36584
Psalms 150 2461 42167
Jeremiah 52 1364 46359

KenKen Flash Game

Two weeks ago, I got a free copy of Adobe Flex 3 since Jo is a teacher! So I’ve been learning Flash and it’s been a lot of fun.

I started by porting my old Texas Hold’em Odds calculators from Java to Flash (since no one has Java =p). I still wanted to use Java for the back end calculations, so I also had to learn how to write Java Servlets. It’s been a lot of fun. Mostly because I’m a big fat nerd.

After getting a little Flash experience I created a new KenKen application. Check it out and let me know what you think: http://www.ben61a.com/kenken/

Jo can beat a 4×4 in 30s. She’s also beat a 9×9 in 21 minutes.

Kashmiri vs. The Regents of UC

12/16/2008 Update: I got my settlement check for $200!

—–

Did anyone else receive the below email? I did some digging and everything checks out. I had heard about the class action lawsuit before, and Rust Consulting truly is the administrator for this particular one. But I’m paranoid. Should I reply?

IMPORTANT NOTICE ABOUT STEPS TO TAKE TO ENSURE YOU RECEIVE INFORMATION ABOUT YOUR POTENTIAL SHARE OF THE UNIVERSITY OF CALIFORNIA FEE OVERCHARGE JUDGMENT

You have been identified by the University of California as a member of the plaintiff class in the class action lawsuit known as Kashmiri v. The Regents of the University of California, which challenged certain fee increases at the University. The $33.8 million judgment in favor of the plaintiffs has been affirmed on appeal and is now final.

You will receive additional information about the distribution of the funds recovered from the University. As we begin this process, we need current e-mail and postal addresses for all class members so that we can send you additional notices and, eventually, a check if you are entitled to one. If you have changed your name, please provide both names. Please provide any updated contact information as soon as you can and if possible by April 21, 2008, by (1) replying to this e-mail (if you are the addressee), (2) sending an e-mail to ucfees@rustconsulting.com, or (3) mailing the information to Kashmiri v. Regents Class Action, P.O. Box 1931, Faribault MN 55021-7186. The information you provide will not be used for any other purpose.

Also, please forward this email to any of your classmates who may be members of the plaintiff class and encourage them to update their contact information. The plaintiffs consist of three subclasses:

1. Current and former University of California (“UC”) students who enrolled in a UC professional degree program prior to December 16, 2002, and whose professional degree fees were raised after that date.

2. Students who attended any UC school on a semester system during the Spring 2003 semester, whose fees for that semester increased after they had already enrolled in classes and received bills for the semester.

3. Students who attended the Summer 2003 session at UC Berkeley or UCLA, whose fees for that summer session increased after they had already enrolled and received bills for the session.

Thank you.

Rust Consulting
Class Action Administrator

The Housing Crisis Explained

I wanted to learn about what caused the housing crisis, so here’s what I found based on some discussion from an investment mailing list and online sources. Hope it helps.

Background

1980s

  • Someone at JP Morgan invents a way to split a mortgage loan into multiple shares which can be sold separately
  • This allows everyday investors to buy into mortgages instead of only banks, who gave out the loans

1990-2007

  • China, Korea, Taiwan become rich with money from exports
  • Russia and Persian Gulf countries become rich with money from oil
  • These countries look for good investments for their trillions of dollars
  • The Internet and other technological advances increase the speed of financial transactions

2001

  • US recession causes Greenspan to cut interest rates as low as 1% in 2002
  • This eventually meant that people would pay less interest on new or refinanced mortgages
  • This spurred more house purchases
  • More house purchases (more demand) caused housing prices to increase

2001-2007

  • Derivatives become popular. An example is an investment in an instrument that:
    • Returns 300% if housing prices go up 10%
    • Returns its original value if housing prices increase between 0% and 10%
    • Returns nothing (you lose it all) if housing prices fall

The Build Up

  • Investment banks were deluged with investments (much from those rich countries)
  • Because the interest rates were low from Greenspan’s cuts, the banks couldn’t make much money from normal loans, so they channeled all the money into the housing market
    • The banks sold investors shares of the mortgages
    • The liability of the mortgages went from the bank to the investors
  • Since they didn’t have any risk on mortgage defaults, banks gave out loans easily (no income verification, no money down, etc.) and gave out riskier loans (option arms, etc.)
  • Since loans were easy to get, more people bought houses
  • Since more people bought houses, housing prices increased
  • Since housing prices were increasing seemingly without stop, banks put lots of money into derivatives
    • To make even more money, they borrowed money from other places at the low interest rates to be able to bet it on derivatives
    • This makes sense: if you could borrow money at 1% to make a 300% return from a derivative, you’d borrow as much as possible

The Crash

  • Loans were given to riskier and riskier borrowers
  • Many borrowers started to default on their mortgages because they couldn’t pay
  • Banks reacted by making it harder to get a loan (require income verification, money down, etc.)
  • Foreclosures caused housing prices to drop
  • Fewer people could qualify for loans
  • Demand for housing went down, which caused prices to go down
  • Housing prices going down caused many of the derivatives that banks were invested in to return nothing
  • Worse yet, the loans that banks took to invest in the derivatives still needed to be paid off
  • Investment banks that were heavy into derivatives were no longer able to pay the bills

Current Events

  • US government stepped in to take control of companies like Fannie Mae and Freddie Mac
  • US government decided not to step in to take control of Lehman Brothers, causing it to declare bankruptcy
  • Investors in all three of these companies lost a lot of money from their stock prices nosediving

Imperial Star Destroyer Completed

9/15 1:05am-1:40am Began the bridge’s base before sleep

9/15 6pm Continued the bridge’s base

The completed base sitting on top of the top wings:

630pm Dinner

1100pm Started again

The bridge’s frame:

The walls of the bridge (front and back, where the back folds behind):

The walls added to the frame without folding the back:

One of the back walls folded in:

The completed bridge:

The bridge with roofing below

1120 Stopped to provide computer support for a friend =p

1145-9/16 130am Finish up

9/16 130am Finished!

That bag is holding all the extra parts. The black thing is a plaque to put the sticker on:

Bridge support detail:

Side-mount cannon:

Side detail:

Extra ship thinger:

Docking bay in the belly of the destroyer:

Rear/engine detail:

Bridge rear detail:

Bridge front detail:

Bridge top detail:

Inset focus shot:

Bridge focus shot:

Extra Pieces: 19

Missing Pieces: 0

Total Time Spent: 651 minutes ~= 11 hours over 2 days

Imperial Star Destroyer

Sunday 9/14 4:10pm – Opening

3104 pieces

Split into 4 boxes:

4:25pm

Finished sorting from smallest (left) to largest (right) with sub-sort according to whether the pieces are “normal-shaped” or not.

4:29pm Found the 3 pieces required to complete step 1

5:16pm Took a break

5:24pm Started working again

6:30pm Realized the big “2x” after step 20 meant to repeat steps 1 through 20, which took about 2 hours the first time

9:34pm Wifey makes me eat dinner

9:55pm Started working again

11:10pm Finished bottom wings

Attaching the bottom “wings” to the frame

It uses a combination of magnets and normal Lego connections

Both bottom wings on:

9/15 12:20am Finished top wings; entire bottom portion done

Total minutes so far: 461

More to come! Thanks to everyone who contributed to this awesome gift =]

Adjectives instead of Adverbs

Jo and I watched an episode of The West Wing about a new U.S. poet laureate a little while ago. She incorrectly used “I” (instead of “me”) in a sentence and it made me cringe. I understand a U.S. poet laureate does not have to be good at grammar, but I believe one should be. Shame on the show writers, too.

Anyway, that occurrence made me think of another grammar mistake that I’ve recently started to notice: the use of adjectives instead of adverbs.

The basics:

  • Adjectives modify nouns
  • Adverbs modify verbs

Examples of incorrect use:

  • “He is breathing normal again” is wrong because “normal” is intended to modify the verb “breathing” and should thus be an adverb: “He is breathing normally again.”
  • When someone asks you how you’re doing and you say, “I’m doing good,” you’re actually saying that you are doing good things because good is a noun here. You should actually say “I’m doing well.”

Interesting case:

  • “Slow” and “quick” can be considered adverbs in conversational grammar, so it is fine to say “Take it slow” instead of “Take it slowly.” But when you’re writing formally, you should use the formal adverbs “slowly” and “quickly.”