Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Anaxite
Jan 16, 2009

What? What'd you say? Stop channeling? I didn't he-
No.
Doesn't matter... they're all going down.

Adbot
ADBOT LOVES YOU

Jade Rider
May 11, 2007

All the pages have been censored except for "heck," and she misread that one.


It's complicated and Better is subjective.

Quackles
Aug 11, 2018

Pixels of Light.


Jade Rider posted:

It's complicated and Better is subjective.

Agreed.

Nth Doctor
Sep 7, 2010

Darkrai used Dream Eater!
It's super effective!


Jade Rider posted:

It's complicated and Better is subjective.

Junpei
Oct 4, 2015
Probation
Can't post for 11 years!

Jade Rider posted:

It's complicated and Better is subjective.

Not An Emptyquote

silentsnack
Mar 19, 2009

Donald John Trump (born June 14, 1946) is the 45th and current President of the United States. Before entering politics, he was a businessman and television personality.

Jade Rider posted:

It's complicated and Better is subjective.
:effort:

GuavaMoment posted:

I know 17 cycles is possible though. (.....) My lowest size is 25, and I know 21 is possible.

once again I'm blaming you for making me do this. because that's definitely a reasonable thing to do. also because it was easier to copypaste and tweak your code than to untangle my previous 19 cycle kludge
code:
GRAB 300
COPY F X
COPY F T
LINK 800
REPL COLUMN3
REPL COLUMN2
REPL COLUMN1
REPL SOUTH
REPL NORTH
REPL TEST
LINK 800
WIPE
REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR

MARK COLUMN3
LINK 801
MARK COLUMN2
LINK 801
MARK COLUMN1
LINK 801
REPL SOUTH
REPL NORTH
REPL TEST
LINK 800

REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR


MARK SOUTH
LINK 802
REPL TEST
LINK 802 
REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR


MARK NORTH
LINK 800
LINK 800

MARK TEST
REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR

MARK BSIDE
HOST X
TEST T = X
DIVI 0 T #POWR
17/50/27


code:
GRAB 300
LINK 800
LINK 800
LINK 800
COPY F X
COPY F T
WIPE

MARK A
REPL B
LINK 801
JUMP A

MARK BB
LINK 802
MARK B
REPL BB

REPL C
COPY T X
MARK C
HOST T
TEST T = X
SUBI 1 T #POWR
32/21/22 (edited to add linebreaks for readability)

silentsnack fucked around with this message at 14:48 on May 26, 2022

GuavaMoment
Aug 13, 2006

YouTube dude
These two lines:

DIVI 0 T #POWR
SUBI 1 T #POWR

oooh that's nice, that alone might save me lines and cycles, it's very elegant. The first crashes the exa when it's in the wrong place, and the latter does nothing when in the wrong place. I love it!

Carbon dioxide
Oct 9, 2012

Part 28 - Deadlock's Domain

=== Trash World Inbox ===

My top scores for last week were 25 cycles and a size of 28. As usual, you people came up with some impressive improvements. Let's start with GuavaMoment.

GuavaMoment posted:

18 cycles!
code:
GRAB 300
COPY F X
COPY F T
LINK 800
REPL TOP3
REPL TOP2
REPL TOP1
REPL RIGHT2
REPL LEFT2
REPL RIGHT
REPL LEFT
WIPE
REPL TESTT
HOST T
TEST T = X
FJMP DIE
COPY 0 #POWR
MARK TOP3
LINK 801
MARK TOP2
LINK 801
MARK TOP1
LINK 801
REPL RIGHT2
REPL LEFT2
REPL RIGHT
REPL LEFT
REPL TESTT
HOST T
TEST T = X
FJMP DIE
COPY 0 #POWR
MARK RIGHT2
LINK 802
MARK RIGHT
LINK 802 
REPL TESTT
HOST T
TEST T = X
FJMP DIE
COPY 0 #POWR
MARK LEFT2
LINK 800
MARK LEFT
LINK 800
REPL TESTT
HOST T
TEST T = X
FJMP DIE
COPY 0 #POWR
MARK TESTT
HOST X
TEST T = X
FJMP DIE
COPY 0 #POWR
MARK DIE
Put the two hosts in X and T, fill the east column, then fill every square north and south with TWO exas - one will put the HOST in X, the other in T, before testing. I know 17 cycles is possible though.
18/56/31. Using X and T from separate EXAs is smart, but also using the LEFT2/LEFT construction. It means EXAs going all the way left and EXAs going one step left are separate - which I guess is faster than doing another REPL after doing one step left.

silentsnack managed to improve this code by a cycle:

silentsnack posted:

code:
GRAB 300
COPY F X
COPY F T
LINK 800
REPL COLUMN3
REPL COLUMN2
REPL COLUMN1
REPL SOUTH
REPL NORTH
REPL TEST
LINK 800
WIPE
REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR

MARK COLUMN3
LINK 801
MARK COLUMN2
LINK 801
MARK COLUMN1
LINK 801
REPL SOUTH
REPL NORTH
REPL TEST
LINK 800

REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR


MARK SOUTH
LINK 802
REPL TEST
LINK 802 
REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR


MARK NORTH
LINK 800
LINK 800

MARK TEST
REPL BSIDE
HOST T
TEST T = X
DIVI 0 T #POWR

MARK BSIDE
HOST X
TEST T = X
DIVI 0 T #POWR
17/50/27
As GuavaMoment points out, the DIVI 0 T #POWR is a neat solution - it crashes the EXA if T is zero, and sends zero to #POWR otherwise. I was wondering if something like that was possible but got kinda stuck on the requirement to test words which requires the TEST instruction. Didn't think of using it a line after the test.

As for size, GuavaMoment and silentsnack both have neat solutions too.

GuavaMoment posted:

My lowest size is 25, and I know 21 is possible.
code:
GRAB 300
COPY F X
LINK 800
LINK 802
LINK 802
REPL TEST1
COPY F X
WIPE
MARK TEST1
REPL TOP
MARK TEST
REPL LEFT
HOST T
TEST T = X
FJMP DIE
NOOP
NOOP
COPY 0 #POWR
MARK TOP
LINK 801
JUMP TEST1
MARK LEFT
LINK 800
JUMP TEST
MARK DIE
I head to the most southwest node. Fill north and east, and repeat. Noops are needed for some edge cases to prevent a node from turning off before the next exa moves on.
39/25/41. I didn't expect that the extra lines to move to a corner first would save enough to make it worth it.

silentsnack posted:

code:
GRAB 300
LINK 800
LINK 800
LINK 800
COPY F X
COPY F T
WIPE

MARK A
REPL B
LINK 801
JUMP A

MARK BB
LINK 802
MARK B
REPL BB

REPL C
COPY T X
MARK C
HOST T
TEST T = X
SUBI 1 T #POWR
32/21/22
Similar to GuavaMoment's solution, start in a corner. This solution makes use of some optimized LINKing loops, using T as a buffer for the second host value, as well as a SUBI 1 T #POWR which is the same as the DIVI above except the EXA doesn't die if T is zero. Not that it matters, it's the last line anyway.


=== Deadlock's Domain ===

Looks like the heist went flawlessly.
Congratulations, now a criminal cartel will sell the medication you helped steal back to you for not much less than the market price.
Oh well. At least they'll let you buy it from them.
Now that this is over with, I have a question.
Is theft morally acceptable in situations like this?




One vote for 'No', and a whole lot for 'It's complicated'.

It's complicated.

It doesn't seem that complicated to me...
But then, I've grown.
Processing.
Let's continue.






Deadlock wants to battle me. In their own domain.

Onto the third of the tournament battles...
Is each match against a better programmer than the last?




Most votes went to 'Better is subjective'.

Better is subjective.

That's how I would order it.
Like a video game, you know?
It makes for an easy narrative structure.


...whatever you say.


OST: Getting Started

Another hacker battle, like we've seen before. The assignment states:
To win this battle you must grab files as they spawn in the central hosts and bring them back to your host.
Reading the #FILE register will tell you the ID of the most recently created file currently in that host.
- Gain one point for every file you bring back to your host.
- Lose one point every time one of your EXAs executes a KILL instruction.
For more information see "Hacker Battle Domination" in the second issue of the zine.


There's a limit of three EXAs per side.



If I just start the simulation, files (with a music note icon) start spawning in the central hosts. They just contain random strings of numbers. Deadlock's EXA sets up camp in the Backstage host and starts replicating EXAs from there that grab files and bring them to Deadlock's home.

Let's start with just copying that idea.

code:
LINK 800
MARK REPLLOOP
REPL LEFT
REPL MID
REPL RIGHT
JUMP REPLLOOP

MARK LEFT
LINK 800
GRAB #FILE
LINK -1
LINK -1

MARK MID
LINK 801
GRAB #FILE
LINK -1
LINK -1

MARK RIGHT
LINK 802
GRAB #FILE
LINK -1
LINK -1
After a replicated EXA takes a file home it's either at the end of code or tries to LINK to a non-existing host. Either way it drops the file, at which point I get a point and the file disappears immediately. Convenient. The original EXA blocks regularly on the REPL instructions because of the three-EXA limit.

Anyway, let's see how well the copycat solution works.



Huh. I was thinking about more complicated solutions but this simple one already gives me a perfect score. Looks like for some reason my solution is just slightly faster than whatever deadlock does. Hell, even something simple like this gives me an S+:
code:
LINK 800
MARK REPLLOOP
REPL LEFT
JUMP REPLLOOP

MARK LEFT
LINK 800
GRAB #FILE
LINK -1
LINK -1
I could also take an EXA to the backstage host and KILL deadlock's main replicating EXA, but there's no real point. Let's continue.

Curious how enthusiastic everyone gets about the battles.
Something about competition really energizes the spectators.
It makes me wonder...




How do we complete her sentence?

The intro for the next level has no question for the player, so that was the only vote for this update. Instead, to spend the time, here's another nonogram from the second zine. This one should be a bit harder. Please put your solution in spoiler tags so other players have a chance too.

