SuperFactoryManager icon indicating copy to clipboard operation
SuperFactoryManager copied to clipboard

[Feature Request] Output to blocks with MATCHING input labels (new keyword)

Open zarillion opened this issue 6 months ago • 0 comments

Problem Statement

Consider the following HNN script:

NAME "Hostile Neural Networks"

EVERY 20 TICKS DO
    INPUT FROM matrices
    OUTPUT hostilenetworks:prediction_matrix TO sim
FORGET
    INPUT forge_energy:: FROM power TOP SIDE
    OUTPUT forge_energy:: TO sim, fab
FORGET
    INPUT FROM sim, fab
    OUTPUT TO drawers
END

EVERY 20+10 TICKS DO
    INPUT 1 hostilenetworks:prediction FROM enderman
    OUTPUT TO enderman ROUND ROBIN BY BLOCK
FORGET
    INPUT 1 hostilenetworks:prediction FROM zombie
    OUTPUT TO zombie ROUND ROBIN BY BLOCK
FORGET
    INPUT 1 hostilenetworks:prediction FROM creeper
    OUTPUT TO creeper ROUND ROBIN BY BLOCK
FORGET
    INPUT 1 hostilenetworks:prediction FROM skeleton
    OUTPUT TO skeleton ROUND ROBIN BY BLOCK
FORGET
    INPUT 1 hostilenetworks:prediction FROM witch
    OUTPUT TO witch ROUND ROBIN BY BLOCK
FORGET
    INPUT 1 hostilenetworks:prediction FROM spider
    OUTPUT TO spider ROUND ROBIN BY BLOCK
END

In this setup, both the simulation chamber and the associated loot fabricators have matching labels for the mob they are simulating.

I'm looking for a feature that would simplify the second per-mob block that would allow an HNN farm to expand without adding additional statements.

Proposal - MATCHING keyword

If the mob labels used a common prefix like mob_, then the input statement could look something like this:

INPUT 1 hostilenetworks:prediction FROM mob_*

What could an appropriate OUTPUT statement look like here? We want it to output to each matching output label. Maybe something like:

OUTPUT TO MATCHING ROUND ROBIN BY BLOCK

Then the entire block could be simplified to:

EVERY 20+10 TICKS DO
    INPUT 1 hostilenetworks:prediction FROM mob_*
    OUTPUT TO MATCHING ROUND ROBIN BY BLOCK
END

This would take 1 prediction from mob_creeper, and then send it to any block labeled with mob_creeper in a round-robin fashion.

Multiple Inputs

The MATCHING keyword is easy to reason about when only 1 label or pattern is in play, but what if there are multiple inputs?

INPUT stone FROM a
INPUT FROM storage_*
OUTPUT TO MATCHING

In this example, it would output to any blocks with both an a label and a label matching storage_*. Is this useful? I'm not sure, but a behavior has to be defined and I think matching all input labels and patterns is a sensible default.


Please let me know what you think! I believe this concept could be pretty powerful and would simplify a lot of scripts out there without the need for introducing variables, lists, etc.

zarillion avatar Jun 10 '25 23:06 zarillion