예제 #1
0
        public static Tuple <ImmutableBubbleBurstGrid, int, Bubble> RemoveGroup(this ImmutableBubbleBurstGrid grid, Point point)
        {
            if (!grid.IsLegal(point))
            {
                throw new ArgumentException($"Invalid move - Point ({point.X},{point.Y}) is invalid in this grid");
            }

            var pointsGroup = grid.Groups.FirstOrDefault(x => x.Locations.Contains(point));

            if (pointsGroup == null)
            {
                throw new ArgumentException(
                          $"Invalid move - Point ({point.X},{point.Y}) does not belong to a valid group");
            }

            var gridBuilder = grid.ToBuilder();

            foreach (var bubble in pointsGroup.Locations)
            {
                gridBuilder[bubble.X, bubble.Y] = Bubble.None;
            }

            gridBuilder.JumpTillTheresNoGaps();
            gridBuilder.PushColumnsRight();

            return(Tuple.Create(gridBuilder.ToImmutable(grid.Groups), pointsGroup.Score, pointsGroup.Colour));
        }
예제 #2
0
 public void Setup()
 {
     _grid = BubbleGridBuilder.Create(new[]
     {
         new[] { Bubble.Blue, Bubble.Green, Bubble.Cyan, Bubble.Blue },
         new[] { Bubble.Red, Bubble.Green, Bubble.Red, Bubble.Green },
         new[] { Bubble.Red, Bubble.Yellow, Bubble.Yellow, Bubble.Cyan, },
         new[] { Bubble.Red, Bubble.Cyan, Bubble.Cyan, Bubble.Cyan, }
     });
 }
예제 #3
0
 public void Setup()
 {
     _grid = BubbleGridBuilder.Create(new[]
                                      {
                                          new[] {Bubble.Blue, Bubble.Green, Bubble.Cyan, Bubble.Blue},
                                          new[] {Bubble.Red, Bubble.Green, Bubble.Red, Bubble.Green},
                                          new[] {Bubble.Red, Bubble.Yellow, Bubble.Yellow, Bubble.Cyan, },
                                          new[] {Bubble.Red, Bubble.Cyan, Bubble.Cyan, Bubble.Cyan, }
                                      });
 }
예제 #4
0
        public static void Display(this ImmutableBubbleBurstGrid grid)
        {
            for (var row = 0; row < grid.Height; row++)
            {
                for (var col = 0; col < grid.Width; col++)
                {
                    var current = grid[col, row].ToString()[0];
                    if (current != 'N')
                    {
                        switch (current)
                        {
                        case 'B':
                            Console.BackgroundColor = ConsoleColor.Blue;
                            break;

                        case 'Y':
                            Console.BackgroundColor = ConsoleColor.Yellow;
                            break;

                        case 'G':
                            Console.BackgroundColor = ConsoleColor.Green;
                            break;

                        case 'C':
                            Console.BackgroundColor = ConsoleColor.Cyan;
                            break;

                        case 'R':
                            Console.BackgroundColor = ConsoleColor.Red;
                            break;
                        }

                        Console.Write(current);
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.Write(" ");
                    }
                    else
                    {
                        Console.Write("  ");
                    }
                }
                Console.Write(row + " ");
                Console.Write(Environment.NewLine);
            }
            for (var a = 0; a < grid.Width; a++)
            {
                Console.Write(a + " ");
            }
            Console.WriteLine();
        }
예제 #5
0
        public static bool IsLegal(this ImmutableBubbleBurstGrid grid, Point point)
        {
            var returnBool = true;

            if (point.X < 0 || point.X >= grid.Width)
            {
                returnBool = false;
            }
            else if (point.Y < 0 || point.Y >= grid.Height)
            {
                returnBool = false;
            }

            return(returnBool);
        }
예제 #6
0
 public BubbleGroupFinder(ImmutableBubbleBurstGrid grid, IEnumerable<BubbleGroup> parentsGroups)
 {
     _grid = grid;
     _stats = new Dictionary<Bubble, int>();
     //_parentGroups = parentsGroups ?? Enumerable.Empty<BubbleGroup>();
 }
예제 #7
0
 public GridSolver(ImmutableBubbleBurstGrid grid, StreamWriter writer, int depthPenalty)
 {
     _grid         = grid;
     _writer       = writer;
     _depthPenalty = depthPenalty;
 }
예제 #8
0
 public GridSolver(ImmutableBubbleBurstGrid grid, StreamWriter writer, int depthPenalty)
 {
     _grid = grid;
     _writer = writer;
     _depthPenalty = depthPenalty;
 }