EXAPUNKS

EXAPUNKS

View Stats:
That last level is no joke
(SPOILERS for final level)

That last level nearly broke me. Unless I'm missing an obvious solution It fully ramped up to like Spacechem difficulty. I couldn't even figure out how to get the host names and #nerv data recorded in a fashion that wasn't just completely garbled in order.

This is the bit that nearly broke me, but I solved it as thus:

In the end I basically had an initial EXA sending out a "signal" which was just a 1 to the M register to signal a specific EXA that'd found a nerv to send back the data, and if (as frequently happened) another EXA accidentally received the data that was meant to be sent back then it would always first test whether the data being received was a 1 (which means go ahead, it's your turn to send your Host and Nerv data back) or if not it means, you've accidentally recieved data that was supposed to go back to the host, now send it back to M register and wait your turn.

This did mean that occasionally the NERV and HOST data would be in the right pairs, but written back to front, as the NERVs sometimes came through before the HOSTs. I had to run a specific bit of code just to swap these wrongly ordered pairs around.

Then finally of course, now i need to order them all in size. Which just meant running through, checking if the first and second host names are in the right order, if not do a bunch of copy pasting, seeking, to get both the host names and nerv names swapped around, then continue with 3 and 4, all the way to the end, but then of course, you've got to run that same bit of code 11 times in case the lowest host name was at the end, number 11.

After running the reordering 11 times, then it was complete.

Would ABSOLUTELY LOVE to hear how other people solved it, if it was way easier than I thought?

!!!
< >
Showing 1-15 of 25 comments
It's been a week or 2, so I don't fully remember, but it was something like this.

First I had EXA spread to every room. Every EXA has a number in a register (or file) that indicates which 'generation' it is (how deep in it is).

Then the EXA start walking back one room, beginning with the last generation (furthest in). The EXA use their generation number to determine how long to wait until they should walk back.

