public void AddSolution(sbyte[] solution)
        {
            if (solution.Length != locations.Count)
            {
                throw new Exception("Solution does not have the correct number of locations");
            }

            if (allSolutions.GetSize() >= maxSolutionSize)
            {
                tooMany = true;
                return;
            }

            /*
             * String text = "";
             * for (int i=0; i < solution.length; i++) {
             *  text = text + solution[i] + " ";
             * }
             * solver.display(text);
             */

            allSolutions.AddSolution(solution);
        }
        /**
         * Builds a top of tree node based on the solutions provided
         */
        private Node buildTopNode(SolutionTable solutionTable)
        {
            Node result = new Node(this, locations.Count);

            result.startLocation = 0;
            result.endLocation   = solutionTable.GetSize();

            List <LivingLocation> living = new List <LivingLocation>();

            for (short i = 0; i < locations.Count; i++)
            {
                int value;

                int[] valueCount   = ResetValues();
                int   mines        = 0;
                int   maxSolutions = 0;
                byte  count        = 0;
                sbyte minValue     = 0;
                sbyte maxValue     = 0;

                for (int j = 0; j < result.GetSolutionSize(); j++)
                {
                    if (solutionTable.Get(j)[i] != Cruncher.BOMB)
                    {
                        value = solutionTable.Get(j)[i];
                        //values[value] = true;
                        valueCount[value]++;
                    }
                    else
                    {
                        mines++;
                    }
                }

                for (sbyte j = 0; j < valueCount.Length; j++)
                {
                    if (valueCount[j] > 0)
                    {
                        if (count == 0)
                        {
                            minValue = j;
                        }
                        maxValue = j;
                        count++;
                        if (maxSolutions < valueCount[j])
                        {
                            maxSolutions = valueCount[j];
                        }
                    }
                }
                if (count > 1)
                {
                    LivingLocation alive = new LivingLocation(this, i);
                    alive.mineCount     = mines;
                    alive.count         = count;
                    alive.minValue      = minValue;
                    alive.maxValue      = maxValue;
                    alive.maxSolutions  = maxSolutions;
                    alive.zeroSolutions = valueCount[0];
                    living.Add(alive);
                }
                else
                {
                    solver.Write(locations[i].AsText() + " is dead with value " + minValue);
                }
            }

            living.Sort();
            //Collections.sort(living);

            result.livingLocations = living;

            return(result);
        }