public void TestUpdateTile() { Arcade a = new Arcade(new long[1]); Point p = new Point(0, 4); a.UpdateTile(p, (int)Arcade.Tile.Wall); a.UpdateTile(p, (int)Arcade.Tile.Empty); Assert.That(a.Tiles.Count, Is.EqualTo(1)); Assert.That(a.Tiles[p], Is.EqualTo(Arcade.Tile.Empty)); }
public void TestGetVisualRepresentation() { Arcade a = new Arcade(new long[1]); a.UpdateTile(new Point(0, 0), (int)Arcade.Tile.Empty); a.UpdateTile(new Point(1, 0), (int)Arcade.Tile.Wall); a.UpdateTile(new Point(2, 0), (int)Arcade.Tile.Block); a.UpdateTile(new Point(3, 0), (int)Arcade.Tile.HorizontalPaddle); a.UpdateTile(new Point(4, 0), (int)Arcade.Tile.Ball); Assert.That(a.GetVisualRepresentation(), Is.EqualTo(".+#~O\n")); }
public void TestCountTilesOfType() { Arcade a = new Arcade(new long[1]); a.UpdateTile(new Point(0, 4), (int)Arcade.Tile.Wall); a.UpdateTile(new Point(1, 4), (int)Arcade.Tile.Wall); a.UpdateTile(new Point(2, 4), (int)Arcade.Tile.Wall); a.UpdateTile(new Point(3, 4), (int)Arcade.Tile.Empty); a.UpdateTile(new Point(4, 4), (int)Arcade.Tile.Empty); Assert.That(a.CountTilesOfType(Arcade.Tile.Wall), Is.EqualTo(3)); Assert.That(a.CountTilesOfType(Arcade.Tile.Empty), Is.EqualTo(2)); Assert.That(a.CountTilesOfType(Arcade.Tile.Ball), Is.EqualTo(0)); }
public string SolvePartOne(string[] input) { long[] game = string.Join(",", input) .Split(",") .Select(x => Int64.Parse(x)) .ToArray(); Arcade arcade = new Arcade(game); Point p; int tileId; do { p = new Point(0, 0); arcade.Run(); p.X = (int)arcade.Output; arcade.Run(); p.Y = (int)arcade.Output; arcade.Run(); tileId = (int)arcade.Output; arcade.UpdateTile(p, tileId); } while (arcade.CurrentState != IntcodeComputer.State.Halted); return(arcade.CountTilesOfType(Arcade.Tile.Block).ToString()); }
public void TestUpdateMaxX() { Arcade a = new Arcade(new long[1]); Point p = new Point(4, 0); a.UpdateTile(p, (int)Arcade.Tile.Wall); Assert.That(a.MaxX, Is.EqualTo(4)); }
public string SolvePartTwo(string[] input) { long[] game = string.Join(",", input) .Split(",") .Select(x => Int64.Parse(x)) .ToArray(); game[0] = 2; Arcade arcade = new Arcade(game); arcade.Input = 0; int score = 0; Point p; int tileId; do { p = new Point(0, 0); arcade.Run(); p.X = (int)arcade.Output; arcade.Run(); p.Y = (int)arcade.Output; arcade.Run(); tileId = (int)arcade.Output; if (-1 == p.X) { score = tileId; } else { arcade.UpdateTile(p, tileId); } // Console.Clear(); // Console.WriteLine($"Score: {score}"); // Console.WriteLine($"{arcade.GetVisualRepresentation()}"); } while (arcade.CurrentState != IntcodeComputer.State.Halted); return(score.ToString()); }