My Toy Closet
This is a computerized version of Mayfair Games’ Empire Builders board game series, specifically modelled after Eurorails with its ferries, alpine mountains, and multilingual nature. Download it here. If you like to play board games but are not familiar with these games, I recommend you buy one of them from the Mayfair site. I don’t provide much background info in the download so you’ll probably want to play the board game version a couple of times first.
I love playing board games, especially strategy board games such as Puerto Rico as opposed to the more general-audience games like Cranium. A great site to try BoardGameGeek if you like board games. There you’ll find a list of most of the games that I own.
Visual Basic program to print graph paper. It can print regular graph paper with squares, hexagonal graph paper for gaming, or isometric (with triangles). You can specify the grid size either in metric or English units.
3D Strange Attractors
C# program to generate random 3D chaotic strange attractors. These weird shapes represent the fractal basin of attraction of a non-linear function. Find out more about strange attractors here, here, and here.
This is a simple Visual Basic program that generates mazes with four different levels of difficulty, for display or for printing. Source code demonstrates basic maze generation algorithm and shows how to print in Visual Basic.
This is source code for a VB demo program. It simulates a number of sub-planetary masses orbiting a central solar mass. Initially the orbits are very unstable due to the random starting velocities, and many collisions result. Eventually the simulation settles down to two or three large planets in nearly circular orbits, with perhaps a planet in a distant eccentric orbit.
A 15th anniversary update to my original Plasma program. This one is C# source code only (no executable). It uses a physical simulation model instead of a mid-point displacement fractal, so it's a lot more computationally heavy that the old Plasma, but it's still fun to look at.
Rubik's Cube Object Model
This C# class represents a Rubik's cube (standard 3x3x3) and allows you to rotate any of its faces, reset it to its original state, perform a sequence of moves described by a string, perform the moves in reverse order, and scramble the cube. It does not solve a scrambled cube.
I've tried many methods of representing a cube in software, some more cumbersome than others. This one is very simple, lightweight, and pretty fast. It uses the U, F, R, D, B, L notation for faces, and +, -, and 2 for quarter CW, quarter CCW, and 180-degree turns. So "F2 D- B2 U+" would be an example of a valid move sequence.
Software Development Topics
I created this calculator as my personal replacement for the Windows calculator. It's modelled after a Hewlett-Packard HP-10C calculator, and as such it uses reverse polish notation for data entry.
This C# project is a quick-and-dirty Travelling Salesman Problem solver which works pretty well for several hundred nodes. It allows you to define any vertex data type and specify an arbitrary cost function to calculate the cost of an edge between two vertices.
In addition to the generic solver class, some sample source code is provided to show how to use the TSP solver for points on a sphere, and a Windows Forms app is include to provide a graphical illustration of a 2D Euclidean problem as it is being solved.
Hash Function Evaluation
This is a long article about testing 32-bit hash functions, and includes testing for uniform distribution of output bits and for diffusion of input bits into all output bit positions. I evaluate a number of different 32-bit hash functions using these tests, and provide an improvement to the FNV hash.
SHA-1 Cryptographic Hash
C++ source code for a SHA-1 class. This implementation is a bit different than others because it allows you to calculate the hash result part-way through a stream and then accumulate additional data.
This C# sample code illustrates how to write your own ICustomFormatter object for .NET.
This is my attempt at creating a .NET-compatible class for the Jalali (Persian) calendar. Written in C#. One user reported an error in the date calculations so it's not quite right yet, but I didn't know enough about the Jalali calendar to fix it.
Random Shuffle with O(1) Memory Requirement
Let's say you want to generate one million random numbers, each number being from one to one million, but you only want to use each number once and exactly once. Most algorithms for this require at least one million bits of memory to keep track of which numbers have already been generated in order to avoid using the same number twice.
This C# source code demonstrates a way to do this with no need to keep track of which numbers have already been generated. It purposely uses a "bad" random number generator (a linear congruential generator) because of ability to create an LCG with a known period.
The down-side to this method is that not all possible permutatations can be generated. Instead of n! different permutations, this algorithm can only produce O(n3) different permutations. The C# class exposes a property to indicate the number of possible permutations. Note that using a better PRNG and using a million bits of memory won't necessarily give you n! permutations, either. If your PRNG is deterministic and uses a 32-bit seed, you won't get n! for n>12. To shuffle a deck of cards, for example, you'd need a PRNG with at least 232 bits of state information.
.NET Custom Attributes
This C# sample code illustrates how to create and use custom attributes in .NET. The code includes a class called LabelAttribute that allows you to assign an arbitrary text label to any .NET code element and to read the value of that label at run-time.
Calculate Many Digits of Pi
C# source code to calculate p to many digits of accuracy. Number of digits is specified as a program constant. It's not the fastest code in the world, but it'll do 10000 digits pretty quickly.