public long PlayGuided() { var comp = new AsciiCapableIntcode(_program); // Start with scripted move to get everything foreach (var move in _startMoves) { comp.InputLine(move); } // Try all the inventory combinations. The program will terminate when the // right combo is found, but all input is added before anything runs. for (var bitField = 1; bitField < 256; bitField++) { var curr = bitField; for (int i = 0; i < 8; i++) { var verb = curr % 2 == 0 ? "drop" : "take"; var line = $"{verb} {_items[i]}"; comp.InputLine(line); curr /= 2; } comp.InputLine("east"); } foreach (var line in comp.OutputLines()) { if (line.Contains("You should be able to get in")) { return(long.Parse(Regex.Match(line, @"\d+").Value)); } } throw new Exception("Never gets here"); }
public void PlayInteractive() { var comp = new AsciiCapableIntcode(_program); while (true) { comp.AnimateOutputNonAscii(true); } }
public long Run(bool animate = false) { var asciiComp = new AsciiCapableIntcode(_program); asciiComp.InputLine("NOT C J"); asciiComp.InputLine("AND D J"); asciiComp.InputLine("NOT A T"); asciiComp.InputLine("OR T J"); asciiComp.InputLine("RUN"); return(asciiComp.AnimateOutputNonAscii(animate)); }
public long Walk(bool animate = false) { var asciiComp = new AsciiCapableIntcode(_program); asciiComp.InputLine("NOT C T"); asciiComp.InputLine("AND D T"); asciiComp.InputLine("NOT A J"); asciiComp.InputLine("OR T J"); asciiComp.InputLine("WALK"); return(asciiComp.AnimateOutputNonAscii(animate)); }