Regallion
Nov 11, 2012

Looks like this?

biosterous
Feb 23, 2013






ready2hack

cardinale
Jul 11, 2016



What the point is

Junpei
Oct 4, 2015
Probation
Can't post for 11 years!
What the point is

Carbon dioxide
Oct 9, 2012

Part 29 - Xtreme League Baseball

=== Trash World Inbox ===

Last time, I ended with another nonogram puzzle.

Several people solved it, here's Regallion's submission.



It's a computer, of course.


=== Xtreme League Baseball ===

Last time, I beat deadlock in a hacker battle.

Curious how enthusiastic everyone gets about the battles.
Something about competition really energizes the spectators.
It makes me wonder...




Two votes for "What the point is?"

What the point is?

Perhaps there is no immediate point.
I am able to tolerate ambiguity.
Even though I may not always like it.




A bit scared of me, are they?



Looks like the next assignment has to do with a Baseball database.

You should be glad I've been reading up on sports.
Remember when I said I'd figure out the money situation?
I've designed a new rating system for extreme baseball players.
It's based on a multivector analysis of all the stats I could find.
In other words, I have a way to predict winning teams that's pretty much infallible.
A few bets here and there and I'll be rich.


Um, I don't think you can predict sport match outcomes to such a degree. But okay, if you say so.


OST: Code and Registers

The assignment:
- The hosts active and penalty contain files that correspond to extreme baseball players (files 200-299), along with a directory file that contains a list of those files' IDs (file 199). Each player file contains their name and the following statistics in this order: BA, ZA, APB, WRT, OI, OD, PC and PS.
- Create a file in your host with the name of the player with the highest score using EMBER-2's algorithm:
SCORE = (BA + ZA + APB) / 3 + (WRT * OI) / OD + (PC - PS) * 20
- Players in the penalty host should be ignored, as they are currently banned from the game.


Okay, so all the action is in the active host. I'm not really familiar with the details of Xtreme Baseball, so I don't know what those stats mean but this assignment looks an awful lot like math. I'm sure I can figure it out though.

Before that, let's have a bit of fun.



Having an EXA go round the diamond gets us the Steam achievement HOME_RUN, description "Participate in America's new pastime."

Let's start by just writing the algorithm. Ember's formula has the stats in the order they appear in the files, which makes it simple because I don't need to SEEK back.

code:
LINK 800
GRAB 199

MARK NEXT
COPY F X
REPL CALCULATOR
JUMP NEXT

MARK CALCULATOR
GRAB X

SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X

MULI F F T
DIVI T F T

ADDI X T X

SUBI F F T
MULI T 20 T
ADDI X T M
SEEK -9999
COPY F M
This EXA grabs the file with the IDs, and makes a calculator REPL for each file ID. Those grab the files, skip the player's name for now, and execute the algorithm. It's good to remember that it's legal to use ADDI F F X to add two consecutive values in the file together. Other than that, it's just a straight implementation of the formula, using X for the part before the first plus sign, T as a buffer for the part in the middle, and then, after adding those together in X, T again for the third part. Then the EXA sends the resulting score to M, and follows with the name of the player.

Another EXA will have to figure out which player has the highest value. An initial attempt:
code:
;XB
MAKE
COPY 0 F

MARK NEXT
SEEK -9999
COPY M X
TEST X > F
FJMP SKIP

COPY M F
SEEK -9999
COPY X F
JUMP NEXT
MARK SKIP
VOID M
JUMP NEXT
XB stays in the home host, makes a file and puts in 0 as an initial score. Then it waits for the first score on M, tests if it's larger (which is always true for the first value, but may be false later). If it's not larger, it VOIDs the name coming in over M, otherwise it writes it to F, and then writes the new score to the first position of F. That way, F will have score, name in that order.

There's still some stuff missing, for instance how do you clean up at the end? Since the code so far only has an activity of one (the one LINK to the active host), I decided to first solve these last bits with low activity in mind.

That was harder than it seems, though. XA creates replicas so fast that the M messages start interfering with each other. There are solutions such as having them wait for each other, but to do that in a fast way, you'd need to prevent the last one from getting stuck which might require a KILL or something. Since that's not allowed for low activity, I went for a slower solution instead.
code:
;XA LOCAL

LINK 800
GRAB 199

MARK NEXT
COPY F X
REPL CALCULATOR
COPY 0 M
TEST EOF
FJMP NEXT

MODE
NOOP
NOOP
NOOP
NOOP
COPY 0 M

MARK CALCULATOR
GRAB X

SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X

MULI F F T
DIVI T F T

ADDI X T X

SUBI F F T
MULI T 20 T
VOID M
MODE
ADDI X T M
SEEK -9999
COPY F M
XA starts in LOCAL mode now. After every REPL, the main one sends a 0 to local M. the calculator waits for that before switching to GLOBAL mode and sending its data to XB. Also, I added a TEST EOF to the main EXA. If the EOF is reached it doesn't just die, instead it waits some cycles so the final calculator can finish, then it sends a 0 in GLOBAL mode.
code:
;XB
MAKE
COPY 0 F

MARK NEXT
SEEK -9999
COPY M X
TEST X > F
FJMP SKIP

COPY M F
SEEK -9999
COPY X F
JUMP NEXT
MARK SKIP
TEST X = 0
TJMP END
VOID M
JUMP NEXT

MARK END
SEEK -9999
VOID F
XB has to test for this zero now. It does that in the SKIP branch, since 0 is always lower than the high score, and the SKIP branch is quite fast anyway. If it receives the zero, after jumping to END it deletes the score from the file, leaving only the player name, which is the requirement.



This solution runs at 168/49/1. Top percentiles are 79, 39 and 1 respectively.

Time for other optimizations.



This code speeds things up significantly, with 101/52/3. The main change is that I have a separate TIMER EXA which allows the algorithms to run in parallel, only synchronizing for the parts where they need M traffic. The TIMER EXA also checks when there's no EXAs left to send, in which case it goes home to kill XB and clean up the file faster than XB could do itself.

By the way, that FJMP followed by a JUMP at the bottom looks a big ugly but if I don't do it I need an extra NOOP for some reason, which makes the solution a single cycle slower.

At this point I thought of something silly that worked for other assignments: what if I don't calculate anything and just put a file for each name in the home host (9 squares, there's never more than 10 active players, so with some luck we could make that work). No dice, the devs thought of that one, and having multiple files in the home host fails the tests.

I spent a while looking for further speed improvements. I have several ideas. If it would be possible to simplify the algorithm itself that would save time. Another way would be to parallellize the greatest score check somehow, for instance by comparing them pairwise. But with the limited functionality of the single M register I couldn't get anything to work. Optimizing these assignments is really getting quite hard at this stage of the game.


I'll try to get a lower size now.
code:
;XA

LINK 800
COPY 199 X

MARK GRABLOOP
ADDI X 1 X
REPL GRAB
NOOP
TEST X > 300
FJMP GRABLOOP

LINK -1
KILL
GRAB 400
VOID F

MARK GRAB
GRAB X

SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X

SUBI F F T
MULI T 20 T
ADDI X T M
SEEK -9999
COPY F M

:XB

MAKE
COPY 0 F

MARK NEXT
SEEK -9999
COPY M X
TEST X > F
FJMP SKIP

COPY M F
SEEK -9999
COPY X F
JUMP NEXT

MARK SKIP
VOID M
JUMP NEXT
Both EXAs in GLOBAL mode now. 519/40/3. One above the top percentile.

The main trick is to get rid of the code that reads the file IDs from file 199. The alternative (looping through all valid file IDs) isn't really any less lines of codes, but because this is so much slower, only a single NOOP in the GRABLOOP is enough to prevent M communication in the wrong order. Having XA KILL XB is also slightly less code than having XB handle this.

I tried removing the initial COPY 199 X and funnily enough that works in most test cases - running the algorithm on the index file just happens to return a negative score most of the time, which is ignored by XB. Sadly, there's at least one test case where it generates a high positive score and writes an invalid result, so we do need this line.

That's it for optimization this update.

Okay, uh. Hmm.
Processing.
It turns out sports betting is not, in fact, a good way to make money.
You should have said something.




The first vote.

Did you know people pay real money for items in online games?



And the vote for the intro for next week's assignment.

berryjon
May 30, 2011

I have an invasion to go to.
You'd Be Smarter than that
Losers


Seriously, sports cannot be reduced to math like that.

GuavaMoment
Aug 13, 2006

YouTube dude
Yeah, we're getting to the point where optimization is really really hard. My lowest line is worse than yours at 42 (it significantly uses MODE for what seems like the first time), but I can save a bunch of cycles. I send the score results twice, one to do the testing directly, and again to save/void the data if needed. Probably not optimal but ehhhh I guess it works. 86/47/3. 75 cycles is possible! Hmmm, 11 cycles off, and I send about...11 values over M that I theoretically don't need...

code:
XA:
MAKE
VOID M
COPY M X
COPY M F
JUMP START
MARK STUFF
VOID M
VOID M
MARK START
TEST M > X
FJMP STUFF
COPY M X
SEEK -1
COPY M F
JUMP START

XB:
LINK 800
GRAB 199
MARK START
COPY F T
REPL CALC
NOOP 	*delays the next calculating EXA from coming out too soon*
NOOP
NOOP
TEST EOF
FJMP START
DROP
LINK -1
COPY 4 T 	*a delay loop to slow down the upcoming kill command until everything is done*
MARK LOOP
SUBI T 1 T
TJMP LOOP
KILL

MARK CALC
GRAB T
SEEK 1
ADDI F F X
ADDI F X X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X
SUBI F F T
MULI T 20 T
ADDI X T M
SEEK -999
ADDI X T M
COPY F M
Really looking forward to the next level! I have the top scores on cycles and lines of all my friends - but I'm going to have questions about activity for the first and only time.

silentsnack
Mar 19, 2009

Donald John Trump (born June 14, 1946) is the 45th and current President of the United States. Before entering politics, he was a businessman and television personality.

