clock_solitaire_simulation
    
    
    
      clock_solitaire_simulation,
      a MATLAB code which
      simulates the game of clock solitaire.  The deck is dealt into 13
      piles of 4 cards each.  Repeatedly, the top card a pile is removed,
      and its rank indicates the next pile to consider.  Game continues
      until an empty pile is reached.  The game is won if all piles are
      empty.  The quantity of interest is the probability of winning.
    
    
      Knuth showed that the probability of winning is exactly 1/13.
    
    
      Licensing:
    
    
      The information on this web page is distributed under the MIT license.
    
    
      Languages:
    
    
      clock_solitaire_simulation is available in
      a MATLAB version and
      an Octave version and
      a Python version.
    
    
      Related Data and codes:
    
    
      
      clock_solitaire_simulation_test
    
    
      
      matlab_simulation,
      a MATLAB code which
      uses simulation to study card games, contests, and other processes
      which have a random element.  Usually, the purpose is to try to
      predict the average behavior of the system over many trials.
    
    
      Reference:
    
    
      
        - 
          Martin Gardner,
          Combinatorial problems involving tree graphs and forests of trees,
          Scientific American,
          February 1968.
         
        - 
          Donald Knuth,
          The Art of Computer Programming,
          Volume 1, Fundamental Algorithms,
          Third Edition,
          Addison-Wesley, 1997,
          ISBN: 0201896834,
          LC: QA76.6.K64.
         
      
    
    
      Source Code:
    
    
      
        - 
          card_rank.m, 
          given the index (1-52) of a card, returns its rank (1-13).
        
 
        - 
          card_suit.m, 
          given the index (1-52) of a card, returns its suit ('H','C','D','S').
        
 
        - 
          card_symbol.m, 
          given the index (1-52) of a card, returns its symbol,
          such as 'AH', '3S', '5C', '10D', 'QH'.
        
 
        - 
          piles_deal.m, 
          initializes a solitaire game by dealing the 52 cards into
          13 piles.
        
 
        - 
          piles_print.m, 
          prints the current status of the piles of cards.
        
 
        - 
          play.m, 
          plays one solitaire game and reports if it was won.
        
 
        - 
          play_many.m, 
          plays N solitaire games and reports the number of wins.
        
 
      
    
    
    
      Last revised on 29 August 2022.