Exemple #1
0
 protected override void ProcessOpCode(IntComputer computer)
 {
     if (firstVal.ReadParamFromMemory() == secondVal.ReadParamFromMemory())
     {
         computer.ReplaceMemoryAtAddress(thirdVal.GetMemoryWriteAddressFromParameter(), 1);
     }
     else
     {
         computer.ReplaceMemoryAtAddress(thirdVal.GetMemoryWriteAddressFromParameter(), 0);
     }
 }
Exemple #2
0
        protected override void ProcessOpCode(IntComputer computer)
        {
            // input is forked up
            // you can have a relative address. It's technically a write, but it can be in immediate, position and relative mode.
            int targetAddress = destinationParam.GetMemoryWriteAddressForInputParameter();

            computer.ReplaceMemoryAtAddress(targetAddress, inputData);
        }
Exemple #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);
 }
Exemple #4
0
 public bool FindNounVerb(IntComputer newComp)
 {
     for (int intI = 0; intI < 100; intI++)
     {
         for (int intJ = 0; intJ < 100; intJ++)
         {
             newComp.ResetMemory();
             newComp.ReplaceMemoryAtAddress(1, (long)intI);
             newComp.ReplaceMemoryAtAddress(2, (long)intJ);
             newComp.StartComputer(false);
             long result = newComp.ReadMemoryAtAddress(0);
             if (result == 19690720)
             {
                 // ALL DONE
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #5
0
 protected override void ProcessOpCode(IntComputer computer)
 {
     result = firstVal.ReadParamFromMemory() + secondVal.ReadParamFromMemory();
     computer.ReplaceMemoryAtAddress(thirdVal.GetMemoryWriteAddressFromParameter(), result);
 }