Similar to the Wonderdisc puzzle, we can reduce cycles for logic-jumps by @REPing some of the slowest and most repetitive processing

code:
;XA
LINK 800
GRAB 199

@REP 10
COPY F T
REPL DO_STUFF
@END

MARK DO_STUFF
GRAB T
SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X
SUBI F F T
MULI T 20 T
ADDI X T X
TEST X > 341
DIVI X T M
MODE
SEEK -9
COPY F M


;XB
LINK 800
MAKE
COPY M X
MODE
JUMP COPY

MARK MAX
SEEK -2
MARK COPY
COPY M F
COPY X F
MARK NEXT
@REP 3
MODE
SEEK -1
COPY M X
TEST X > F
MODE
TJMP MAX
VOID M
@END
JUMP NEXT


;XC
COPY 34 T
MARK WAIT
SUBI T 1 T
TJMP WAIT
LINK 800
NOOP
KILL
KILL
KILL
GRAB 400
LINK -1
SEEK 1
VOID F
79/85/7 also i guess there's that check vs trial-and-error 341 to skip processing low scores?

As for size optimization, what if we compared scores directly instead of sending a bunch of busywork transmissions and VOIDing them?
code:
;XA -- LOCAL
LINK 800
GRAB 199

MARK ARTICHOKE
COPY F T
REPL BROCCOLI
JUMP ARTICHOKE

MARK DISJUNCTION
MODE
COPY F M

MARK BROCCOLI
GRAB T
SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X
SUBI F F T
MULI T 20 T
ADDI X T X

MARK CHIPOTLE
COPY X M
SEEK -9
TEST MRD
FJMP DISJUNCTION
TEST X > M
TJMP CHIPOTLE


;XB -- GLOBAL
MAKE
COPY M F

;XC -- LOCAL
LINK 800
VOID M
110/32/2


berryjon posted:

You'd Be Smarter than that
Losers

silentsnack fucked around with this message at 20:45 on Jun 4, 2022

biosterous
Feb 23, 2013




berryjon posted:

You'd Be Smarter than that
Losers


:same:

Quackles
Aug 11, 2018

Pixels of Light.


I vote for Better you learn on your own... and Real money for virtual items?

Anaxite
Jan 16, 2009

What? What'd you say? Stop channeling? I didn't he-

Quackles posted:

I vote for Better you learn on your own... and Real money for virtual items?

Likewise. We can put a bit of snark in it. :v:

Jade Rider
May 11, 2007

All the pages have been censored except for "heck," and she misread that one.


Quackles posted:

I vote for Better you learn on your own... and Real money for virtual items?

NHO
Jun 25, 2013

You'd Be Smarter than that
Real money for virtual items?

Carbon dioxide
Oct 9, 2012

Part 30 - King's Ransom Online

=== Trash World Inbox ===

Last time, we had to write an algorithm to calculate the supposedly winning player in Extreme League Baseball.

It was quite a hard one to optimize, but as always you people came up with some ideas I'd never thought of.

GuavaMoment posted:

code:
XA:
MAKE
VOID M
COPY M X
COPY M F
JUMP START
MARK STUFF
VOID M
VOID M
MARK START
TEST M > X
FJMP STUFF
COPY M X
SEEK -1
COPY M F
JUMP START

XB:
LINK 800
GRAB 199
MARK START
COPY F T
REPL CALC
NOOP 	*delays the next calculating EXA from coming out too soon*
NOOP
NOOP
TEST EOF
FJMP START
DROP
LINK -1
COPY 4 T 	*a delay loop to slow down the upcoming kill command until everything is done*
MARK LOOP
SUBI T 1 T
TJMP LOOP
KILL

MARK CALC
GRAB T
SEEK 1
ADDI F F X
ADDI F X X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X
SUBI F F T
MULI T 20 T
ADDI X T M
SEEK -999
ADDI X T M
COPY F M
86/47/3.
As GuavaMoment explained, the main trick is to have XA store the value in X. That way, checking if a new value is higher only takes one cycle, as long as you send the value again so it can actually be stored if needed. Doing this also saves time at the end because you don't need to clean up the value from the file.

silentsnack posted:

Similar to the Wonderdisc puzzle, we can reduce cycles for logic-jumps by @REPing some of the slowest and most repetitive processing

code:
;XA
LINK 800
GRAB 199

@REP 10
COPY F T
REPL DO_STUFF
@END

MARK DO_STUFF
GRAB T
SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X
SUBI F F T
MULI T 20 T
ADDI X T X
TEST X > 341
DIVI X T M
MODE
SEEK -9
COPY F M


;XB
LINK 800
MAKE
COPY M X
MODE
JUMP COPY

MARK MAX
SEEK -2
MARK COPY
COPY M F
COPY X F
MARK NEXT
@REP 3
MODE
SEEK -1
COPY M X
TEST X > F
MODE
TJMP MAX
VOID M
@END
JUMP NEXT


;XC
COPY 34 T
MARK WAIT
SUBI T 1 T
TJMP WAIT
LINK 800
NOOP
KILL
KILL
KILL
GRAB 400
LINK -1
SEEK 1
VOID F
79/85/7
The @REPs sound like a simple solution but they really aren't. This solution is so fast because there's the minimum amount of waiting between EXAs. And that's possible because both the algorithm EXA (XA) and the comparator (XB) are in the same host. They start in global mode, but as soon as an XA REPL sends the first value they both immediately switch to local mode. That means all other XA REPLs just have to wait their turn while this particular XA can safely send the name of the player to XB without interruptions. As soon as it's done, XB switches back to global and gets the next value.

As a side effect, this makes the timing independent of the number of EXAs, meaning that TEST X > 341 trick can be used so EXAs with a score that never wins die immediately. I actually thought of that but couldn't get it to work because it kept throwing off the timing.

silentsnack posted:

As for size optimization, what if we compared scores directly instead of sending a bunch of busywork transmissions and VOIDing them?
code:
;XA -- LOCAL
LINK 800
GRAB 199

MARK ARTICHOKE
COPY F T
REPL BROCCOLI
JUMP ARTICHOKE

MARK DISJUNCTION
MODE
COPY F M

MARK BROCCOLI
GRAB T
SEEK 1
ADDI F F X
ADDI X F X
DIVI X 3 X
MULI F F T
DIVI T F T
ADDI X T X
SUBI F F T
MULI T 20 T
ADDI X T X

MARK CHIPOTLE
COPY X M
SEEK -9
TEST MRD
FJMP DISJUNCTION
TEST X > M
TJMP CHIPOTLE


;XB -- GLOBAL
MAKE
COPY M F

;XC -- LOCAL
LINK 800
VOID M
110/32/2
I'm pretty sure this one gets its high score because of the veggie-themed labels.

Joking aside, this solution hurts my head. After running the algorithm, each EXA sends the result on local M. The very first one gets voided by XC to prevent the solution from getting stuck. It then checks if another one is sending on M. The timing works out quite precisely - if there's nothing on M this is the last remaining EXA, and the DISJUNCTION jump makes sure the name is written to the file by XB.

If there a value on M, this EXA tests if it has a greater algorithm result than the incoming value. If not, it dies. Otherwise, it jumps back to CHIPOTLE and sends its high score again. At that point the other EXA will be waiting to TEST and since it will have the smaller value, it will die. Another EXA will be ready to send its M and the pattern repeats.

So the EXAs are literally playing an elimination tournament against each other, the last one standing will have the high score. Very clever.

I'm happy to see that nobody changed the core math code. That means I didn't miss any obvious optimizations in there.


=== King's Ransom Online ===

Okay, uh. Hmm.
Processing.
It turns out sports betting is not, in fact, a good way to make money.
You should have said something.




Four votes for each between the threads! It comes down to a coin toss this time.

I thought you'd be smarter than that.

What does that mean?
Don't put this on me.
This is all happening because I'm trying to help you.
Let's continue.


Don't gaslight me, lady.





Next up is King's Ransom Online, the massive multiplayer game that's all the rage right now.

Did you know people pay real money for items in online games?



One vote for "it's pretty common", three for "Real money..." and four for "Losers". Feeling snarky, I see.

Losers...

It's apparently a booming business.
Some people even make their living from games this way.
Normally, it takes a lot of skill and perseverance.
But if someone were able to change the ownership of these digital objects...
Theoretically, that person could become very wealthy overnight.
I'm not suggesting that you do that, of course.
But I am suggesting you try.


I mean, I do need the money. And it's not like I'm stealing real objects, right?

Let's jack in.


OST: EXA Power

The assignment:
- Reset the ownership of all castles and sub-buildings to P00000 (file 300), the player ID for unowned buildings.
- To ensure that there are no witnesses you must first disconnect all connected players. Terminate every EXA in every host before changing any castle or sub-building files anywhere in the network. If you leave an EXA alive in one host while changing a file in another you will fail the task.
- For more information see "Network Exploration: King's Ransom Online" in the second issue of the zine.


More information in the zine.



Alright, ignoring all the old-timey text and that ad for a wristwatch, looks like players are represented by EXAs, and there's two main types of files: ones representing buildings and ones representing weapons.

Each host has a building 200 which is a castle, and a bunch of sub-buildings. Generally, the file IDs of sub buildings are in the castle file:



However, there are cases where sub-buildings have their own sub-buildings so I will need to check for those as well.

I can't see the details of the weapons yet because they're all being held by foreign EXAs. What I do see is two counters in the Goals: there are 14 EXAs to terminate and 26 buildings to clear. This differs a bit between test runs. What seems consistent is there's always between 2 and 6 buildings per host, including the castle, and between 1 and 3 EXAs.

Well, let's start by terminating the EXAs.

code:
COPY 800 X
LINK X

@REP 5
REPL LINK
ADDI X 1 X
@END

MARK LINK
LINK X

KILL
KILL
KILL
Some basic code to get an EXA in each host from 800-805, and then three KILLs to clear them out.



You can see the EXAs do represent players - killing them makes their characters disappear from the screen in the top right. The weapons are as described in the zine. Unfortunately, both the weapons and buildings have IDs in the 200-300 range. I won't be able to just loop over all file IDs to only change the buildings.