Each EXA that walked back passes off its data to the EXA in the room it walked back to, and dies. Because there might be multiple EXA of the same generation walking back to the same room, and because each EXA has two values to pass on (host name and #nerv), I use a 'signal' EXA (like you did) to give one EXA at a time permission to send its data. There is no collision between the signal EXA and the other EXA, because only the signal EXA writes in global mode.

After all the generations are done walking back one room and passing off their data, I have all the data (unsorted) in a file the starting room.

I sort the data by spawning a 'receiver' EXA and repeating the following until the file is empty.
- Find the lowest value pair remaining.
- Send the lowest value pair to the receiver.
- Delete the lowest value pair from the file.
Not wanting to deal with sync issues I went for an naive approach.
First gather only the hostnames, then sort them and send exas exa that look up the value.
In the initial hostname gathering the random transmission order does not matter. (Single values cant get mixed up in each other.) And for the value lookup I only send the exa for the second smallest host after the one for the smallest host has transmitted back its value.
Here's what I did.

First, I had EXAs spread out to every room. If it links successfully, it goes into its own special loop so that it replicates exas seeking out new rooms, but not the one it just came from.

Then, each exa communicates back to a host EXA over M what the hardware registry is before starting a countdown and they commnicating the second value, the host. This allows me to communicate over M without having to worry about EXAs conflicting with each other; they can report in any order, but once they start the countdown the host file will have an ordered list, with the pairs of value seperated by a set amount (that varies in each test).

So far, getting that file is done extremely fast, but it was really late at night when I solved this, and the rest of my solution is probably wasteful. Essentially, make another file to sort the file into neat pairs, then I make another file that puts them into the correct order, making sure to delete the high value pairs from the earlier file.

Lastly, because it was too tricky to program that EXA to terminate by itself, I have a single EXA whose sole role is to count down from the lowest possible value and terminate the remaining EXA. Kinda messy, but it works.

In fact, just now I checked the countdown value of the terminator EXA and found that it was too high. I just shaved off 100 cycles or so. It's almost below 1000 now.
I love reading all these solutions!
I had a main exa explore the maze methodically — it was holding a file, and in the file, each time it enters a room, it writes down which path it entered it through; then it tests the other paths to see if they exist/have not been explored yet (it sends probing clones that are supposed to enter a prospective path then come back immediatly and send back a signal in local mode — if there's no path the clone dies and after a couple cycle the main exa, not detecting anything, concludes that there's no path and so marks it as "explored" in the file). When it ends up in a room with no path left to explore, it makes a "data" clone that tries to copy from a #data port - if there's no port, it just dies — and send it to another exa back in the host; then the main exa goes back in the previous room and erase the room it completed from the file.

This method ensures that every room is explored and tested, with no risk of cross-communication over the M channel.

Once every room has been tested, the main exa is effectively back into the host. It kills the other exa (which is just a "dumb" copying exa that writes down anything it receives over the M channel), takes the file and sort it (sorting was a easy part — you can do it in a single file if you just put some sort of halting number at the end of the file, then search, copy and erase the values from the first to second half of the file).
mine takes a nightmarish amount of time because for every time an exa changes direction, i would have it go into a noop loop of a varying amount of cycles, with the variance of the times to loop being such that no matter what combination they went, they'd all be waiting an entirely different amount of time, which ends up being some of them waiting like thousands of cycles to send their host and register information.
https://i.gyazo.com/2d4fd184e8fa913263aaed06be10d915.png
look at this nightmare. i could have made it more efficient by like, properly calculating the exact integers to avoid overlap but it's like, this is going to be a garbage mess of cycles anyways so who cares about cutting off a coupla hundred cycles offa my 16k.
Since I haven't seen my approach here, I'll add it:

One way to get a more or less reasonable size (101 right now) was to to a depth first approach - basically one EXA sends out a replica of itself trying out one of the directions (except if its the one it came from), and if the replica doesnt die instantly, it waits for it to come back. Then, after it comes back, it itself sends out the info package to the data collector in the host, and alerts the exa it had left waiting.
It's a bit clunky and definitely not optimized, but ♥♥♥♥ me, as long as it works I'm fine. This puzzle was something else. I also used bubblesort on my first approach, which seemed to be the easiest solution at the time, but turned out a huge hassle to implement and then also not very efficient, either. So now it just finds the minimum and removes it, instead...
was really cool reading all the different approaches, though. Now that I'm done minimizing for size (no idea how to get below 100), I'm definitely gonna try and do the rest.

Edit: Literally 5 seconds later im at 99. So i guess the moral of the story is don't give up on your dreams.
My solution was:
1. exa in the host sends a seeding clone into 800 which then clones itself until it fills up all of the hosts, while this happens host exa waits for around 100 cycles
2. i make sure each exa does a test check of #nerv so the ones in a host without a #nerv just die
3. once the host exa is done waiting it clones itself and waits for another 100 cycles
4. its clone meanwhile sends out wait times to all the other exas on the board (just a number that's being counted down at the host, order here doesn't matter as long as at each read there's only 1 exa sending)
5. when host finishes waiting again it reads a value from its clone that gives it an idea how many exas are still on the map (this i had to do after finding out that each test run has a variable number of #nerv registers on the map, and i wanted to avoid kill to get a solution with lowest activity which i got)
6. now host can copy from m until this number reaches 0 and we get an unsorted file
7. clone host again and apply a currently very awful bubble sort

but solution is still around 2000 cycles so i am happy for now, i will probably begin finetuning it later by reducing the wait times to minimum possible since they are still high right now, and eventually try and figure out how to sort better (or earlier)
ive done a few versions of this level. the first one was where i didnt feel like planning it out so i made one exa navigate the network by using the "hand on the left wall" technique (imagining the links layout as if it were spatially the same every time; it isnt but that doesnt matter). at each host it would insert that host's info into its file if there was a #nerv & it wasnt in the file already. it turned out i could complete the level by having a terminator wait at the home host & smash and grab when it spots a probe. i thought this one was cute, and surprisingly not bad on metrics other than activity

the one i like most is the fast parallel one (running 153 cycles currently):
1. a replicator occupies all the hosts. if there's a #nerv, it sends back its hostname on global
2. another set of replicators at home fill their registers with the hostnames, chain and then replicate through the network to send the hostnames on local. these exas are gated from linking out too quickly from the home host and jamming up by messages from another exa acting as a clock
3. each host checks if its own name is ">" the names it receives, and sums the results. this count is equal to that host's position in the sorted list for #nerv hosts
4. another exa waiting at home sends a dummy hostname on global to make sure every name gets distributed, then after another wait clears other exas from the home host and sends a final replicator with a stop message.
5. the external exas test write #nerv (empty hosts drop out here) and shift to listening on global
6. an exa at home waits to make sure all the hosts will be ready, then sends out a list of delays for the #nerv hosts to use to synch up. each host adds its comparison count to the delay and waits, then sends its name/data.
7. the external hosts are transmitting in sorted order, so an exa at home can copy everything off global directly into an empty file, and we're done

this relies heavily on hardcoded waits and kills, so it hits the same cycle count on every single test
I too populated the network by having an EXA REPL itself to every link except the one it entered from. It then tries to read #NERV to temp to kill off the ones not occupying a #NERV node.

At first I tried to send the data back using a similar traversal technique, but kept running into traffic jam issues, so I endeavored to find a simpler way. If two EXAs write to M on the same channel at the same time, one's message will take priority, and it turns out that if they later try it again they will have the same priority. So I just had everyone HOST M as soon as they could, wait a hardcoded amount of cycles to ensure everyone else had finished, then COPY #NERV M. Voila, a file containing matching host-nerv pairs.

For sorting, I used the same technique as Zednaught. EXA 0 looked for max(host) in the file, messaged the pair to EXA 1, then voided it and started over. When it reached EOF it just wiped its empty file and killed EXA 1.
My initial solution for this was pretty brutal on the cycles, and I have thought of (and will implement!) a better way, but I was really running into the problem that I couldn't get the timing right so that hosts and #NERV-value would be sent at the same time which made it hard to get the right host/value-pairs.

My solution:
Just send the hostname as many times as the #NERV value. E.g. -37 means sending the hostname 37 times :-). At the receiving end, just count the hostnames as they come in, and when no more message (TEST MRD), sort your now-complete list. Swizzle to get the original negative values.

It's not efficient or pretty, at all, but it's foolproof against timing issues.
My first solution:

Spread out in every direction, after link, do some kill commands, and get wait number from exa that increments it after every sucessfull sending, basically spacing them out so they are not transmitting at the same time.
Second exa wait set number, kills the first one when it runs out, and records the hostnames and #Nerv Values and goes in wait loop, checking if any are transmitting until it counts down to 0, resetting counter on succesfull record. Once it runs out, bubble sort the list. Last part took long time, total of 2154 cycles, cause I made it go from the start of the list every time, making it go 3 elements back cuts time to 1329.
2154/135/870.

My current best is just improvements on the first approach, with making it spread only in directions it didn't come from, and sorting with going over the list twice, first over all of them to find which one is the lowest in the list, the second until it's found again, transmitted to second exa and removed from the file.
1032/99/18.
Very neat results. And good approach. I'm having trouble thinking of a good way of preventing spreaders from returning the way they came. Currently in every node I park an EXA that does COPY -1 M (local). Whenever an EXA walks into a node, they do a TEST MRD, and terminate if true. .

I've found a better way than my above described 20k cycles. I've traded message cycles for activity cycles. I score about 1300 cycles, which I find acceptable. (with over 900 activity now though).

I send waves of EXA's into the network. The first wave just reports back the hostnames, then (while sorting from smallest to largest) I send in a) a killer wave to clean up all the COPY -1 M exa's and then b) a new wave that just reports back the #nerv of the specific host when it finds it.

I've been trying other approaches, but interference on the global M registry is what I keep running into.
My fastest solution to the wave problem trades code size for speed and activity: I simply have 4 different marks, one for each direction. Each steps in it's direction and then only spawn exas for the other 3.

The whole solution basically works in 4 stages:

1) a wave of exas that transmit(global) back their hostname and stick around

2) several waves of exas that report(local) all those hostnames to the exas from 1) . Those count how many are smaller. This is that hosts position in the final list. (A massively parallel insertion sort)

3) transmitting(global) sync signals to have all of the exas from 1) enter phase 4) at the same time

4) have each exa waiting for a time proportional to the position in the list then transmit(global) hostname and value. The master simply writes them to file in the order they come in.

Works out to 182 / 135 / 113

Edit: Just realised I'm sorting in O(n). Neat.
Originally posted by PsyBlade:
2) several waves of exas that report(local) all those hostnames to the exas from 1) . Those count how many are smaller.
huh, smart. And I thought I'm doing well with 903 cycles and gnome sorting.
< >
Showing 1-15 of 25 comments
Per page: 1530 50