Ejemplo n.º 1
0
        public double CalculateProbability(Tiles tile)
        {
            var N = Unknown.CountAll();

            for (int i = 0; i < 8; i++)
            {
                if (NotInHand[i])
                {
                    N -= Unknown.Count(TilesMethods.GetTileByNumber(i + 1));
                }
            }
            var k = Unknown.Count(tile);

            if (k < 1 || NotInHand[tile.GetNumber() - 1])
            {
                return(0.0);
            }
            var n = HandSize;

            if (n < 1)
            {
                return(0.0);
            }
            var    x      = Enumerable.Range(1, k);
            double Result = CHP(N, k, n, x);

            if (1 < Result)
            {
                return(1.0);
            }
            return(Result);
        }
        public void Add(int number)
        {
            Tiles tile = TilesMethods.GetTileByNumber(number);

            if (AtMax(tile))
            {
                throw new InvalidTileException("Too many of the same tile in collection.");
            }
            TileNumbers[number - 1]++;
        }
        public Tiles Remove(int number)
        {
            Tiles tile = TilesMethods.GetTileByNumber(number);

            if (TileNumbers[number - 1] < 1)
            {
                throw new InvalidTileOperationException("No tile to remove.");
            }
            TileNumbers[number - 1]--;
            return(tile);
        }