# Tips for golfing in The Powder Toy

Have fun with this one, The Powder Toy is a interesting challenge for golf, especially with filt logic.

The thing that makes TPT a challenge is the many many many many ways to approach a problem: Should I use Cellular Automaton rules, SWCH logic, Filt logic, subframe filt logic, and/or wall logic?

As such, a location for tips for TPT golfing would be quite helpful, so I made this question thread.

This thread will likely use a lot of abbreviations. A lot of them will be in-game elements, so searching them up on the Wiki will bring you a lot of information about them, like what they are.

Here are the most common ones you'll likely see in this thread, with their ingame description attached (and their full name), for people who don't want to go searching:

• SPRK: Electricity. The basis of all electronics in TPT, travels along wires and other conductive elements.
• FILT: Filter. Filter for photons, changes the color.
• ARAY: Ray Emitter. Rays create points when they collide.
• BTRY: Battery. Generates infinite electricity.
• DRAY: Duplicator ray. Replicates a line of particles in front of it.
• CRAY: Particle Ray Emitter. Creates a beam of particles set by its ctype, with a range set by tmp.
• SWCH: Switch. Only conducts when switched on. (PSCN switches on, NSCN switches off)

List of all elements

• @mbomb007 Thanks for adding the link. I was just going to ask for that. I don't know TPT and thought it was a challenge about toys that used to be -- and maybe still are -- found in packs of detergent... :/ Commented May 3, 2018 at 14:08
• @Arnauld Haha. Whoops. Thanks mbomb007 :P Commented May 3, 2018 at 14:14
• How do you even calculate the score? Commented May 3, 2018 at 14:30
• @12Me21 At the moment, the score is based on save file. You can discuss that in this meta post Commented May 3, 2018 at 14:49

# Only use subframe logic when it's smaller

And, for more complex machines, it's often much smaller.

Subframe generally imposes the overhead of creating solid SPRK (about 3 pixels for most directions, an extra pixel compared to just a BTRY), FILT 'channels' (for fast BRAY transfer), and minimizing the amount of nonsubframe logic, even if it's smaller, due to it being many times (4x to 20x-30x slower!) slower.

Subframe logic is often good for complex operations (which is most of the challenges here), but for simpler ones, subframe logic is probably not optimal.

• pls add images tyvm Commented May 3, 2018 at 13:39
• @ASCII-only Will do when I get home. Commented May 3, 2018 at 13:41
• It'd be nice if you could spell things out instead of using so many abbreviations. Not everyone is familiar with the game, but some might find it interesting. Commented May 3, 2018 at 13:59
• @mbomb007 Just going to note, FILT, BTRY, BRAY, SPRK, etc are just names for in-game particles. The game itself uses those names. Shall I put the game's wiki in the main post instead? People can search those names there and figure out what they are quite easily. Commented May 3, 2018 at 14:03

FILT is, at least for FILT and subframe logic, the cornerstone of computing in TPT. And as such, it has a bunch of tricks to make your life easier, in the form of it's various modes. You set a FILT mode using tmp, but a comprehensive list that describes the intricacies of these modes isn't really a thing right now. FILT takes two inputs: it's own color (CTYPE) and the color of what it's interacting with, either BRAY or CRAY. I'll label these FILTC and INTRC, respectively, for this list.

• Mode 0:

The simplest mode, it sets INTRC to the value of FILTC, nothing more.

INTRC = FILTC

• Mode 1:

This is a binary AND, it ands together INTRC and FILTC, setting INTRC to the result.

INTRC = INTRC & FILTC

• Mode 2:

This is a binary OR, it ors together INTRC and FILTC, setting INTRC to the result.

INTRC = INTRC & FILTC

• Mode 3:

This mode is slightly more complicated, it ands together the inverse of FILTC and INTRC, setting INTRC to the result.

INTRC = INTRC & (~FILTC)

• Mode 4:

This mode is a bit harder to describe. It's a red shift (binary left shift),

The catch here is that the amount it shifts by is controlled by it's temperature, with the equation (Temperature-273.0)*0.025, defaulting to a shift by 1 if the value is less than 1. You can acheive a shift of any required amount by multiplying the number of bits you need by 40, and adding 273.0. I'll call the amount shifted X.

As such, INTRC is shifted left by X, setting INTRC to the result.

X = (temperature-273.0)*0.025
INTRC = INTRC << X

• Mode 5:

This is essentially mode 4, but with a right shift instead. See the information on mode 4 for how to use it.

X = (temperature-273.0)*0.025
INTRC = INTRC >> X

• Mode 6:

Does nothing.

INTRC = INTRC

• Mode 7:

Performs a binary XOR on INTRC and FILTC, setting INTRC to the result.

INTRC = INTRC ^ FILTC

• Mode 8:

Performs a binary NOT on INTRC, setting INTRC to the result.

INTRC = ~INTRC

• Mode 9:

Sets INTRC to a random color.

INTRC = rand()

• Mode 10:

Performs a different version of a red shift.

[TODO: figure out how to describe]

LSB = FILTC & (-FILTC)
INTRC = INTRC * LSB

• Mode 11:

Performs a different version of a blue shift.

[TODO: figure out how to describe]

LSB = FILTC & (-FILTC)
INTRC = INTRC / LSB