private static int RunImpl(string input, int startValue, Dictionary <Coordinate, SquareColor> paintedSquares) { var cpu = new IntCodeStateMachine(input.Split(',').Select(BigInteger.Parse)); var paintingRobotState = new MessageState(paintedSquares, cpu); cpu.OnOutput += paintingRobotState.Run; cpu.SetInput(startValue); cpu.RunAll(); var totalPaintedSquares = paintedSquares.Count; return(totalPaintedSquares); }
public int Run(string input = Input) { var memory = Input.Split(',').Select(s => BigInteger.Parse(s)); // probably not the best origin of control, but I don't // have to make any changes, sooooo, here's my excuse. var cpu = new IntCodeStateMachine(memory); var view = new InMemoryGameView(); var game = new ArcadeProgram(cpu, view); cpu.RunAll(); var blockCount = view.Memory.Values.Count(t => t == TileType.Block); return(blockCount); }
public int Run(string input = Input) { var memory = Input.Split(',').Select(s => BigInteger.Parse(s)).ToArray(); memory[0] = 2; // to play for free! var cpu = new IntCodeStateMachine(memory); var scoreView = new ScoreView(); var gameView = new SegmentDisplay(scoreView, new ConsoleGameView()); var gameInput = new AiGameInput(cpu); var game = new ArcadeProgram(cpu, gameView, gameInput); cpu.RunAll(); Console.Clear(); return(scoreView.FinalScore); }
public void ExecuteInstruction() => _cpu.RunAll();