The Let's Play Archive

EXAPUNKS

by Carbon dioxide

Part 24: Mitsuzen HDI-10 - Left hand

Part 24 - Mitsuzen HDI-10 - Left hand

=== Trash World Inbox ===

Thanks cardinale and biosterous for the nonogram submissions.

biosterous posted:


I'm not entirely sure what it depicts. It kinda looks like a disk in a cartridge, but it doesn't have the same shape as the Redshift disks. It might be for something we have yet to see.


=== Mitsuzen HDI-10 - Left hand ===


Do you like it? Winning?



All votes went to "Sure".

Sure.

Of course.
That's how human brains are designed, aren't they?
To like winning. So that you will always try to win.
It's a very simple design.
Any time I start to discredit myself for being too simple, I think about human brains and feel a little better.


Oof.



I mean, I don't know about clones, but the main problem with most conspiracy theories is that they assume a level of government competence we've never seen in real life, so I'll have to give hydro credit for that, at least.



Anyway, I need to take a break for a moment and first do something about my Phage infection.

First it was your arm... now it's your hand.



Three votes for "It's getting bad".

Yeah, it's getting bad.

I can see that.
Fortunately, it looks like you can easily access the nodes connected to your median nerve.
You'll just need to make a small incision in your ventral forearm.
Better watch out for that artery, though.




This is one of those choices where all options lead to the same dialogue.

Ugh.

Sounds like you're getting used to this.
That's good. It's nothing to be squeamish about.



OST: EXA Power

All right, here's what I need to do.

- There are three nerve signals that need to be relayed: muscle control (M), which runs from your central nervous system (CNS) to your hand (HND) and heat (H) and pressure (P), which run the other direction.
- For each signal, read a value from the input nerve and relay it to the output nerve. Repeat
ad infinitum.
- It is not necessary to leave no trace. Your EXAs should be written to operate indefinitely.
- For more information see "Debugging the Phage" in the first issue of the zine.


Hmm. Looks like the main challenge is one of 'bandwidth'. Using the M register is usually fast, but you can only have one global signal per cycle. Having EXAs running back and forth is slower, but you can have multiple, with the limit being that you can only have one EXA traverse any specific LINK at one time.

I think I'll start with the M solution and try to start optimizing for low activity since that seems easy, if not very fast.

Now, sending messages from all three nerves in parallel is hard. Getting that synced up so the right EXA gets the right message.
So, what if we make it simpler and just... don't?

For the low activity we need to start with one EXA and REPL from there to have the minimum amount of LINKs.

code:
LINK 800

REPL RIGHT
; LEFT
COPY -3 X
LINK -3
LINK -3

MARK RIGHT
COPY 3 X
LINK X
LINK X
This gets the original EXA (LEFT) to M-CNS, and the RIGHT one to M-HND. You'll see in a bit why I am using X for this.

Next, the LEFT EXA starts sending and the RIGHT one starts receiving, exactly 14 signals.

code:
LINK 800

REPL RIGHT
; LEFT
COPY -3 X
LINK -3
LINK -3

MARK SEND
COPY 14 T

MARK SENDLP
COPY #NERV M
SUBI T 1 T
TJMP SENDLP

MARK RIGHT
COPY 3 X
LINK X
LINK X

MARK RECEIVE
COPY 14 T

MARK RECEIVELP
COPY M #NERV
SUBI T 1 T
TJMP RECEIVELP
Just a couple countdown loops like we've seen before. Why 14? Well, that's the ugly hack I'm using here. The assignment's tests mark a program as OK when for each nerve 14 signals have been relayed. It doesn't care about the fact that my hand will fall off or something, and losing my hand is certainly worth it when aiming for some meaningless high score.

After "completing" the M nerve, it's time to LINK to the next nerves. Importantly, the RIGHT EXA needs to switch to sending and the LEFT one to receiving. When 14 signals have been sent in that round, they need to move on once more, but then RIGHT needs to keep sending. So I need a contextual swap of some sort.

Here is the complete working program.



This is where the X register comes in use. Once either the SENDLP or RECEIVELP loops are done, the EXA LINK to the next host in its direction (as stored in X), and then uses the value of X to determine whether it should be sending or receiving. So, in summary:
- In the first iteration, LEFT starts out sending and RIGHT starts out receiving.
- In the second iteration, the above test is first run, which sets RIGHT to sending and LEFT to receiving.
- In the third iteration, the test is run again, keeping RIGHT to sending and LEFT to receiving.
- After that, if the test didn't cut off the program after getting all expected signals, the EXA would try to link to a non-existent host and die.



This leads to a strange solution where the nerve signals are handled nerve by nerve.



Results: 181/29/9. The top percentile scores stand at 37, 24, and 9 respectively.

I can make a small size improvement by moving some LINK instructions to inside the SEND and RECEIVE marks.

code:
LINK 800

REPL RIGHT
; LEFT
COPY -3 X
LINK X

MARK SEND
LINK X
COPY 14 T

MARK SENDLP
COPY #NERV M
SUBI T 1 T
TJMP SENDLP

TEST X = 3
TJMP SEND

MARK RECEIVE
LINK X
COPY 14 T

