Esempio n. 1
0
        // counts the number of mines already placed
        private BigInteger CountPlacedMines(ProbabilityLine pl, NextWitness nw)
        {
            BigInteger result = 0;

            foreach (Box b in nw.GetOldBoxes())
            {
                result = result + pl.GetMineBoxCount(b.GetUID());
            }

            return(result);
        }
Esempio n. 2
0
        // calculate how many ways this solution can be generated and roll them into one
        private void MergeLineProbabilities(ProbabilityLine npl, ProbabilityLine pl)
        {
            BigInteger solutions = 1;

            for (int i = 0; i < this.boxes.Count; i++)
            {
                solutions = solutions * (BigInteger)SMALL_COMBINATIONS[this.boxes[i].GetTiles().Count][(int)pl.GetMineBoxCount(i)];
            }

            npl.SetSolutionCount(npl.GetSolutionCount() + solutions);

            for (int i = 0; i < this.boxes.Count; i++)
            {
                if (this.mask[i])    // if this box has been involved in this solution - if we don't do this the hash gets corrupted by boxes = 0 mines because they weren't part of this edge
                {
                    npl.SetMineBoxCount(i, npl.GetMineBoxCount(i) + pl.GetMineBoxCount(i) * solutions);
                }
            }
        }