Skip to content

endform/blackjack_state_machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a little demo of how you can use state_machine to write simple
interactive applications. Included in the repo is Blackjack_state_machine.png
which is a graph that represents the machine with all states and events.

The main loop is pleasingly concise. Each state offers a command method that
causes the program to advance the underlying state and return a symbol for
the next even that should fire. The different agents, the dealer and the
player classes, have methods on them which sometimes compute the next event
programatically but some require user input.

The tests are under the spec folder.

I gleaned the rules for blackjack from this page
http://en.wikipedia.org/wiki/Blackjack

To install please clone this repo and then run
gem build blackjack_state_machine.gemspec
gem install blackjack_state_machine-0.0.1.gem

To run the tests install rspec and then just run 'rspec', note they rely on some
1.9.2 specific features. The actual program should function just fine

To run the game itself if your path is setup correctly you can just enter
blackjack_state_machine on the command line. If not, cd into
this directory and run ruby -Ilib bin/blackjack_state_machine

About

a simple state machine to play blackjack with

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages