The Let's Play Archive

EXAPUNKS

by Carbon dioxide

Part 32: Equity First Bank - Money Transfer

Part 32 - Equity First Bank - Money Transfer

=== Trash World Inbox ===

silentsnack has some nice improvements again for KGOG-TV.

silentsnack posted:

small solution
code:
;XA
GRAB 300
LINK 800
LINK 799
VOID F
COPY F X

LINK 800
MARK A_LOOP
SUBI X #AZIM T
COPY T #MOTR
TJMP A_LOOP
LINK -1

VOID F
COPY F X
VOID F
COPY F #FREQ
WIPE

LINK 801
MARK E_LOOP
SUBI X #ELEV T
COPY T #MOTR
TJMP E_LOOP
VOID M

;XB
LINK 800
COPY 0 M
MARK KEY_RESET
GRAB 199
MARK KEY_LOOP
SUBI F 5000 X
SUBI X 5000 X
REPL CODEC
JUMP KEY_LOOP


MARK CODEC
LINK -1
GRAB 301
VOID F
ADDI X F X
DROP
LINK 800
REPL KEY_RESET

LINK 799
TEST X < 0
MULI T 5000 T
ADDI X T X
ADDI X T #DATA
327/44/102
There's a lot of smart stuff going on here. XA moves into the #AZIM host and back, which I guess takes less lines than making a REPL. It then stores the #ELEV value in X, sets the frequency, goes to move the elevation, and then messages on M when it's done.

XB grabs the key file, gets a value each round and subtracts 10000 to prevent overflow, then makes a REPL which goes back to get the data. Since the repl can use VOID F to remove values it already read, there's no need to keep track of where in the data file we are. The EXA also drops a new KEY_RESET EXA in case the main XB is at the end of the file. Usually KEY_RESET dies immediately because the file isn't available, but if it grabs it, the pointer is at the beginning of the file so no SEEKs are necessary.

silentsnack posted:

fast solution:
code:
;XA- MY AZIMUTH CAN'T BE
;THE RATE-LIMITNG STEP
LINK 800
LINK 799
LINK 800
COPY M X
MARK A_LOOP
@REP 8
SUBI X #AZIM #MOTR
@END
TEST X = #AZIM
FJMP A_LOOP

;XB- I GOT SENT TO THE
;UPLINK HOST AND NOW I'M
;STUCK BUFFERING OUTPUT
GRAB 300
VOID F
COPY F M
LINK 800
LINK 799

COPY 15 T
REPL DATA

VOID F
COPY F X
VOID F
COPY F #FREQ
WIPE
LINK 801
MARK E_LOOP
SUBI X #ELEV #MOTR
SUBI X #ELEV T
MODI 1 T #MOTR
JUMP E_LOOP


MARK DATA
MODI -2 T T
MAKE
COPY M F
COPY M F
FJMP LAST
COPY M F
REPL DATA

MARK WAIT_ALIGN
SUBI T 1 T
TJMP WAIT_ALIGN

SEEK -3
@REP 3
COPY F #DATA
@END
WIPE

MARK LAST
SEEK -2
@REP 2
COPY F #DATA
@END
WIPE
COPY M #DATA

;XC- LET'S TRANSMIT THE
;DATA IMMEDIATELY!!
GRAB 301
LINK 800
VOID F
MARK READ_LOOP
@REP 3
ADDI F M X; LOCAL
REPL ENCODE
@END
JUMP READ_LOOP

MARK ENCODE
LINK -1
TEST X < 0
MULI T 5000 T
ADDI X T X
MODE
ADDI X T M;GLOBAL

;XD- DO  STUPID SELF-
;-REFERENCING JOKES
;DREAM OF BREAKING
;THE FOURTH WALL?
LINK 800
REPL START

COPY 33 T
MARK WAIT_CLEANUP
SUBI T 1 T
TJMP WAIT_CLEANUP
KILL
KILL
KILL
KILL
GRAB 301
LINK -1
HALT

MARK KEY_OUT
SUBI X 5000 M;LOCAL
;GRAB?? OR CRASH
MARK START
GRAB 199
SUBI F 5000 X
MARK KEY_LOOP
@REP 3
REPL KEY_OUT
SUBI F 5000 X
@END
JUMP KEY_LOOP
81/99/37
A and B have to start in GLOBAL mode, C and D in LOCAL.

81 cycles... how???
Seriously, this code is very hard to understand.
For the dish, you found a way to unroll the loop by sending the difference between the expected and actual value to the #MOTR. It won't move more than one step at a time, even if you send a larger number, but once it's zero you know you're done.