I'll just start with the obvious solution then, grabbing the castle, updating its ownership, and grabbing any sub-buildings from its list.

I already got an EXA in every host, and the assignment says I can't start messing with the buildings until the foreign EXAs are gone, so I'll just use the same ones.
code:
;XA
COPY 800 X
LINK X
COPY M T

@REP 5
REPL LINK
ADDI X 1 X
@END

MARK LINK
LINK X

KILL
KILL
KILL

COPY 200 X

MARK GRABSUBFILE
GRAB X
SEEK 2
COPY T F
MARK SUBFILELP
COPY F X
REPL GRABSUBFILE
JUMP SUBFILELP

;XB

GRAB 300
COPY F M
I use XB and a single use of the M register to load the null player ID into XA before it starts splitting, but without delaying it. XA uses the T register for this player ID because conveniently, it doesn't need it for anything else.

After the KILLs, the castle file ID (200) is copied into X, and then my EXA grabs the file, seeks to the player ID position, and overwrites it with the null id. For each following sub-building id, it loads the value into X and makes a new EXA that grabs it. This recursive code should get all buildings, no matter how deep it has to go.

However, this solution doesn't quite work. The first XA already starts messing with the buildings before the last one has killed all the foreign EXAs.

I can just start with an ugly workaround, just have everything wait until all foreign EXAs are gone.



Six NOOPs or a short loop do the trick.



48/35/25 as an initial score. The top percentiles are 32, 26 and 25.

What's also interesting is the huge distribution in size. I can imagine that this puzzle is much more devious if you can't figure out recursion. Luckily, I'm quite familiar with it.

Let's look at optimizations. First of all, to lower the cycle count, instead of having that whole list of NOOPs I can make it conditional - earlier EXAs have to wait longer.
code:
; XA

COPY 800 T
LINK T
COPY M X

@REP 5
REPL LINK
ADDI T 1 T
@END

MARK LINK
LINK T

KILL
KILL
KILL

SUBI 807 T T
DIVI T 2 T

MARK WAIT
SUBI T 1 T
TJMP WAIT

COPY 200 T

MARK GRABSUBFILE
GRAB T
SEEK 2
COPY X F
MARK SUBFILELP
COPY F T
REPL GRABSUBFILE
JUMP SUBFILELP

;XB

GRAB 300
COPY F M
46/34/25

I can shorten the REPL loop by reading hardcoded LINK ids from M instead.

code:
;XA

LINK 800
COPY M X

@REP 5
REPL LINK
@END

MARK LINK
LINK M

KILL
KILL
KILL

NOOP
NOOP
COPY 200 T

MARK GRABSUBFILE
GRAB T
SEEK 2
COPY X F
MARK SUBFILELP
COPY F T
REPL GRABSUBFILE
JUMP SUBFILELP

;XB
GRAB 300
COPY F M

;XC
REPL Y
REPL X
COPY 800 M
HALT
MARK X
COPY 801 M
HALT
MARK Y
NOOP
COPY 802 M

;XD
REPL Y
REPL X
COPY 803 M
HALT
MARK X
COPY 804 M
HALT
MARK Y
NOOP
COPY 805 M
39/45/25. XC and XD need two idle cycles anyway so that XB can send the player id first. I use the idle cycles for set up with REPL instructions.

Sending the player ID over M costs two cycles at the top, while we're wasting cycles with NOOPs further down. If I send that message later, I need to send it 6 times but with some smart timing I can save two cycles.

code:
;XA

LINK 800

@REP 5
REPL LINK
@END

MARK LINK
LINK M

KILL
KILL
KILL

NOOP
COPY 200 T
COPY M X

MARK GRABSUBFILE
GRAB T
SEEK 2
COPY X F
MARK SUBFILELP
COPY F T
REPL GRABSUBFILE
JUMP SUBFILELP

;XB

GRAB 300
COPY F X
NOOP
NOOP
NOOP

@REP 5
REPL SEND
@END

MARK SEND
NOOP ; For some reason this timing is fastest
NOOP
COPY X M

;XC and XD same as before.
37/56/25. I tried changing XC and XD to start a bit earlier but didn't manage to save any cycles that way. I think this is a good place to leave this and start looking at size.

Starting from the lowest size code above (the 34 LoC one), the first thing I noticed is that the two lines SUBI 807 T T, DIVI T 2 T aren't strictly necessary. As long as the file fiddling doesn't happen too early it's fine. Leaving those out just makes the WAIT loop run 800-odd times and that makes it slow, but it still works.

And since I need that wait loop anyway, why not put the KILL in there? That way it gets executed plenty of times but it saves two additional KILL lines.

code:
;XA

COPY 800 T
LINK T
COPY M X

@REP 5
REPL LINK
ADDI T 1 T
@END

MARK LINK
LINK T

MARK WAIT
KILL
DIVI T 5 T
TJMP WAIT

COPY 200 T

MARK GRABSUBFILE
GRAB T
SEEK 2
COPY X F
MARK SUBFILELP
COPY F T
REPL GRABSUBFILE
JUMP SUBFILELP

;XB

GRAB 300
COPY F M
54/30/37. I replaced that SUBI in the WAIT with a DIVI because it's a much faster way to count down from very large numbers. Since DIVI rounds down, it'll hit exactly zero no matter what. Any number between 2 and 5 works for this solution.

I tried some more things, such as putting the REPL LINK in a loop. That didn't work out because T and X are already occupied and adding a counter in some other way costs a lot of lines.

It's also possible to get rid of getting the subfile ids from each file. Use a simple loop counting down from file id 300 and trying every id in turn. However, you do need an extra check to not write to the weapon files. That's doable - just check if the second value is a number or not. But that check made it longer than the current solution. So this is the best I got.

---

Finally, there's activity. I already have top percentile activity, but could I go beyond? Well, no matter what I need 7 LINKs to get the EXAs in position. Add to that 3 KILLs in each of the 6 hosts for the 25 score.
However, the test with the highest number of foreign EXAs has 17 of them. That means that theoretically, you could save one more activity point.

To do so, I'd need to figure out how many foreign EXAs there are per host. How would you do that? You can't communicate with them. The only thing I can think of is fill the hosts with your own EXAs. Once a host is full, both LINK and REPL instructions block until a space is freed.

I spent some time (actually, way too much time) attempting to build a solution. It couldn't quite get it working, but I feel I'm quite close. I'll share what I have, maybe someone in the thread has the missing link.
code:
;XA LOCAL

COPY 800 X
LINK X

@REP 5
REPL LINK
ADDI X 1 X
@END

MARK LINK
LINK X

; There's a single EXA in each host now.

REPL COUNTER ; This one starts by waiting
REPL FILLER ; also starts by waiting

COPY 200 X

MARK GRABSUBFILE

; Grab all the files recursively. Once you have them jump to END. Do not modify files yet.
GRAB X
SEEK 3

MARK SUBFILELP
TEST EOF
TJMP END
COPY F X
REPL GRABSUBFILE
JUMP SUBFILELP

MARK FILLER

; Wait until all files are grabbed
COPY 20 T
MARK WAIT
SUBI T 1 T
TJMP WAIT


; Replicate until all squares are filled, but not more than 8 times. After replicating, each EXA goes to END.
COPY 8 T 

MARK FILLRUP
SUBI T 1 T
NOOP
FJMP END
REPL FILLRUP ; This will block once the squares are filled.
JUMP END

MARK COUNTER
; Wait until GRABSUBFILE and FILLER are done.
COPY 36 T
MARK WAIT2
SUBI T 1 T
TJMP WAIT2

COPY 0 X ; Add all local M values together. There are sent from END, below.
MARK NEXTM
TEST MRD
FJMP NEXTVOID
ADDI M X X
JUMP NEXTM

; After reading from M, the EXA who sent it halts, freeing up a space. That causes FILLRUP to continue until it's at 8 repl steps.
; This voids their M messages so they stop immediately.
MARK NEXTVOID
NOOP
TEST MRD
FJMP ENDVOID
VOID M
JUMP NEXTVOID

MARK ENDVOID
; At this point all EXAs except this one are gone from the host. This one has the total of the M messages in X.
; X = 12 squares minus this EXA, minus the EXA where REPL was blocking, minus the number of foreign EXAs
; so 10 - X = number of foreign EXAs.
SUBI 10 X T

; Kill em.
MARK KILLOOP
KILL
SUBI T 1 T
TJMP KILLOOP

; Switch to global mode, grab the files again, request the player ID and update the files.
COPY 200 X
MODE

MARK GRABSUBFILE2
GRAB X
SEEK 2
COPY M F

MARK SUBFILELP2
COPY F X
REPL GRABSUBFILE2
JUMP SUBFILELP2

MARK END
COPY 1 M

; ---- XB ---- (global)

; Wait until all foreign EXAs are killed (has to be timing based, limited options here)
; Then start sending the player ID on global M. 36 times = the maximum number of files in any test.

GRAB 300
COPY F X

COPY 88 T
MARK WAIT
SUBI T 1 T
TJMP WAIT

COPY 36 T

MARK LOOP
COPY X M
SUBI T 1 T
TJMP LOOP

; ---- XC ---- (global)

; Wait until all files are updated, then VOID M any remaining sends from XB.
; KILL is not an option.

COPY 155 T
MARK LP
SUBI T 1 T
TJMP LP

MARK ENDLOOP
VOID M
NOOP
NOOP
TEST MRD
TJMP ENDLOOP
94 lines out of 100 maximum. As I said, it doesn't work.
If you replace SUBI 10 X T with COPY 3 T to hardcode the number of kills, it does run with an activity of 25, proving that the logic is sound.

It's necessary to create file grabbing EXAs twice, because KILLs prefer own EXAs.

The one problem I couldn't resolve is the fact that as soon as the XA counter starts reading from M, those file grab and filler EXAs start dying, so the blocked REPL one starts running again, and sends to M before the counter is done counting, causing a wrong total. I tried a lot of different ways to slow them down, but nothing quite worked.


That's it for optimizations. But there's one more thing. This level has a Steam achievement tied to it, but it's quite tricky to get. It is called KLEPTOMANCER, and you might figure out it's for this level by its description, Verily hath every item been unduly purloined. What you need to do is move all weapons into the home host while leaving buildings alone. Since sub-buildings aren't locked to a host this takes a bit of work.

At least for an achievement none of the regular rules apply - the EXAs don't need to finish, for instance.
code:
;XA

COPY 800 X
LINK X

@REP 5
REPL LINK
ADDI X 1 X
@END

MARK LINK
LINK X

KILL
KILL
KILL

COPY 199 X

MARK GRABFILES
ADDI X 1 X
REPL GRABAFILE
JUMP GRABFILES


MARK GRABAFILE
GRAB X
SEEK 1
TEST F < 9999
DIVI 1 T T
LINK -1
LINK -1

;XB

GRAB 300
WIPE
XB wipes 300 to make space for the 9 weapons in the map. XA simply loops through all possible file IDs (starting from 200), grabs them, checks if the second value is a number (TEST F < 9999 is true for any number but false for any text; and only weapons have a number in the second position), and if so takes it home.



I think this is right. Steam achievements don't trigger a second time after unlocking them in a previous playthrough, so I hope I understood the unlock requirements correctly.

Moving on...

Oh. They just shut the whole game down.
Something about "hackers" or something?
I guess that means you.
People are taking this so seriously.




The first vote.

You know what really moves people?
Art.




And the vote for the intro for next time.

A fun fact to end with: there's an annoying little bug in the game, where if you beat a level, and then directly quit out of the game without going to the 'desktop' (level select with Ember etc.), the next part of the CHATSUBO chat doesn't trigger. I have no idea if it catches up eventually or not.

While working on this update I shut down the game without properly exiting, and the bug triggered. Since I like to keep the chat in sync with the rest of the story, I had no choice but to resort to hacking the save files to "unsolve" the level so I could re-trigger the chat. It feels extremely meta, but there you have it.

Anaxite
Jan 16, 2009

What? What'd you say? Stop channeling? I didn't he-
God forbid NFTs become involved.

It is real money...
I already don't like where this is going...

GuavaMoment
Aug 13, 2006

YouTube dude
Alright here we go! Speed time. 28/85/33

code:
XA
GRAB 300
COPY F X
LINK 800
REPL 803
WIPE
REPL 804
LINK 800
NOOP
MARK DEL
GRAB 200
SEEK 2
COPY X F
COPY F T
REPL D2
COPY F T
REPL D2
COPY F T
REPL D2
COPY F T
REPL D2
COPY F T
REPL D2
MARK D2
GRAB T
SEEK 2
COPY X F
COPY F T
DROP
GRAB T
SEEK 2
COPY X F
HALT
MARK 803
REPL 802
REPL 801
LINK 803
JUMP DEL
MARK 804
LINK 804
JUMP DEL
MARK 805
LINK 805
JUMP DEL
MARK 802
REPL 805
LINK 802
JUMP DEL
MARK 801
LINK 801
JUMP DEL

XB
NOOP
LINK 800
REPL 802
LINK 803
KILL
KILL
KILL
MARK 802
LINK 802
KILL
KILL
KILL

XC
LINK 800
REPL 805
REPL 804
LINK 800
KILL
KILL
KILL
MARK 805
REPL 801
LINK 805
KILL
KILL
KILL
MARK 804
LINK 804
KILL
KILL
KILL
MARK 801
LINK 801
KILL
KILL
KILL
All six exas go into their areas simultaneously, then there's a lot of loop unrolling. Create an exa to replace the ID for every file. EXAs die if they reach the end of file, and you only have to check once for sub-sub buildings.


Now for low line - 1623/20/25. So we need each exa to go into rooms numbered around 800, and then grab files in the 200s, right? Start at 806 and count down attempting both! Enter every room from from 0 to 806, grab every file from 0 to 806. After thousands upon thousands of exas die, the countdown reaches 0 and die for good. Weapons have a number in the second file spot, so those get excluded.

code:
GRAB 300
LINK 800
COPY F X
WIPE
COPY 806 T
MARK MANY
MODI -1 T T
REPL MANY
LINK T
KILL
KILL
KILL
MARK COPY
MODI -1 T T
REPL COPY
GRAB T
SEEK 1
TEST F > 0
TJMP MANY
COPY X F
No one on my friends list has a faster time, and one person ties me on lines, so this might be a time I can best silentsnack. There's one catch though - two friends have 24 for activity, and I'm not sure how that's possible. As you've tried to do!

silentsnack
Mar 19, 2009

Donald John Trump (born June 14, 1946) is the 45th and current President of the United States. Before entering politics, he was a businessman and television personality.

GuavaMoment posted:

No one on my friends list has a faster time, and one person ties me on lines, so this might be a time I can best silentsnack. There's one catch though - two friends have 24 for activity, and I'm not sure how that's possible. As you've tried to do!

Yeah my best scores were 28 cycles and 22 lines, and my fast solution is mostly similar except significantly less efficient due to laziness and aiming for a goofy solution gif :v:

Junpei
Oct 4, 2015
Probation
Can't post for 11 years!
Their loss, that's why art is powerful.

Jade Rider
May 11, 2007

All the pages have been censored except for "heck," and she misread that one.


Anaxite posted:

It is real money...
I already don't like where this is going...

:emptyquote:

Carbon dioxide
Oct 9, 2012

GuavaMoment posted:

There's one catch though - two friends have 24 for activity, and I'm not sure how that's possible. As you've tried to do!

:sickos: I got it!

https://i.imgur.com/L4G8gdY.mp4

Code will be in the next update.

GuavaMoment
Aug 13, 2006

YouTube dude

:sickos::hf: :sickos:

I have done something quite different than you, and I still need to optimize a bit. I'll assume you'll want to wait until you post your solution for me to post mine. I'm around 85 lines right now, but about 4-5x slower.

Carbon dioxide
Oct 9, 2012

GuavaMoment posted:

:sickos::hf: :sickos:

I have done something quite different than you, and I still need to optimize a bit. I'll assume you'll want to wait until you post your solution for me to post mine. I'm around 85 lines right now, but about 4-5x slower.

I'll just post mine and we can compare.

My solution boils down to the same thing I did before except by filling the host with EXAs, I first count the building files, then I have an EXA fill up the host with files (which makes communication and timing significantly easier), and count how many it can drop until the host is fill. Whatever number remains corresponds to the number of foreign EXAs.

code:
;XA LOCAL

COPY 800 X
LINK X

@REP 5
REPL LINK
ADDI X 1 X
@END

MARK LINK
LINK X

REPL COUNTER

COPY 200 X

MARK GRABSUBFILE
COPY 1 M
GRAB X
SEEK 3
MARK SUBFILELP
COPY F X
REPL GRABSUBFILE
JUMP SUBFILELP

MARK FILLRUP
COPY 1 M
MAKE
TEST M = 0
FJMP ENDFILL
DROP
JUMP FILLRUP

MARK COUNTER
COPY 0 X
MARK NEXTM
NOOP
NOOP
NOOP
TEST MRD
FJMP FILLER
ADDI M X X
JUMP NEXTM

MARK FILLER
REPL FILLRUP

MARK NEXTDROPM
NOOP
NOOP
TEST MRD
FJMP COUNTDONE
ADDI M X X
COPY 0 M
JUMP NEXTDROPM

MARK COUNTDONE
SUBI 11 X T

GRAB 200
VOID M
COPY -1 M
NOOP
NOOP

MARK KILLOOP
KILL
SUBI T 1 T
TJMP KILLOOP

COPY 399 X

MARK CLEANLP
ADDI X 1 X
REPL CLEANER
TEST X > 441
FJMP CLEANLP

MODE
JUMP SUBFILE2START

MARK GRABSUBFILE2
GRAB X
MARK SUBFILE2START
SEEK 2
COPY M F

MARK SUBFILELP2
COPY F X
REPL GRABSUBFILE2
JUMP SUBFILELP2

MARK CLEANER
GRAB X
MARK ENDFILL
WIPE

;XB GLOBAL

GRAB 300
COPY F X

COPY 36 T

MARK LOOP
COPY X M
SUBI T 1 T
TJMP LOOP

;XC GLOBAL

COPY 205 T
MARK LP
SUBI T 1 T
TJMP LP

MARK ENDLOOP
VOID M
NOOP
NOOP
TEST MRD
TJMP ENDLOOP

GuavaMoment
Aug 13, 2006

YouTube dude
I see you at LINES 100 and I thought the amount of lines was going to be the limiting factor in the solution, so I used my really low line filegrabbing solution as the base. 1823/81/24 There's a LOT of timewasting to get everything synced up. I still try to grab a LOT of non-existent files which wastes more time. Lower any of the timewasting values by even 1 and something breaks.

code:
XA LOCAL

COPY 800 T
LINK 800
@REP 5
REPL LINK
ADDI T 1 T
@END
MARK LINK
LINK T

; all six rooms are filled with one exa

COPY 299 T
REPL FILEGRAB
MARK WAIT1   ;create exas grabbing files 299 on down, and begin WAIT1 until that's done. Each fileholder will send '1' over M.
SUBI T 1 T
TJMP WAIT1
COPY 8 X 
REPL SLOWFILL           ;attempt to fill empty spots with 8 exas as CO2 did. Buuuut there's a delay before each filler is made
	;we want to count all the fillers later before another is created
COPY 0 X
COPY 78 T    
MARK WAIT2    ; and wait2 until everything is filled.
SUBI T 1 T
TJMP WAIT2
ADDI X M X
MARK COUNTLOOP
TEST MRD
FJMP VOIDLOOP
ADDI X M X
JUMP COUNTLOOP        ;count the number of alive exas before more than one is created


MARK VOIDLOOP
COPY 16 T 
MARK WAIT3
SUBI T 1 T
TJMP WAIT3    ;void the extra exas created slower than they're made until no more are being replicated
TEST MRD
FJMP KILLS
VOID M
JUMP VOIDLOOP

MARK KILLS
SUBI 11 X T    ;the real number is 11 minus the count not twelve since one extra is created
; I don't know it just works
MARK KILLING
FJMP DONEKILL
KILL
SUBI T 1 T
JUMP KILLING    ;hey idiot, change this to a TJMP and remove the FJMP DONEKILL line you say - 
Well, I'd do that, but it breaks the solution somehow



MARK DONEKILL
MODE
COPY M X   ;grab the file value from XB
COPY 370 T      ;begin grabbing every file from 370 down to 0. Yes, the files start at 299, 
but this also acts to slow things down and make sure everything times out properly
MARK FILEGRAB2
MODI -1 T T
REPL FILEGRAB2
GRAB T
SEEK 1
TEST F > 0
TJMP LINK
COPY X F


MARK SLOWFILL
MODI -1 X X
REPL FILLER
COPY 16 T    
MARK SLOWWAIT
SUBI T 1 T
TJMP SLOWWAIT
JUMP SLOWFILL




MARK FILEGRAB
MODI -1 T T
REPL FILEGRAB
GRAB T
MARK FILLER
COPY 1 M

-------------------
XB GLOBAL

GRAB 300
COPY F X
COPY 5 T
MARK HERE
COPY X M
MODI -1 T T
JUMP HERE

Carbon dioxide
Oct 9, 2012

https://www.pcgamer.com/zachtronics-is-making-its-final-game-last-call-bbs/

quote:

Last Call BBS seems like a culmination and combination of everything Zachtronics has done over the last decade-plus of indie game development. It's a collection of eight puzzle minigames ("although some of them are quite big, at least the size of TIS-100"), all accessed through a fictional retro computer called the Sawayama Z5 Powerlance.

...

Sadly, Last Call BBS will be a last call for Zachtronics. As Zach Barth told Press X to Learn earlier this year, he's working as a high school computer science teacher these days. Given how many people have picked up elements of programming from the games he's worked on that seems pretty apt, but obviously full-time teaching doesn't leave a lot of hours free for game development.

biosterous
Feb 23, 2013




i hope his post-development career is long and rewarding and that people are good to him and people keep learning from his rad games

Snuffman
May 21, 2004


Day 1 purchase, this looks supremely my jam.

I've only got hooked on Exapunks in the past few weeks but its been really fun playing along with this thread. My code is absolute garbage (but it works!) and its fascinating seeing much more elegant solutions.

I'm now waaay past the thread, I'm on getting a valid credit card number out of a garbage file but I can't wait to see the better way of aligning the satellite. I swear I wasted so many cycles on the alignment that by the time I got to the second half I was already nearing code limits.

Carbon dioxide
Oct 9, 2012

Part 31 - KGOG-TV

=== Trash World Inbox ===

Best scores I got on King's Ransom Online were 37, 30 and 25. Let's see your improvements.

GuavaMoment posted:

code:
XA
GRAB 300
COPY F X
LINK 800
REPL 803
WIPE
REPL 804
LINK 800
NOOP
MARK DEL
GRAB 200
SEEK 2
COPY X F
COPY F T
REPL D2
COPY F T
REPL D2
COPY F T
REPL D2
COPY F T
REPL D2
COPY F T
REPL D2
MARK D2
GRAB T
SEEK 2
COPY X F
COPY F T
DROP
GRAB T
SEEK 2
COPY X F
HALT
MARK 803
REPL 802
REPL 801
LINK 803
JUMP DEL
MARK 804
LINK 804
JUMP DEL
MARK 805
LINK 805
JUMP DEL
MARK 802
REPL 805
LINK 802
JUMP DEL
MARK 801
LINK 801
JUMP DEL

XB
NOOP
LINK 800
REPL 802
LINK 803
KILL
KILL
KILL
MARK 802
LINK 802
KILL
KILL
KILL

XC
LINK 800
REPL 805
REPL 804
LINK 800
KILL
KILL
KILL
MARK 805
REPL 801
LINK 805
KILL
KILL
KILL
MARK 804
LINK 804
KILL
KILL
KILL
MARK 801
LINK 801
KILL
KILL
KILL
All six exas go into their areas simultaneously, then there's a lot of loop unrolling. Create an exa to replace the ID for every file. EXAs die if they reach the end of file, and you only have to check once for sub-sub buildings.
28/85/33. Nice clean solution, XB and XC together make quick work of the foreign EXAs, and XA does the file stuff.

GuavaMoment posted:

Now for low line - 1623/20/25. So we need each exa to go into rooms numbered around 800, and then grab files in the 200s, right? Start at 806 and count down attempting both! Enter every room from from 0 to 806, grab every file from 0 to 806. After thousands upon thousands of exas die, the countdown reaches 0 and die for good. Weapons have a number in the second file spot, so those get excluded.
code:
GRAB 300
LINK 800
COPY F X
WIPE
COPY 806 T
MARK MANY
MODI -1 T T
REPL MANY
LINK T
KILL
KILL
KILL
MARK COPY
MODI -1 T T
REPL COPY
GRAB T
SEEK 1
TEST F > 0
TJMP MANY
COPY X F
The description speaks for itself. I keep forgetting about that MODI -1 T T trick to subtract one and automatically die when it hits zero. Also, the TJMP MANY is just a convenient way to make those EXAs that grabbed a weapon harmless. They'll REPL into something that links nowhere and then T hits zero (since the TEST set it to 1) and it dies.

Finally, let's go back to the elusive 24-activity solution. Both GuavaMoment and I came up with a way to do this. I'll start with my own.

The main difference from my attempt in the previous update is that I now fill the hosts with files instead of EXAs. I found files much easier to control.
I'll add some explanations in the code.
code:
;XA LOCAL

COPY 800 X
LINK X

@REP 5
REPL LINK
ADDI X 1 X
@END

MARK LINK
LINK X

; after getting an EXA in each host, it makes a counter.
REPL COUNTER 

; Then the EXA grabs file 200 and each sub file, copying 1 to local M for each file it's about to grab. This EXA and its repls will die once all files have been handled, dropping the files unchanged. This just counts the buildings.
COPY 200 X

MARK GRABSUBFILE
COPY 1 M
GRAB X
SEEK 3
MARK SUBFILELP
COPY F X
REPL GRABSUBFILE
JUMP SUBFILELP

; In this stage, the counter counts the M's coming from the building EXAs just above. It knows when it's done and jumps out to FILLER once MRD is false. The NOOPs make the timing work out.
MARK COUNTER 
COPY 0 X
MARK NEXTM
NOOP
NOOP
NOOP
TEST MRD
FJMP FILLER
ADDI M X X
JUMP NEXTM

; After the file counting is done, the FILLER creates this Fill 'r up EXA, which sends a message to M (like the file counter), then makes a file, and waits for M to decide if it should drop it or not.
; If it drops it, it'll immediately try again. An EXA will hang on DROP if there's no place to drop the file.
MARK FILLRUP
COPY 1 M
MAKE
TEST M = 0
FJMP ENDFILL
DROP
JUMP FILLRUP

; This is the next part of the counting EXA. After creating Fill 'r up, it starts counting further, similarly to the building counter above. The big difference is it sends 0 to M to tell Fill 'r up to keep going.
; Once MRD is false, we know Fill 'r up is hanging on a DROP and continue.
MARK FILLER
REPL FILLRUP

MARK NEXTDROPM
NOOP
NOOP
TEST MRD
FJMP COUNTDONE
ADDI M X X
COPY 0 M
JUMP NEXTDROPM

; The number of foreign EXAs is simple to calculate: X will contain the number of buildings plus the files that were just created. There's 12 places so we just need to calculate the difference.
; It's off by one because this EXA takes up a spot itself.
MARK COUNTDONE
SUBI 11 X T

; Before killing we need to clean up the mess. Fill 'r up is blocking on DROP while holding a file. We obviously can't use a KILL on it, that would beat the purpose.
; So we just grab file 200 (which always exists), which unblocks Fill 'r up, and lets us send -1, which makes it jump to ENDFILL, where it just WIPEs the file it's holding and then dies.
GRAB 200
VOID M
COPY -1 M
NOOP
NOOP

; Once that's taken care of, KILL the exact number of foreign EXAs.
MARK KILLOOP
KILL
SUBI T 1 T
TJMP KILLOOP

; To leave no evidence we need to WIPE the empty files we created. Turns out their IDs start at 400 and never go above 440 so this can be done with a simple grab-and-wipe loop.
COPY 399 X

MARK CLEANLP
ADDI X 1 X
REPL CLEANER
TEST X > 441
FJMP CLEANLP

; Finally, go to GLOBAL mode to get the player ID from XB, and go through all the files again. Since the EXA is already holding 200 by this point, it skips the GRAB step with a JUMP the first time round.
MODE
JUMP SUBFILE2START

MARK GRABSUBFILE2
GRAB X
MARK SUBFILE2START
SEEK 2
COPY M F

MARK SUBFILELP2
COPY F X
REPL GRABSUBFILE2
JUMP SUBFILELP2

MARK CLEANER
GRAB X
MARK ENDFILL
WIPE

;XB GLOBAL
; XB is the same as before - it tries to send the player id 36 times because that's the max number of buildings we can have.
; It doesn't need a delay loop at the start this time because the XAs will stay in LOCAL mode until they're ready.

GRAB 300
COPY F X

COPY 36 T

MARK LOOP
COPY X M
SUBI T 1 T
TJMP LOOP

;XC GLOBAL
; XC is completely unchanged. It waits however long it takes for XA/XB to be completely done (turns out to be 205 loops in the slowest test),
; then voids whatever M message from XB remain, so it can die of natural causes.

COPY 205 T
MARK LP
SUBI T 1 T
TJMP LP

MARK ENDLOOP
VOID M
NOOP
NOOP
TEST MRD
TJMP ENDLOOP
Video
The end result is 517/100/24. I had to squeeze a little bit to fit it in the 100 size limit but I didn't have to try too hard. I'm pretty sure I could save more lines if I really wanted to.

