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)); }
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, } }); }
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, } }); }
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(); }
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); }
public BubbleGroupFinder(ImmutableBubbleBurstGrid grid, IEnumerable<BubbleGroup> parentsGroups) { _grid = grid; _stats = new Dictionary<Bubble, int>(); //_parentGroups = parentsGroups ?? Enumerable.Empty<BubbleGroup>(); }
public GridSolver(ImmutableBubbleBurstGrid grid, StreamWriter writer, int depthPenalty) { _grid = grid; _writer = writer; _depthPenalty = depthPenalty; }
public GridSolver(ImmutableBubbleBurstGrid grid, StreamWriter writer, int depthPenalty) { _grid = grid; _writer = writer; _depthPenalty = depthPenalty; }