F# Blackjack
An F# implementation of the game of blackjack useful for exploring the basics of F#.

I'm no F# expert, but I've learned quite a bit about it. This project was originally done for a "lunch and learn," but I thought it might be useful for others learning F#. It consists of:
  • A blackjack library (F#)
  • A UI project (Winforms)
  • A unit test project (C# testing the F# blackjack library)
Before running the game, adjust the path to the card image files in BlackjackDataStructures.fs

The F# code is fully functional (no classes & nothing mutable). It relies heavily on pattern matching over discriminated union types (see Game.fs & BlackjackDataScructures.fs). I believe it shows how useful, understandable, clean, and tight F# code can be. The code is tight because the game is defined as a DU of states and the code that runs a game controls transition over the states the game can be in.

There is no ability to split your hand, but otherwise I think it's complete. Run the project and use keys to start new game / hit / stay.

Last edited Jan 13, 2015 at 3:16 PM by bradwood, version 5