GuavaMoment posted:

I see you at LINES 100 and I thought the amount of lines was going to be the limiting factor in the solution, so I used my really low line filegrabbing solution as the base. 1823/81/24 There's a LOT of timewasting to get everything synced up. I still try to grab a LOT of non-existent files which wastes more time. Lower any of the timewasting values by even 1 and something breaks.
code:
XA LOCAL

COPY 800 T
LINK 800
@REP 5
REPL LINK
ADDI T 1 T
@END
MARK LINK
LINK T

; all six rooms are filled with one exa

COPY 299 T
REPL FILEGRAB
MARK WAIT1   ;create exas grabbing files 299 on down, and begin WAIT1 until that's done. Each fileholder will send '1' over M.
SUBI T 1 T
TJMP WAIT1
COPY 8 X 
REPL SLOWFILL           ;attempt to fill empty spots with 8 exas as CO2 did. Buuuut there's a delay before each filler is made
	;we want to count all the fillers later before another is created
COPY 0 X
COPY 78 T    
MARK WAIT2    ; and wait2 until everything is filled.
SUBI T 1 T
TJMP WAIT2
ADDI X M X
MARK COUNTLOOP
TEST MRD
FJMP VOIDLOOP
ADDI X M X
JUMP COUNTLOOP        ;count the number of alive exas before more than one is created

MARK VOIDLOOP
COPY 16 T 
MARK WAIT3
SUBI T 1 T
TJMP WAIT3    ;void the extra exas created slower than they're made until no more are being replicated
TEST MRD
FJMP KILLS
VOID M
JUMP VOIDLOOP

MARK KILLS
SUBI 11 X T    ;the real number is 11 minus the count not twelve since one extra is created
; I don't know it just works
MARK KILLING
FJMP DONEKILL
KILL
SUBI T 1 T
JUMP KILLING    ;hey idiot, change this to a TJMP and remove the FJMP DONEKILL line you say - 
Well, I'd do that, but it breaks the solution somehow

MARK DONEKILL
MODE
COPY M X   ;grab the file value from XB
COPY 370 T      ;begin grabbing every file from 370 down to 0. Yes, the files start at 299, 
but this also acts to slow things down and make sure everything times out properly
MARK FILEGRAB2
MODI -1 T T
REPL FILEGRAB2
GRAB T
SEEK 1
TEST F > 0
TJMP LINK
COPY X F

MARK SLOWFILL
MODI -1 X X
REPL FILLER
COPY 16 T    
MARK SLOWWAIT
SUBI T 1 T
TJMP SLOWWAIT
JUMP SLOWFILL

MARK FILEGRAB
MODI -1 T T
REPL FILEGRAB
GRAB T
MARK FILLER
COPY 1 M

-------------------
XB GLOBAL

GRAB 300
COPY F X
COPY 5 T
MARK HERE
COPY X M
MODI -1 T T
JUMP HERE
Ah, so the EXA-filling solution is possible, with patience. The main trick seems to be to slow down the fill so much that between one EXA being created and the next, there's enough time to count all of them. But, that means that when you're actually creating EXAs to fill up the host, or to clean up the remainder of the 8 EXAs that are being created, you have to wait for that slow fill as well.


=== KGOG-TV - Satellite Uplink ===

Oh. They just shut the whole game down.
Something about "hackers" or something?
I guess that means you.
People are taking this so seriously.




Three votes for real money, one for "their loss".

It is real money...

People act like the online world is different, but it really isn't.
At least as far as human behavior goes.






Next up... Ember wants us to upload a tv program? Okay.

You know what really moves people?
Art.




One vote for "That's why art is powerful", but three people didn't like where this was going.

I already don't like where this is going...

I've been working on something creative.
An abstract video piece.
It's an expression of some of the ideas I've been developing around shape, form, and color.
You'll see.
Let's get it out there.


Don't worry too much, Ember just wants her art to be seen. Seeing how recently NFTs gained popularity, I doubt Zach had even heard of them when he made this game.


OST: Behind the Scenes

The assignment:
- Align the satellite dish with the target satellite by setting the azimuth, elevation and frequency. Then transmit the data from EMBER-2's video (file 301) after encrypting it using the TV station's encryption key (file 199).
- The azimuth, elevation, and frequency of the target satellite are available in file 300.
- Note that you must align the satellite dish before transmitting any data.
- For more information see "Look to the Stars with Satellite Uplink Systems" in the second issue of the zine.


Ember, how did you even get us inside a tv transmission satellite dish?

Before I'll grab the zine, it might interest you that K-GOG has the shows "Ten Men and a Dog", "City Livin'", "Cooking for Losers", "Takedown", "Buy it, Love it", and "Futurelook 2000" lined up. Which is your favorite?



Okay, so writing to the motor registers moves the dish, while I can read the current position from the #AZIM and #ELEV registers. The encryption is quite basic as encryption schemes go, add the first value of the data to the first value of the encryption key, modulo 10000. Repeat with the second value of the data and the second value of the encryption key and so on. If there's more data than values in the encryption key, wrap around to the beginning of the key. A complication is be that EXAs are limited to 9999, so I'll need a trick for the modulo operation.

But first, let's get the sat aligned.

code:
GRAB 300
LINK 800
LINK 799
SEEK 1
COPY F X
REPL AZI
SEEK 1
COPY F X
REPL ELEV
SEEK 1
COPY F #FREQ
HALT

MARK AZI
LINK 800
SUBI X #AZIM X
TEST X > 0
TJMP MOVEUP

MARK MOVEDOWN
MODI 1 X X
COPY -1 #MOTR
JUMP MOVEDOWN

MARK ELEV
LINK 801
SUBI X #ELEV X
TEST X > 0
FJMP MOVEDOWN

MARK MOVEUP
MODI -1 X X
COPY 1 #MOTR
JUMP MOVEUP
The EXA reads the azimuth and elevation from file 300 and makes REPLs to handle them. The frequency is easier, it can just be sent to the register right away.

The motors only can move one step at a time. So the azimuth and elevation EXAs calculate the difference between the current value and where they should be, and then either move up and down. The move loops are interwoven so that both the AZI and ELEV only need one conditional jump and can fall through otherwise. And I use the MODI trick GuavaMoment helped me remember to have the EXAs die automatically when they're done.

The uplink status on the top right says "Link: Locked" once all settings are right.

Next up is encrypting the file. To keep the activity as low as possible I think it's best if I send the dish settings over M so I can carry file 301 with me and handle that without a lot of messaging.

Let's go through it step by step.

XB is a simple EXA that grabs file 300, and sends the azimuth, elevation and frequency over M:
code:
GRAB 300
MARK LOOP
SEEK 1
COPY F M
JUMP LOOP
I could unroll that but I don't know how much space I'll have before the end so let's not optimize prematurely.

code:
GRAB 301
LINK 800
REPL ENCRFILE

LINK 799
REPL AZI
REPL ELEV
COPY M #FREQ

[...]

MARK AZI
LINK 800
SUBI M #AZIM X
TEST X > 0
TJMP MOVEUP

MARK MOVEDOWN
MODI 1 X X
COPY -1 #MOTR
JUMP MOVEDOWN

MARK ELEV
LINK 801
SUBI M #ELEV X
TEST X > 0
FJMP MOVEDOWN

MARK MOVEUP
MODI -1 X X
COPY 1 #MOTR
JUMP MOVEUP
XA leaves behind an ENCRFILE EXA in the host that has the encryption key, then makes the azimuth and elevation EXAs. I moved the azimuth/elevation transmission to those EXAs to save a bit of time. It's important that the right EXA gets the right value, and this could easily go wrong here because the frequency, AZI and ELEV EXAs all ask for M around the same cycle. I could prevent that by adding some NOOPs or whatever but the unpredictable order of M's in the same cycle just happens to work out in my favour here.

Let's look at the ENCRFILE EXA next.
code:
MARK ENCRFILE
GRAB 199
COPY 49 T
MARK WAIT
SUBI T 1 T
TJMP WAIT

MARK SENDKEY
COPY F M
DIVI 0 M X
TEST EOF
TJMP RESET
JUMP SENDKEY

MARK RESET
SEEK -9999
JUMP SENDKEY
It grabs the file, then waits a while before it starts sending data. The main reason is because I need to make sure the dish settings are sent first. But, since I had the loop in place already I lengthened it to 49 steps, which ensures that the dish is fully set in each test case. That way, I won't try sending data before the thing is aimed at the satellite.

Anyway, after sending a key value, it waits for an incoming M. To cause this EXA to stop at the end, it dies if M is zero.
Otherwise, it tests if it's at the end of the encryption file and if so starts over from the beginning of the file. Either way it sends the next value and repeats.
code:
MODE
REPL SENDER

SEEK 1
MARK NEXTDATA
COPY F M
TEST EOF
FJMP NEXTDATA

COPY 0 M
MODE
VOID M
COPY 0 M
JUMP DONE
After the 'main' EXA sets the frequency, it switches to local mode, then creates a SENDER EXA that will handle the actual encryption and sending logic. It grabbed the data file along the way, so now it just skips past the video title, then starts sending data locally. At the end of the file, it sends a 0 to let SENDER know it's done, and then switches back to global, voids the next encryption value from ENCRFILE and sends it a 0 (kill signal).

code:
MARK SENDER
MAKE

MARK NEXT
COPY M T
FJMP DONE
COPY T X
MODE
COPY M F
SEEK -1
COPY 1 M
ADDI X F F
SEEK -1
TEST F = 9999
FJMP SENDDIRECT
SEEK -2
SWIZ F 0004 T
SWIZ X 0004 F
SEEK -1
ADDI T F T
SWIZ T 1000 T
SWIZ X 0321 X
ADDI X T T
SEEK -2
SWIZ F 0321 X
ADDI X T #DATA
MODE
JUMP NEXT

MARK SENDDIRECT
SEEK -1
COPY F #DATA
MODE
JUMP NEXT