Other than that this solution is mostly very well-timed parallellism. XB makes a whole bunch of copies, each of them buffering 3 values in a file and them sending it to #DATA without any cycles wasted. Somehow it all lines up.


=== Equity First Bank - Money Transfer ===

Well, what did you think?



Two votes for the same option.

I'm not sure I understand it.

That's okay...
Great art is often mysterious.
If you want to know the truth, though, that video was just some garbage data I had lying around.
I just thought it would be fun to broadcast.


You have a unique sense of fun, Ember.



But, I guess you were noticed.




Next up, I'm gonna go to Equity First again. That's the bank where I messed with the ATMs a while ago. Hacking banks is a bit iffy but it might solve my money troubles once and for all.

Okay, no more trying to find shortcuts.
Time for a brute-force solution to the money problem.
I know you like messing around with bank systems...




Another unanimous vote.

Hacking those ATMs was your idea.

Well, you get to do it again!
This time with a little more urgency.



OST: Leave No Trace

The assignment:

- Move EMBER-2's new account (file 300) into checking. Then iterate over the checking accounts listed in the directory (file 199) and, in that order, transfer $1.00 from each target account to EMBER-2's account. Finally, add the file ID of EMBER-2's account file to the end of the directory.
- The keywords CREDIT and DEBIT are available in file 301.
- For more information see "Network Exploration: Equity First Bank" in the first issue of the zine.


Well, this is the same network as before, but they have disconnected all the ATMs. Perhaps I caused more trouble than I thought.

Since we didn't do anything with the files last time, let's read up on them again.


In short, I shouldn't mess with the first 4 values in any account file. To add a transaction from account X to Ember, I need to add a DEBIT transaction line to account X's file, with Ember's account number and the amount. I also need to add a CREDIT transaction with account X's number and the same amount to Ember's file.

The assignment says to do this for checking accounts, so no need to touch the loans. Let's get started.

I'll need the DEBIT and CREDIT keywords, but since they're only two values I think I can bring them along in X and T, which would save an EXA or a lot of M back and forth.
code:
GRAB 301
COPY F X
COPY F T
DROP
GRAB 300
LINK 800
LINK 800
Now my EXA is in the checking host, with Credit in X, and Debit in T. It's also holding Ember's account file. To do anything more I'm gonna need REPLs.
code:
REPL DIRECTORY
COPY F T
SEEK 9999
MODE

MARK EMBERWRLOOP
COPY M F
COPY X F
COPY 1 F
COPY 0 F
COPY T M
JUMP EMBERWRLOOP
I'll get to the directory EXA in a second. It still has Debit in T, so this main EXA can now use T to hold Ember's account number. After that it switches communication mode, goes to the end of the file, waits for an account number to come in on M, writes that, followed by Debit, and 1 dollar and 0 cents. Finally, it sends Ember's account number so the other side can credit the sending account.

code:
MARK DIRECTORY
GRAB 199
COPY T X
MARK NEXTACCOUNT
COPY F T
REPL TRANSACTION
TEST EOF
VOID M
FJMP NEXTACCOUNT

COPY 300 F
KILL
The directory EXA grabs file 199 which is the directory. It moves the Debit keyword to X to make some space for testing. Then it makes a transaction EXA for each account, waiting for a message on M before it makes the next (so that the transfers happen in the right order).

At the EOF it writes Ember's file id to the directory to officially register it, and kills the EMBERWRLOOP EXA.



The final part is the TRANSACTION EXA. It grabs the account file, copies the account ID to EMBERWRLOOP, and adds the $1.00 Credit transaction line to the end of the file. It messages the DIRECTORY EXA when it's done.

Note that the messages between Ember's account and the other accounts are in local mode while the "I'm done" message from the transaction EXA is in global mode. All EXAs are in the same host so it doesn't matter what modes these EXAs start in, but I need both modes to prevent messages getting mixed up.



This initial solution scores 158/40/3. Top percentiles are 55, 40, and 2.

I'm pretty sure there's some smart tricks to save a couple lines. For instance, the file IDs in 199 seem to be in order so you could just loop through all of them. But, you know, I'm happy with top percentile score on size, and I'll leave it to the thread to go beyond.

Let's get the activity down instead. There's only one way to do so - remove that KILL instruction.

