Monday, September 14, 2009

Simulated Annealing - Poker Solitaire and C#

I recently revisited the Simulated Annealing heuristic algorithm using C#. This algorithm is traditionally the choice for solving the Traveling Salesman problem, but I wanted to tackle another large combinatorial problem, Poker Solitaire.

For a description of the problem, visit Dr. Dobbs original article at:

http://www.ddj.com/184408203?pgno=16

How do you calculate a result with a solution set of 25 factorial (15,511,210,043,330,983,907,819,520)?

The Visual Studio 2008 solution (see below) provides a console application that repeatable executes a single annealing process, each time trying to optimize a 5x5 matrix of playing cards. The algorithm attempts to lay the cards out to optimize 12 poker hands (5 rows, 5 columns, 2 diagonals).

You can execute the console application using the syntax below, passing it the name of a text file that represents 25 cards for the 5x5 matrix.

C:> SimulatedSolitaire.Console.exe TestData\BestCards.txt

Download the Visual Studio 2008 solution by clicking here.

No comments:

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...