diff --git a/notes.md b/notes.md index a4ba51b..e23c0f8 100644 --- a/notes.md +++ b/notes.md @@ -47,7 +47,7 @@ At the foothills, the first area of the RPG: Required opcodes: All except `halt` ### Code 5 (Twisty passages) -After falling down the bridge, there is an `empty lantern` to the `east`, which should be `take`n. To the `west`, there is a passage, where one can take the `ladder` down or venture into the `darkness`. Attempting to venture into the `darkness` at this point will result in being eaten by Grues. +After falling down the bridge, there is an `empty lantern` to the `east`, which should be `take`n. To the `west`, there is a `passage`, where one can take the `ladder` down or venture into the `darkness`. Attempting to venture into the `darkness` at this point will result in being eaten by Grues. Taking the `ladder` down, then traversing `west`, `south`, `north`, a code is obtained: @@ -60,7 +60,7 @@ Taking the `ladder` down, then traversing `west`, `south`, `north`, a code is ob There is also a can, which can be `take`n and `use`d to fill the lantern, which can then be `use`d to become lit, and which will keep away Grues. ### Code 6 (Dark passage, ruins and teleporter) -Returning to the fork at the passage and venturing to the `darkness`, we now `continue` `west`ward to the ruins. The `north` door is locked, but dotted elsewhere around the ruins are a `red coin` (2 dots), `corroded coin` (triangle = 3 sides), `shiny coin` (pentagon = 5 sides), `concave coin` (7 dots) and `blue coin` (9 dots) which should be `take`n and `look`ed at, and the equation: +Returning to the fork at the passage and venturing to the `darkness`, we now `continue` `west`ward several times, then `north`ward several times to the ruins. The `north` door is locked, but dotted elsewhere around the ruins are a `red coin` (2 dots), `corroded coin` (triangle = 3 sides), `shiny coin` (pentagon = 5 sides), `concave coin` (7 dots) and `blue coin` (9 dots) which should be `take`n and `look`ed at, and the equation: _ + _ * _^2 + _^3 - _ = 399 @@ -248,7 +248,7 @@ I've implemented this as a debug function to prepare the teleporter: ### Code 8 (Beach and vault) Arriving at the beach, traverse `north`ward until you reach a fork. To the `east` lies a `journal` containing clues as to the upcoming puzzle. -With the ability to map the puzzle (possibly with the help of our knowledge of the map data format), and (unlike the adventurers, it seems) a grasp of basic arithmetic, this puzzle shouldn't be too difficult to solve. I couldn't do better than [paiv](https://github.com/paiv)'s [solution](https://paiv.github.io/blog/2016/04/24/synacor-challenge.html) ([code](https://github.com/paiv/synacor-challenge/tree/master/code/src/vault), [map](https://github.com/paiv/synacor-challenge/blob/master/notes/vault-locks.svg)), and it doesn't look like there's much parallelisation to do, so I'll leave you with those links. +With the ability to map the puzzle (possibly with the help of our knowledge of the map data format), and (unlike the adventurers, it seems) a grasp of basic arithmetic, this puzzle shouldn't be too difficult to solve. Armed with our map data, we can now do a [breadth-first search to find the shortest solution](https://github.com/RunasSudo/synacor.py/blob/master/tools/bfs.py). The solution is: diff --git a/tools/bfs.py b/tools/bfs.py new file mode 100755 index 0000000..586f47c --- /dev/null +++ b/tools/bfs.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +# synacor.py - An implementation of the Synacor Challenge +# Copyright © 2017 RunasSudo +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import collections +import re +import struct +import sys + +rooms = {} + +class Door: + def __init__(self): + self.name = None + self.destination = None + +class Room: + def __init__(self): + self.location = None + self.name = None + self.description = None + self.doors = [] + self.callback = None + + self.is_operator = False + self.mutate_value = None + +# Read code into memory +SYN_MEM = [0] * 32768 + +with open('../dumps/init.raw', 'rb') as data: + i = 0 + while True: + byteData = data.read(2) + if len(byteData) < 2: + break + SYN_MEM[i] = struct.unpack('