I can replace the end of the DIRECTORY code with
code:
COPY 300 F
MODE
COPY 0 M
Now it will send a 0 to the EMBERWRLOOP. So it has to test if the incoming message is zero and die if that's the case. However, that EXA already got X and T occupied (with CREDIT and Ember's account number). Since I don't care about size or cycles for the low-activity solution, let's just write the value to F and test on that:
code:
MARK EMBERWRLOOP
COPY M F
SEEK -1
TEST F = 0
TJMP FINISH
COPY X F
COPY 1 F
COPY 0 F
SEEK -9999
COPY F M
SEEK 9999
JUMP EMBERWRLOOP

MARK FINISH
SEEK -1
VOID F
It also seeks back to the beginning repeatedly just to send Ember's account number, and it has to delete that leftover zero from the file at the end. 197/48/2.

I don't like this slow code, so let's quickly go back to the previous 3-activity solution and look into lowering the cycle count.

The easiest improvement is to not have the transaction EXA wait so long for the Ember EXA, by moving the step where it sends the account number.
code:
MARK EMBERWRLOOP
COPY M F
COPY T M
COPY X F
COPY 1 F
COPY 0 F
JUMP EMBERWRLOOP
134/40/3

Next, we have to look into parallellism.
code:
;XA

GRAB 300
LINK 800
LINK 800
COPY M X
MODE
REPL DIRECTORY
COPY F T

MARK EMBERWRLOOP
COPY T M
JUMP EMBERWRLOOP

MARK EMBERAC
MODE
COPY M X
MODE
GRAB 300
SEEK 4
MARK EMBERACLOOP
COPY M F

COPY X F
COPY 1 F
COPY 0 F
JUMP EMBERACLOOP


MARK DIRECTORY
GRAB 199
MARK NEXTACCOUNT
COPY F T
REPL CREDIT
TEST EOF
FJMP NEXTACCOUNT

NOOP
NOOP
NOOP
NOOP
KILL

REPL EMBERAC
SEEK -9999
MARK NEXTACCOUNT2
COPY F T
NOOP
REPL GETACCOUNT
TEST EOF
FJMP NEXTACCOUNT2

COPY 300 F
NOOP
NOOP
KILL

MARK CREDIT
GRAB T

SEEK 9999
COPY M F
COPY X F
COPY 1 F
COPY 0 F

MARK GETACCOUNT
GRAB T
COPY F M

;XB

GRAB 301
SEEK 1
COPY F M
SEEK -9999
COPY F M
92/61/4.

XB first sends Debit in global mode, then Credit.

XA makes a REPL still called EMBERWRLOOP which doesn't actually write anymore, it just sends the account number repeatedly. This way, the CREDIT EXAs can just write the $1.00 transaction to all accounts at once. After that is done, we loop through 199 again, grab the files again, and send the account numbers to EMBERAC, who writes the debit lines to Ember's account.

A few more cycles can be won by preparing the Ember Ac Loop ahead of time.


88/55/4

As it stands, unrolling loops doesn't do much because the M timing is rather specific and messing with it tends to break things. I do have a bunch of other ideas. For instance, preparing Ember's account file with transactions with dummy account numbers and then fixing them later might save a couple cycles. Or making use of the fact there's always at least 5 accounts. But no matter what I tried, the transactions ended up in the wrong order.

The timing is tough on this one. 88 isn't even the tenth percentile, but I'm afraid I'm going to stop it here anyway.

Defrauding the bank...
That's textbook crime, isn't it?
Not to worry, your secret's safe with me.




Straight to the vote.






Before I move on to the next assignment, Nivas is here.



Delivery...

Nivas hands me the medication.
This time it's the real version that was "liberated" from the drug company...
I thought it might look more impressive than the bootleg, but it's basically the same.

To be honest, I thought I probably wouldn't see you again.
Didn't think you'd be able to put that kind of money together.
So whatever you did... respect.

Nivas hands me another package of the medication... and another.

These are advance deliveries.
I think... I think I need to take it easy for a while.
The whole thing with the operation we did, those people I mentioned...
It got a little hot for me.
I'm gonna lay low for a bit.
I might do some reading, think about the world we live in...
For some reason I'm in kind of a spiritual mood lately.
Anyway, nice doing business with you.
Take care of yourself.

Nivas closes the door, leaving me with the rest of the medicine.
Interesting character.
Everyone's doing what they can in order to survive...


I hope Nivas is gonna be okay.

Well, at least my medicine problem is solved for the forseeable future.

For next time, there's another hacker battle coming up.

If you keep on winning, they'll eventually have to accept that you're back.