MARK RECEIVELP
COPY M #NERV
SUBI T 1 T
TJMP RECEIVELP

TEST X = -3
TJMP RECEIVE

JUMP SEND


MARK RIGHT
COPY 3 X
LINK X
JUMP RECEIVE
181/27/9. I feel like this might be the right approach to get to the smallest size. There's actually some duplicate code in there. But I can't quite figure out how to get rid of it.

Let's look at cycle count instead.

My first idea involved files. I'm still using the "we only need 14 signals" hack, but this time, three EXAs read 14 signals each into a file, take that to the recipient nerve and write from the files to there. I unrolled as many loops as I could, although the fact that the different EXAs need to move in different ways makes it hard to keep track of their state.

code:
LINK 800
REPL LEFT

LINK 3
LINK 3
LINK 3
REPL H

LINK 3

MARK READ
MAKE
@REP 14
COPY #NERV F
@END

TJMP SKIP
LINK -3
LINK -3

MARK SKIP
@REP 6
LINK -3
@END

MARK WRITE
SEEK -9999
@REP 14
COPY F #NERV
@END

MARK H
COPY 1 T
JUMP READ


MARK LEFT
LINK -3
LINK -3
MAKE

COPY 2 T

MARK READ2
@REP 7
COPY #NERV F
@END
SUBI T 1 T
TJMP READ2

@REP 4
LINK 3
@END

JUMP WRITE
The top half of this code handles the right-going EXAs (for H and P). H is REPL'd and sets a flag in T, while P LINKs to its node. They then read the 14 entries to a file, and, making use of the flag that was set in T, they make their way to their receiving nodes, after which they just write the data from the file. LEFT uses a copy of the file code so that afterwards it can LINK the right way without any additional logic.

After the EXAs are done they fall through into some other code that tries to do things, but it doesn't matter, by then the tests have finished.

Runs at 47/72/24, which is still 10 whole cycles away from the top percentile. Most of it wasted on walking back and forth. I think I can't get any better without involving the M register.

At this point I realized that while syncing the M register is hard with three pairs of EXAs, it's surprisingly easy with two. Since an M communication step always takes two cycles (for the first EXA to publish it and then for the second to read it), using two pairs you can send one message each cycle, as long as you make sure to alternate every cycle.

So, what if we change two of the nerves to make use of M, while keeping the 'file transfer protocol' EXA for the third one? Because walking takes so much time, it's probably best to use the file EXA for the M nerve, since that one's closest.

I'll show you the end result because my intermediates were very confusing, dirty code.



XA is the file EXA. It's now much simpler after I removed all the logic. LINK to M-CNS, read 14 values, LINK to M-HND and write them.

XB handles the two other nerves. The rightbound (top half) part simply goes to the nerves and starts reading from them. Notice that the furthest EXA is exactly one cycle off from the other one (through the LINK 3 just after the REPL, so the H nerve starts sending first, causing the P one to wait a cycle, and then send, and since there's no loops or anything, just 14 repetitions of the COPY to M, they will keep alternating.

For the left side, the two EXAs also are one cycle out of sync, but there it's required to use an actual two-cycle loop. If they read from M every single cycle, which EXA reads what becomes completely unpredictable.

This solution started off as a one-EXA one too, but I noticed that after I'd cleaned up the code, the file transfer was the bottleneck by just a few cycles. Making it into a dedicated EXA solved this by removing the need for it to REPL several times. I still had to make sure to send it ahead of XB.

Anyway, this runs at a nice score of 37/70/19.



By the way, from this solution it isn't too hard to make something that actually keeps running forever, although it'll be slightly slower.

code:
;XA

LINK 800

MARK START

LINK -3
LINK -3

MAKE
MARK READ
@REP 7
COPY #NERV F
@END

@REP 4
LINK 3
@END

SEEK -9999
@REP 7
COPY F #NERV
@END

LINK -3
LINK -3
WIPE
JUMP START

;XB

NOOP
LINK 800
REPL LEFT

LINK 3
LINK 3
LINK 3

REPL MREADLOOP
LINK 3
MARK MREADLOOP
@REP 9
COPY #NERV M
@END
JUMP MREADLOOP


MARK LEFT
LINK -3
LINK -3
LINK -3
REPL MWRITELOOP
LINK -3

MARK MWRITELOOP
@REP 9
COPY M #NERV
NOOP
@END
JUMP MWRITELOOP
All I did was put a big loop around XA that resets it, and also make XB's MREADLOOP an actual loop. This means every so often MREADLOOP takes an additional cycle, so I had to unroll the MWRITELOOP to the same amount, and add a NOOP so the 2-cycle read keeps working. The REP amounts don't really matter as long as the read/write REPs within each EXA are the same. The above code runs at 49/74/24 in case you're interested.


I have the top percentile score in cycles and activity, but didn't quite get it in size. As always it'll be interesting to see what you come up with.

Do you ever feel like it's a losing battle?
This constant effort to maintain your physical body.




The first vote.

Next time, we'll finally get to take a look at this video game Isadora got us from Japan, a game for the Sawayama WonderDisc console. Let's see what Ember has to say.

WonderDisc games are restricted by region locks.
Why?




And that's the second vote.