Ejemplo n.º 1
0
        public RepairBot(string inData, string outFile)
        {
            string curMapFile = "BotMap.txt";
            string rootPath   = Path.GetDirectoryName(outFile);

            curMapFile         = Path.Combine(rootPath, curMapFile);
            sw                 = new StreamWriter(outFile);
            xSize              = 42;
            ySize              = 42;
            startNode          = new ExploreNode();
            startNode.nodeType = RobotResultCode.MOVE_SUCCESFUL;
            curNode            = startNode;
            curMap             = new ExploreNode[xSize * ySize];
            curPos.x           = xSize / 2;
            curPos.y           = ySize / 2;
            int startIndex = Helpers.GetIndexFromCoordinate(curPos, xSize);

            curMap[startIndex] = startNode;
            curComputer        = new IntComputer();
            curComputer.InitializeMemory(inData);
            curComputer.StartComputer(true);
            RunRobot();

            //DrawMap();
            int endIndex = Helpers.GetIndexFromCoordinate(curPos, xSize);
            int length   = SearchTree(startIndex, endIndex);

            sw.Close();
        }
Ejemplo n.º 2
0
        public void SolveDayNine()
        {
            string resultsFile = "adventDayNineSolution.txt";
            string dataFile    = "adventDayNine.txt";
            string outFile     = Path.Combine(baseDir, resultsFile);
            string inFile      = Path.Combine(baseDir, dataFile);

            string[]    sourceData = ReadAllLines(inFile);
            IntComputer curComp    = new IntComputer();

            curComp.InitializeMemory(sourceData[0]);
            curComp.AddInputData(2); // test mode
            //curComp.InitializeMemory(SolverTests.GetSampleData(0));
            curComp.StartComputer(false);
            while (!curComp.IsProgramCompleted())
            {
                curComp.ResumeProgram();
            }
            string       debugData = curComp.GetDebugOutputString();
            StreamWriter sw        = new StreamWriter(outFile);

            sw.WriteLine(debugData);
            sw.Close();
            //long outVal = curComp.ReadOutputData();
        }
Ejemplo n.º 3
0
 public ArcadeMachine(string sourceData, string outFile)
 {
     curComputer = new IntComputer();
     curComputer.InitializeMemory(sourceData);
     curComputer.ReplaceMemoryAtAddress(0, 2); // infinite play
     curComputer.StartComputer(true);
     sw = new StreamWriter(outFile);
 }
Ejemplo n.º 4
0
        public void TestDayNineSampleData(int sampleIndex)
        {
            IntComputer curComp = new IntComputer();

            curComp.InitializeMemory(GetSampleData(sampleIndex));
            curComp.StartComputer(false);
            long outVal         = curComp.ReadOutputData();
            long expectedRetVal = GetExpectedResults(sampleIndex);

            Assert.Equal(outVal, expectedRetVal);
        }
Ejemplo n.º 5
0
 public Amplifiers(int ampCount, string sourceProgram)
 {
     numAmplifiers = ampCount;
     for (int intI = 0; intI < ampCount; intI++)
     {
         IntComputer newComp = new IntComputer();
         newComp.curId = numAmplifiers - intI;
         newComp.InitializeMemory(sourceProgram);
         newComp.StartComputer(true);
         generatedAmplifiers.Add(newComp);
     }
 }
Ejemplo n.º 6
0
        public PainterRobot(string sourceInstructions, int width, int height, string debugFile)
        {
            outFile       = debugFile;
            xSize         = width;
            ySize         = height;
            curPos        = new Vector2();
            curPos.x      = xSize / 2;
            curPos.y      = ySize / 2;
            panelsToPaint = new PaintPanelStruct[xSize * ySize];
            int curIndex = Helpers.GetIndexFromCoordinate(curPos, xSize);

            panelsToPaint[curIndex].curColor = PaintColorEnum.WHITE;

            robotComputer = new IntComputer();
            robotComputer.InitializeMemory(sourceInstructions);
            robotComputer.StartComputer(true);
            RunRobot();
        }