Linear Impulse
entity, vector →
Meta-eval usage: ceil(|v|) + 1
Dust cost (integer length): max(0, 2*|v| - 1)
Dust cost (non-integer length): 2*floor(|v|) + (|v| - floor(|v|))^2
(Note: |v| is the length of the vector.)
Patterns
Code: Select all
#define Linear Impulse (SOUTH_WEST awqqqwaqww) = entity, vector ->
{
// save previous ravenmind
Muninn's Reflection
Rotation Gambit II
// on the first iteration, normalize the impulse vector and get its length
// or just push 0 if it's the zero vector to avoid dividing by zero
Gemini Decomposition
Vector Reflection Zero
Inequality Distillation
{
Gemini Decomposition
Length Purification
Undertaker's Gambit
Division Distillation
Jester's Gambit
}
{
Numerical Reflection: 0
}
Augur's Exaltation
// recursive function to actually do the impulse
{
// is the remaining speed greater than 1?
Gemini Decomposition
Numerical Reflection: 1
Maximus Distillation
// if so, impulse by the unit vector (length 1) and decrement the speed
// then do the recursive function again
{
Rotation Gambit II
Dioscuri Gambit
Impulse
Rotation Gambit
Numerical Reflection: 1
Subtractive Distillation
}
Muninn's Reflection
Combination Distillation
// otherwise, impulse by the remaining speed and don't recurse
{
Multiplicative Distillation
Impulse
}
Augur's Exaltation
Hermes' Gambit
}
Gemini Decomposition
Huginn's Gambit
Combination Distillation
Hermes' Gambit
// restore previous ravenmind
Huginn's Gambit
}
Normally, Impulse costs dust equal to the square of the length of the vector (|v|). However, if you split up this impulse into |v| length-1 impulses (assuming integer length), then each impulse would cost just one dust. The mod also adds one dust to the cost of all impulses on the same entity in the same hex after the first (to avoid stacking very short impulses for basically free), so the cost is increased slightly, but it's still linear, not quadratic. If the vector is of non-integer length, the hex does floor(|v|) length-1 impulses, then one impulse equal to the decimal component of the length.