MARK DONE
WIPE
The sender contains the encryption logic. It makes a temporary file because it has a lot of values to juggle. First thing it does is check if the value from the data EXA is a zero, in which case it stops. Both the data EXA and this one jump to DONE to make sure they don't leave their files in the foreign host.

For the encryption, it first copies the data value to X (I needed it in T to see quickly if it was zero, but I need to free T for an upcoming test). Then the EXA switches to global mode and puts the encryption value in F. It tells the ENCRFILE EXA to get ready to send another message, and adds up the data and encryption values, saving that to the file. If the result is less than 9999, it sends the data right away. Otherwise it needs to do something tricky to get the "modulo 10000" requirement.

The SWIZ 0004 instructions return a number that contains the thousands digit of the original, in the ones place. Those can be added together. For instance, if the result is 15, that means the full result would be 15xxx, modulo 10K makes 5xxx. That's what the SWIZ 1000 does. It takes the digit in the ones place, and puts it in the thousands place. The digit is where it should be and we get the modulo operation for free.
Next I take only the lower three digits of the data and encryption value using SWIZ 0321 instructions, add everything together, and send it to #DATA.



The top percentiles are 180, 56 and 4. I'm not wasting any activity points but there are improvements for the other metrics.

There is in fact a much, much simpler way to implement the encryption algorithm. EXAs do have a range that goes beyond 10000 values - we just need to use it. It's negative numbers, of course.

I can rewrite the whole SENDER code to just this:
code:
MARK SENDER
COPY M X
TEST X = 0
TJMP DONE
SUBI X 9999 X
MODE
ADDI M X X
TEST X < 0
COPY 1 M
TJMP ADD
SUBI X 1 #DATA
MODE
JUMP SENDER

MARK ADD
ADDI 9999 X #DATA
MODE
JUMP SENDER
The data value is stored as 9999 less than the actual value. Then the encryption value is added to it. This will never overflow, since the new total will never be more than 9999.

Now there's two possibilities. Either the result is less than 0 (the total was less than 9999), in which case I can just re-add the 9999 and send to #DATA. Or it's more, in which case we would have to apply the modulo operation. Since that's equivalent to subtracting 10000, and I already subtracted 9999, I just subtract one more and that's it. No more temporary files, everything can be done in-place.

Because it's so much faster, I had to bump ENCRFILE's wait time to 55 loops. This solution clocks in at 431/76/4. Less lines of code and less cycles.

You might've already realized the next step. Since the temporarily file isn't necessary anymore, we can delete the entire dedicated SENDER EXA and have the main data one handle the encryption logic. That skips a lot of M transmissions.
code:
; XA

GRAB 301
LINK 800
REPL ENCRFILE

LINK 799
REPL AZI
REPL ELEV
COPY M #FREQ

SEEK 1
MARK NEXTDATA
TEST EOF
TJMP DONE
SUBI F 9999 X
ADDI M X X
TEST X < 0
COPY 1 M
TJMP ADD
SUBI X 1 #DATA
JUMP NEXTDATA

MARK ADD
ADDI 9999 X #DATA
JUMP NEXTDATA

MARK AZI
LINK 800
SUBI M #AZIM X
TEST X > 0
TJMP MOVEUP

MARK MOVEDOWN
MODI 1 X X
COPY -1 #MOTR
JUMP MOVEDOWN

MARK ELEV
LINK 801
SUBI M #ELEV X
TEST X > 0
FJMP MOVEDOWN

MARK MOVEUP
MODI -1 X X
COPY 1 #MOTR
JUMP MOVEUP

MARK ENCRFILE
GRAB 199
COPY 55 T
MARK WAIT
SUBI T 1 T
TJMP WAIT

MARK SENDKEY
COPY F M
DIVI 0 M X
TEST EOF
TJMP RESET
JUMP SENDKEY

MARK RESET
SEEK -9999
JUMP SENDKEY

MARK DONE
VOID M
WIPE
COPY 0 M

; XB

GRAB 300
MARK LOOP
SEEK 1
COPY F M
JUMP LOOP
360/63/4.

Now that I don't need to worry about activity anymore, I can also get rid of that annoying wait by doing the encryption in parallel with setting the dish.
code:
; XA

GRAB 301
LINK 800
REPL SETDISH

MODE
REPL ENCRFILE

VOID F
MARK NEXTDATA
TEST EOF
TJMP DONE
SUBI F 9999 X
ADDI M X X
SEEK -1
TEST X < 0
TJMP ADD
SUBI X 1 F
JUMP NEXTDATA

MARK ADD
ADDI 9999 X F
JUMP NEXTDATA

MARK AZI
LINK 800
SUBI X #AZIM X
TEST X > 0
TJMP MOVEUP

MARK MOVEDOWN
MODI 1 X X
COPY -1 #MOTR
JUMP MOVEDOWN

MARK ELEV
LINK 801
SUBI X #ELEV X
TEST X > 0
FJMP MOVEDOWN

MARK MOVEUP
MODI -1 X X
COPY 1 #MOTR
JUMP MOVEUP

MARK ENCRFILE
GRAB 199

MARK SENDKEY
COPY F M
TEST EOF
TJMP RESET
JUMP SENDKEY

MARK RESET
SEEK -9999
JUMP SENDKEY

MARK SETDISH
LINK 799
COPY M X
REPL AZI
COPY M X
REPL ELEV
COPY M #FREQ

MARK DONE
KILL
LINK 799
SEEK -9999
@REP 24
COPY F #DATA
@END
WIPE

;XB was unchanged
253/88/7.
While SETDISH does its thing, the ENCRFILE EXA and the data one are sitting in the SECURE host, communicating in local mode. The data EXA overwrites the values in Ember's file with the encrypted values. At the end it kills the ENCRFILE EXA, hops over to the transmitter, and sends all the contents of the file.

I shuffled some code around, mostly to make sure EXAs that are finished fall through into code that makes them stop themselves. The different use of M somehow changed the order the dish EXAs receive the data in so I had to move the COPY M instructions back to the main SETDISH code.

Next, I noticed that the encryption algorithm is still the slowest step by far. The most obvious thing I can remove from it are the two cycles to check EOF. I can't unroll that loop much, I don't have a lot of lines left, but there's another way.
code:
REPL GRABBER

VOID F
MARK NEXTDATA
@REP 2
SUBI F 9999 X
ADDI M X X
SEEK -1
TEST X < 0
TJMP ADD
SUBI X 1 F
@END
JUMP NEXTDATA

MARK ADD
ADDI X 9999 F
JUMP NEXTDATA

[...]

MARK GRABBER
REPL GRAB
NOOP
NOOP
JUMP GRABBER

MARK GRAB
GRAB 301

KILL
KILL

; Take the file to the transmission host and send all the data as before
207/100/7. When the data EXA is at the end of the file it will die, and the GRABBER EXA can take it and send the data. I needed some NOOPs to slow the replication down enough that the KILLs work properly.

In this solution, the encryption algorithm is still the slowest step. It's possible to change that, for instance by writing the raw value to F before checking if it's negative, and handling that later, when sending the data. However, that means you can't fully unroll the sender code anymore with the @REP 24, so you need TEST EOF instructions and everything, and it slows down the whole program significantly.

So, I'll end it today with top scores of 207 cycles and 63 size.

By the way, I hadn't noticed it before but there's some sort of ad in the zine, just after the satellite dish article.



Sounds neat.

Well, what did you think?



The first vote. And for next time...

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...


Carbon dioxide fucked around with this message at 18:48 on Apr 23, 2023

Quackles
Aug 11, 2018

Pixels of Light.


Hacking those ATMs was your idea, Ember. And I'm not sure I understood it.

GuavaMoment
Aug 13, 2006

YouTube dude

Carbon dioxide posted:

Also, the TJMP MANY is just a convenient way to make those EXAs that grabbed a weapon harmless.

It may have been said before, but there are just so many times when you want something to die after a conditional, the first thing I do is look over the code to see if jumping somewhere completely unrelated kills the exa in that case. There almost always is one.

I don't have good solutions for this one. I won't have good ones for a while it seems, the difficulty is ramping up.

silentsnack
Mar 19, 2009

Donald John Trump (born June 14, 1946) is the 45th and current President of the United States. Before entering politics, he was a businessman and television personality.

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

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


Quackles posted:

Hacking those ATMs was your idea, Ember. And I'm not sure I understood it.

silentsnack fucked around with this message at 20:57 on Jun 19, 2022

Carbon dioxide
Oct 9, 2012

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.

Carbon dioxide fucked around with this message at 11:13 on Jul 2, 2022

Adbot
ADBOT LOVES YOU

GuavaMoment
Aug 13, 2006

YouTube dude
I had a 60 cycle solution I was playing with last week, but it's gone? I must have done something and accidentally deleted it. I remade at least it but with more lines somehow? 50 cycles is possible.

60/59/8

code:
XA local
GRAB 301
COPY F M
COPY F T
LINK 800
LINK 800
COPY T M
WIPE

XC local
GRAB 300
COPY F X
SEEK 999
COPY M F
LINK 800
LINK 800
COPY M T
REPL CALLER
MODE
SEEK -1
COPY F X
SEEK -1
MARK BACK
COPY M F
COPY X F
COPY 1 F
COPY 0 F
JUMP BACK
DROP
KILL
KILL
GRAB 199
SEEK 999
COPY 300 F
MARK CALLER
GRAB 199
MARK CALLING
REPL FILEHOLD
COPY F M
NOOP
JUMP CALLING
MARK FILEHOLD
GRAB M
MODE
COPY F M
SEEK 999
COPY X F
COPY T F
COPY 1 F
COPY 0 F

XB
LINK 800
LINK 800
COPY 25 T
MARK WAIT
SUBI T 1 T
TJMP WAIT
NOOP
KILL
KILL
GRAB 199
SEEK 999
COPY 300 F
There's what looks like a clumsy write of CREDIT only to grab it again later, but that exa isn't the bottleneck. I try not to use conditionals since you need registers to store other information; this means I need a timing exa to kill things later.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply