public BruteForceAnalysis(SolverInfo solver, List <SolverTile> locations, int size, List <SolverTile> startLocations) { this.solver = solver; this.locations = locations; this.maxSolutionSize = size; //this.top = new Node(); sorters = new SortSolutions[locations.Count]; for (int i = 0; i < sorters.Length; i++) { sorters[i] = new SortSolutions(i); } this.allSolutions = new SolutionTable(this, size); this.startLocations = startLocations; }
/** * 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); }