Ejemplo n.º 1
0
        public static List <Slice> SlicePizzaWithDifferentPatterns(Pizza pizza)
        {
            var slices   = new List <Slice>();
            var patterns = SlicePattern.GetAllPossible(pizza);

            foreach (var pattern in patterns.ToArray())
            {
                for (int row = 0; row < pizza.IngredientRows.Count; row++)
                {
                    for (int column = 0; column < pizza.Columns; column++)
                    {
                        var newSlice = new Slice(row, column, pattern);
                        if (newSlice.IsSufficient(pizza) &&
                            DoesNotOverlapWithSolution(slices, newSlice)
                            )
                        {
                            slices.Add(newSlice);
                            column += newSlice.Pattern.Right;
                        }
                    }
                }
            }

            return(slices);
        }
Ejemplo n.º 2
0
        private void InitiazeFieldPossibilities(IProgress <float> progress = null)
        {
            var slicePatterns = SlicePattern.GetAllPossible(this).ToArray();
            int fieldCount    = Fields.Length;
            int current       = 0;

            foreach (var field in Fields)
            {
                if (progress != null)
                {
                    current++;
                    progress.Report(current / (float)fieldCount);
                }

                foreach (var slicePattern in slicePatterns)
                {
                    var possibleSlice = new Slice(this, field, slicePattern);
                    if (possibleSlice.IsSufficient(this))
                    {
                        //field.PossibePatterns.Add(possibleSlice);
                        foreach (var affectedField in possibleSlice.AffectedFields)
                        {
                            affectedField.PossibleSlices.Add(possibleSlice);
                        }
                    }
                }
            }
        }