SuperFactoryManager icon indicating copy to clipboard operation
SuperFactoryManager copied to clipboard

[Suggestion] adjecent block label

Open 4Magma opened this issue 6 months ago • 7 comments

New keyword ADJECENT reduces matches of a label to blocks adjecent to the opposite block of a transfer.

Syntax:

INPUT FROM ADJECENT label
OUTPUT TO ADJECENT label

Usage example:

label all

  • input inventories with "i"
  • processing devices with "io"
  • output inventories with "o"
EVERY 1 SECONDS DO
	INPUT FROM ADJECENT _i_
	OUTPUT TO _io_
	FORGET
	INPUT FROM _io_
	OUTPUT TO ADJECENT _o_
END

For production chains, where a inventory is output of one device and input of another device, simply alternate with a second set of labels.

4Magma avatar May 16 '25 23:05 4Magma

To confirm my understanding

A B C
A B C
A B C
A B C

Currently this SFM program

INPUT FROM a
OUTPUT TO b
FORGET
INPUT FROM b
OUTPUT TO c

would cause contamination where inputs from a1 could get to b4

You effectively want

INPUT FROM a
OUTPUT TO ADJACENT b
FORGET
INPUT FROM b
OUTPUT TO ADJACENT c

which would transform the problem into

A1 B1 C1
A2 B2 C3
A3 B3 C3
A4 B4 C4
INPUT FROM a1
OUTPUT TO b1
FORGET
INPUT FROM a2
OUTPUT TO b2
FORGET
INPUT FROM a3
OUTPUT TO b3
FORGET
INPUT FROM a4
OUTPUT TO b4
FORGET

INPUT FROM b1
OUTPUT TO c1
FORGET
INPUT FROM b2
OUTPUT TO c2
FORGET
INPUT FROM b3
OUTPUT TO c3
FORGET
INPUT FROM b4
OUTPUT TO c4

?

TeamDman avatar May 17 '25 16:05 TeamDman

Yeah,

only the direct neighbors to a "b" are matches for "a" and "c"

4Magma avatar May 17 '25 20:05 4Magma

ups, i missed an error in your question

not

INPUT FROM a
OUTPUT TO ADJACENT b <--
FORGET
INPUT FROM b
OUTPUT TO ADJACENT c

but

INPUT FROM ADJACENT a <--
OUTPUT TO  b
FORGET
INPUT FROM b
OUTPUT TO ADJACENT c

The ADJACENT is located before the label which matches should be reduced.

  • for each "b"
    • input from nearest/adjacent "a"
    • output to current "b"
    • forget
    • input from current "b"
    • output to nearest/adjecent "c"

4Magma avatar May 18 '25 16:05 4Magma

It should be possible to have it on both, I thought for a second that it would only make sense on the output statement but given how moveTo works it should be fairly simple to check for an adjacency condition on either side of the movement.

INPUT FROM ADJACENT a
OUTPUT TO b
-- would be the same as
INPUT FROM a
OUTPUT TO ADJACENT b
-- would be the same as
INPUT FROM ADJACENT a
OUTPUT TO ADJACENT b

TeamDman avatar May 18 '25 16:05 TeamDman

what's with multiple inputs, e.g.

INPUT xyz FROM storage_system
INPUT FROM ADJACENT a
OUTPUT TO b

if "b" is adjacent, only would be the "b" next to a "a" and "storage_system" a match.

4Magma avatar May 18 '25 17:05 4Magma

for that example, the storage system would not need to be adjacent to b, unless you changed it to

INPUT xyz FROM storage_system
INPUT FROM a
OUTPUT TO ADJACENT b

TeamDman avatar May 18 '25 17:05 TeamDman

the code section shows the correct way the paragraph below the problem if adjacent would be on "b" instead of "a"

4Magma avatar May 18 '25 17:05 4Magma