// We rely on GMPLib here - http://gmplib.org
#include "gmpxx.h"
// We also rely on my really small statistics package for its lone combin
// function.  Maybe someday I'll add to it.  Probably not.  I'm lazy.
#include "jestatistics.h"

/*
  Hypergeometric Probability Calculator.  Great for computing odds for keno,
  lotteries, and card games.  Terrible for cooking, cleaning, or just
  generally helping out around the house.

  Relies on GMP, in case we missed the first comment here.

  MUST HAVE THE GMP LIBS TO MAKE IT GO!!
*/
#ifndef HGPROBABILITYCALC_H
#define HGPROBABILITYCALC_H

// Class for making a friendlier callback
class ProbabilityOddsCallback {
  public:
  virtual void operator() (int, mpf_class) = 0;
};

class HGProbabilityCalc {
  private:
    int m_total_marbles;
    int m_picks;
    int m_white_marbles;
    mpz_class m_pick_permutations;

    void calculate_permutations();

  public:
    // Constructor (duh)
    HGProbabilityCalc(int marbles, int picks, int white);

    // Accessors - read-only, as one should build a new object if one wants
    // a new computation
    inline int picks() {return m_picks;}
    inline int white_marbles() {return m_white_marbles;}
    inline int total_marbles() {return m_total_marbles;}

    // Semi-useful functions
    mpz_class pick_permutations() {return m_pick_permutations;}
    mpf_class odds_against(int);
    void get_all_odds(ProbabilityOddsCallback& poc);
};

#endif
