X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=src%2FMain.hs;fp=src%2FMain.hs;h=d7ad6f3d843eba0c75bdd2da6bc042b7ccc19e7b;hb=56796d54a5048d5f38ac06b1fdea48c045bb626e;hp=be6e522cf64b1980bab72cb877512a8f37a44f72;hpb=a0df5c6aec6ff0271ab47205f915e4647fbad4ec;p=synacor-challenge.git diff --git a/src/Main.hs b/src/Main.hs index be6e522..d7ad6f3 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -157,7 +157,11 @@ handleCommand ":untrace" state = handleCommand ":poke8" state = do let machines = state ^. ssMachines let machine = head machines - let machine' = machine & registers . ix 7 .~ 1 + let machine' = machine & registers . ix 7 .~ 25734 + & memory . ix 5489 .~ 21 + & memory . ix 5490 .~ 21 + & memory . ix 5495 .~ 7 + -- let machine' = machine & memory . ix 5451 .~ 7 return $ state & ssMachines .~ (machine' : (tail machines)) handleCommand command state = return $ runOneInput state command @@ -173,6 +177,14 @@ runWithoutInput state = state & ssMachines %~ (machine' :) (exState, machine', output) = runMachine [] (machine & inputIndex .~ 0) runOneInput :: SynacorState -> String -> SynacorState +runOneInput state ":poke8" = state & ssMachines .~ ssMAchinesNew + where machine0 = head $ state ^. ssMachines + machine = machine0 & registers . ix 7 .~ 25734 + & memory . ix 5489 .~ 21 + & memory . ix 5490 .~ 21 + & memory . ix 5495 .~ 7 + ssMAchinesNew = machine : (tail $ state ^. ssMachines) + runOneInput state input = state & ssMachines %~ (machine' :) & ssInputs %~ (input :) & ssOutputs %~ ((showOutput output) :)