Macro Megathread

Post your coolest Hexcasting creations here.

New topics are NOT for chatting or asking help, put those in the comments of a post or in a different forum.
User avatar
Robotgiggle
Posts: 23
Joined: Fri Dec 02, 2022 12:38 am

Re: Macro Megathread

Post by Robotgiggle »

I posted these spells in their own thread last year, but that thread is now totally buried. Given how useful they are as macros, I thought I'd repost them here. Credit for Locator's Scalpel goes to [object Object], not myself, though I changed the macro pattern to a new one that better fits the theme of the other two.

Robo's Scalpel
list, num, list → list
Works just like Surgeon's Exaltation, but replaces the given index in the first list with the flattened content of the second list. Mainly intended for modifying spells, but you can probably find some other interesting uses.
wwded
Patterns
ddqddaadadaawNumerical Reflection: 1waawaaeddaqaeaqqaeaqwdedddqddNumerical Reflection: 0aawddqaeaqwdedddqddqaeaqqaeaq

Code: Select all

#define Robo's Scalpel (EAST wwded) = list, num, list -> list
{
    Rotation Gambit II
    Dioscuri Gambit
    Numerical Reflection: 1
    Additive Distillation
    Prospector's Gambit
    Abacus Purification
    Selection Exaltation
    Rotation Gambit II
    Numerical Reflection: 0
    Jester's Gambit
    Selection Exaltation
    Rotation Gambit II
    Combination Distillation
    Combination Distillation
}
Advanced Scalpel
list, num, num, list → list
A more powerful version of the above spell. Replaces all the items in the first list between the two provided indices (lower bound inclusive, upper bound exclusive) with the flattened content of the second list.
wwdewdda
Patterns
Numerical Reflection: 21qaawddeaadaaaaeaaaaeddaqaeaqqaeaqwdedddqddNumerical Reflection: 0aaeaaqaeaqwdedddqddqaeaqqaeaq

Code: Select all

#define Advanced Scalpel (EAST wwdewdda) = list, num, num, list -> list
{
    Numerical Reflection: 21
    Swindler's Gambit
    Gemini Decomposition
    Rotation Gambit
    Prospector's Gambit
    Abacus Purification
    Selection Exaltation
    Rotation Gambit II
    Numerical Reflection: 0
    Rotation Gambit
    Selection Exaltation
    Rotation Gambit II
    Combination Distillation
    Combination Distillation
}
Locator's Scalpel
list, pattern, list → list
Modified version of Robo's Scalpel that takes a pattern instead of an index, and replaces the first index of that pattern in the first list with the contents of the second list. (As with the original, does not fail gracefully.)
wwdedqde
Patterns
ddqddaaeddaawdddedqdeaadadaawNumerical Reflection: 1waawaaeddaqaeaqqaeaqwdedddqddNumerical Reflection: 0aawddqaeaqwdedddqddqaeaqqaeaq

Code: Select all

#define Locator's Scalpel (EAST wwdedqde) = list, pattern, list -> list
{
    Rotation Gambit II
    Prospector's Gambit
    Jester's Gambit
    Locator's Distillation

    Dioscuri Gambit
    Numerical Reflection: 1
    Additive Distillation
    Prospector's Gambit
    Abacus Purification
    Selection Exaltation

    Rotation Gambit II
    Numerical Reflection: 0
    Jester's Gambit
    Selection Exaltation

    Rotation Gambit II
    Combination Distillation
    Combination Distillation
}
Last edited by Robotgiggle on Sat Aug 03, 2024 1:16 am, edited 2 times in total.
stevebutnottoomany
Posts: 9
Joined: Wed Dec 28, 2022 5:07 am

Re: Macro Megathread

Post by stevebutnottoomany »

Steve's Prism Counter
integer, vectorvector
Quite an old spell of mine, finally got around to writing it up in the modern style.
Takes an index and a vector describing a rectangular prism, and returns a vector inside the prism. Incrementing the index by one always returns a point adjacent to the previous, making the spell ideal for walking a sentinel over a volume.
For an example of the spell, with the input vector (2,2,2), see: https://imgur.com/a/3ES0Fov
The typical use case is to take the macro's output, multiply it by some scaling factor, and add to a root position, to return a coordinate in the world. I use this for all my quarries and similar.
The math driving it may be found here: https://www.desmos.com/calculator/etyirquwga
NB the macro clobbers the ravenmind, so save it to the stack before using if required
Patterns
aadaaeqqwawqaawqeeeeeNumerical Reflection: 3ddadwqaqwNumerical Reflection: 3ddadwqaqwNumerical Reflection: 3ddadwqaqwqeewdweddwqeeeeeNumerical Reflection: 7ewdqdweeqqwawqaawqeewdweddwaadaaNumerical Reflection: 0deeedaawddNumerical Reflection: 3deeedwdedwewqqeewdweddwNumerical Reflection: 1deeedNumerical Reflection: 0.5waawwaawqeewdweddwNumerical Reflection: 1deeedNumerical Reflection: 2waqawaddwaadqeewdweddwNumerical Reflection: 1deeedwddwwqaqwNumerical Reflection: 0.5wddwqeewdweddwNumerical Reflection: 4deeedNumerical Reflection: 0.25waawaadaawqaqwwdedwwaqawqeewdweddwaadaaNumerical Reflection: 0deeedaawddaadaaNumerical Reflection: 1deeedaawddNumerical Reflection: 3deeedwaqawwdedwewqqeewdweddwNumerical Reflection: 5deeedNumerical Reflection: 0.25waawaadaawqaqwwdedwwaqawqeewdweddwaadaaNumerical Reflection: 0deeedaawddNumerical Reflection: 3deeedNumerical Reflection: 0.5waawwaawqeewdweddwNumerical Reflection: 3deeedNumerical Reflection: 2waqawaddwaadqeewdweddwNumerical Reflection: 3deeedNumerical Reflection: 2Bookkeeper's Gambit: Drop 1wddwwqaqwNumerical Reflection: 0.5wddwqeewdweddwNumerical Reflection: 6deeedNumerical Reflection: 0.25waawaadaawqaqwwdedwwaqaweqqqqq

Code: Select all

{                                   //i n
    Gemini Decomposition            //i n n
    Huginn's Gambit                 //i n
    Vector Disintegration           //i n_x n_y n_z
    Numerical Reflection: 3         //i n_x n_y n_z
    Fisherman's Gambit              //i n_y n_z n_x
    Length Purification             //i n_y n_z |n_x|
    Numerical Reflection: 3
    Fisherman's Gambit
    Length Purification             //i n_z |n_x| |n_y|
    Numerical Reflection: 3
    Fisherman's Gambit
    Length Purification             //i |n_x| |n_y| |n_z|
    Muninn's Reflection             //i |n_x| |n_y| |n_z| n
    Vector Disintegration           //i |n_x| |n_y| |n_z| n_x n_y n_z
    Numerical Reflection: 7
    Flock's Gambit
    Huginn's Gambit                 //
    Muninn's Reflection             //[i, |n_x|, |n_y|, |n_z|, n_x, n_y, n_z]
    Gemini Decomposition
    Numerical Reflection: 0
    Selection Distillation          //[i, |n_x|, |n_y|, |n_z|, n_x, n_y, n_z] i
    Jester's Gambit
    Numerical Reflection: 3
    Selection Distillation          //i |n_z|
    Division Distillation
    Floor Purification              //floor(i/|n_z|)
    Muninn's Reflection
    Numerical Reflection: 1
    Selection Distillation          //floor(i/|n_z|) |n_x|
    Numerical Reflection: 0.5
    Additive Distillation
    Additive Distillation           //floor(i/|n_z|)+|n_x|+0.5
    Muninn's Reflection
    Numerical Reflection: 1
    Selection Distillation
    Numerical Reflection: 2
    Multiplicative Distillation     //floor(i/|n_z|)+|n_x|+0.5 2|n_x|
    Modulus Distillation            //(floor(i/|n_z|)+|n_x|+0.5)%(2|n_x|)
    Muninn's Reflection
    Numerical Reflection: 1
    Selection Distillation
    Subtractive Distillation
    Length Purification             //|(floor(i/|n_z|)+|n_x|+0.5)%(2|n_x|)-|n_x||
    Numerical Reflection: 0.5
    Subtractive Distillation        //|(floor(i/|n_z|)+|n_x|+0.5)%(2|n_x|)-|n_x||-0.5
    Muninn's Reflection
    Numerical Reflection: 4
    Selection Distillation
    Numerical Reflection: 0.25
    Additive Distillation           //(|(floor(i/|n_z|)+|n_x|+0.5)%(2|n_x|)-|n_x||-0.5) n_x+0.25
    Gemini Decomposition
    Length Purification
    Division Distillation           //(|(floor(i/|n_z|)+|n_x|+0.5)%(2|n_x|)-|n_x||-0.5) sign(n_x)
    Multiplicative Distillation     //sign(n_x)*prism_x_i
    Muninn's Reflection
    Gemini Decomposition
    Numerical Reflection: 0
    Selection Distillation          //sign(n_x)*prism_x_i [list] i
    Jester's Gambit
    Gemini Decomposition
    Numerical Reflection: 1
    Selection Distillation
    Jester's Gambit
    Numerical Reflection: 3
    Selection Distillation
    Multiplicative Distillation
    Division Distillation
    Floor Purification              //sign(n_x)*prism_x_i floor(i/(|n_x|*|n_z|))
    Muninn's Reflection
    Numerical Reflection: 5
    Selection Distillation
    Numerical Reflection: 0.25
    Additive Distillation
    Gemini Decomposition
    Length Purification
    Division Distillation
    Multiplicative Distillation     //sign(n_x)*prism_x_i sign(n_y)*prism_n_y
    Muninn's Reflection
    Gemini Decomposition
    Numerical Reflection: 0
    Selection Distillation
    Jester's Gambit
    Numerical Reflection: 3
    Selection Distillation
    Numerical Reflection: 0.5
    Additive Distillation
    Additive Distillation
    Muninn's Reflection
    Numerical Reflection: 3
    Selection Distillation
    Numerical Reflection: 2
    Multiplicative Distillation
    Modulus Distillation
    Muninn's Reflection
    Numerical Reflection: 3
    Selection Distillation
    Numerical Reflection: 2
    Bookkeeper's Gambit: v
    Subtractive Distillation
    Length Purification
    Numerical Reflection: 0.5
    Subtractive Distillation        //sign(n_x)*prism_x_i sign(n_y)*prism_n_y |(i+(|n_z|+1/2))%(2|n_z|) - |n_z||-0.5
    Muninn's Reflection
    Numerical Reflection: 6
    Selection Distillation
    Numerical Reflection: 0.25
    Additive Distillation
    Gemini Decomposition
    Length Purification
    Division Distillation
    Multiplicative Distillation     //sign(n_x)*prism_x_i sign(n_y)*prism_n_y sign(n_z)*prism_n_z
    Vector Exaltation               //(sign(n_x)*prism_x_i, sign(n_y)*prism_n_y, sign(n_z)*prism_n_z)
}
User avatar
Agent
Posts: 1
Joined: Sun Jun 02, 2024 6:49 am

Re: Macro Megathread

Post by Agent »

Flatten Purification
listlist
Flattens a list of lists into a single list.
qaeaqa
Patterns
qqq aadaa aqaeaq Numerical Reflection: 1 wddw eqqwawqaaw qwaeawq qqq qaeaq eee qwaeawq qeewdweddw aadaadaa qeewdweddw ewdqdwe deaqq eee

Code: Select all

#define Flatten Purification (NORTH_WEST qaeaqa) list -> list
{
	Gemini Decomposition
	Abacus Purification
	Numerical Reflection: 1
	Subtractive Distillation
	Huginn's Gambit
	Flock's Disintegration
	{
	    Combination Distillation
	}
	Flock's Disintegration
	Muninn's Reflection
	Gemini Gambit
	Muninn's Reflection
	Flock's Gambit
	Hermes' Gambit
}
Going to keep working towards one that doesn't use the ravenmind.
Argitechno
Posts: 3
Joined: Wed Aug 02, 2023 8:45 pm

Re: Macro Megathread

Post by Argitechno »

Flatten Purification II
listlist
Convert a nested list into a single list, regardless of level of nesting.

edqded
Patterns
qqqadeeedqqaeaaeaawddqqqaadaaawqqqqaeaqaadaaawdqqaeaaeawdadqqqwaaweeeqwaeawqqqqaaeaaaawddedqdeaawddeeeawdddeaqqeeeqqqaqdeeeeeqwaeawqawdddeaqqNumerical Reflection: 2aadadeaqqeeeddqddNumerical Reflection: 2aadadeaqqBookkeeper's Gambit: Drop 1, Keep 1, Drop 1eeeqqqqqqaedeaaqwqaaaawddqqqaedeaawddeee

Code: Select all

//Convert a nested list into a single list, regardless of level of nesting.
#define Flatten Purification II (sw  edqded)
{
    Single's Purification //Enlist the list (this is stack list)
    Vacant Reflection //Push empty list (this is return list)
    Jester's Gambit //Swap

    Introspection

        //-> [ [ret], [stack]]
        Gemini Decomposition
        Augur's Purification
        //Is list empty?
        //-> [ [ret], [stack], bool]

        Introspection

            Derivation Distillation

            //-> [...[ret], [stack], i[?] ]

            Gemini Decomposition
            Classifier's Purification
            Vacant Reflection
            Classifier's Purification
            Equality Distillation

            //Top Iota is List?

            Introspection //If
                Additive Distillation //-> [ ... [ret], [stack] ]  
            Retrospection
            Flock's Disintegration

            Introspection //Else
                Rotation Gambit
                Jester's Gambit
                Integration Distillation 
                Jester's Gambit //-> [ ... [ret, i], [stack] ]
            Retrospection

            Augur's Exaltation
            Hermes' Gambit
                
            //-> [...[P],[stack],[ret]]

        Retrospection

        Introspection
            Charon's Gambit
        Retrospection
        Flock's Disintegration
        Augur's Exaltation
        Hermes' Gambit
        //-> [ [ret], [stack]]
        Numerical Reflection: 2
        Fisherman's Gambit II
        Hermes' Gambit
        
    Retrospection

    Rotation Gambit II
    Numerical Reflection: 2
    Fisherman's Gambit II
    Hermes' Gambit

    Bookkeeper's Gambit: v-v
}


//For those in 1.19
#define Derivation Distillation (nw qaeaq)
{
    Retrograde Purification
    Speaker's Decomposition
    Jester's Gambit
    Retrograde Purification
    Jester's Gambit
}
User avatar
[object Object]
Posts: 70
Joined: Fri Dec 02, 2022 12:37 am

Vector Angles

Post by [object Object] »

Theta Distillation
vec1, vec2angle
Returns the unsigned angle (in radians) between two vectors.
awddeeeeeqa
Patterns
qqqaadadaawwaqawddqddwqaqwaawddwqaqwwaqawwdedwadeeeeeeee

Code: Select all

#define Theta Distillation (NORTH_WEST awddeeeeeqa) = vec, vec -> num
// u, v -> angle
// Returns the unsigned angle (in radians) between two vectors.
{
    // u * v
    Dioscuri Gambit
    Multiplicative Distillation
    
    // |u| * |v|
    Rotation Gambit II
    Length Purification
    Jester's Gambit
    Length Purification
    Multiplicative Distillation
    
    // arccos((u * v) / (|u| * |v|))
    Division Distillation
    Inverse Cosine Purification
}
Theta Exaltation
vec1, vec2, normalangle
Returns the signed angle (in radians) between two vectors, given the plane normal as a unit vector.
Required macros: Inverse Tangent Distillation
dwaaqqqqqed
Patterns
qqqddqddaadadaawwdedwddqddwaqawddqddwaqawaawddqdaqqqqqweee

Code: Select all

#define Theta Exaltation (NORTH_EAST dwaaqqqqqed) = vec, vec, vec -> num
// u, v, n -> angle
// Returns the signed angle (in radians) between two vectors, given the plane normal as a unit vector.
{
    // u x v
    Rotation Gambit II
    Dioscuri Gambit
    Division Distillation

    // u * v
    Rotation Gambit II
    Multiplicative Distillation

    // (u x v) * n
    Rotation Gambit II
    Multiplicative Distillation

    // atan2((u x v) * n, u * v)
    Jester's Gambit
    Inverse Tangent Distillation
}
Shibva_
Posts: 2
Joined: Tue Feb 21, 2023 10:13 pm

Re: Macro Megathread

Post by Shibva_ »

I have come to notice just how useful Robo's Hex surgical tools are so I decided to take one of his scalpels to make a special variant of it

Shiv's Bonesaw
Num (index with a list), Num, Num, List → List
Functions identically to how Advanced Scalpel works but is altered to take an index of a stack instead to allow for a list deep in a stack to be edited.
waaqwwdewdda
The index parameter uses a +5 internal offset to allow for it to function as if it were Fisherman's Distillation (putting 0 in the parameter gets the element right below it at that position in a stack with all parameters in place).

Because of how it's structured it can be altered to have it edit a list nested inside of a list but only to a list inside of a list.
Patterns
ddqddNumerical Reflection: 3aadaNumerical Reflection: 5waawddadaadaaaaeaaaaeddaqaeaqdeeedddqddNumerical Reflection: 0deeedddqddqaeaqqaeaqaawddNumerical Reflection: 1waawewdqdweqqqaedeaaqwqaaaawddqqqaedeqwaeawq
Note: Some of the patterns are intentionally drawn at a different angle for the sake of being able to easily spot a difference between patterns with similar shapes

Code: Select all

{
//I'M GOING TO SAW THROUGH YOUR MIND!
	Rotation Gambit II
	Numerical Reflection: 3
	Fisherman's Gambit II
	Numerical Reflection: 5
	Additive Distillation
	Fisherman's Gambit
	Gemini Decomposition
	Rotation Gambit
	Prospector's Gambit
	Abacus Purification
	Selection Exaltation
	Rotation Gambit II
	Numerical Reflection: 0
	Rotation Gambit 
	Selection Exaltation
	Combination Distillation
	Combination Distillation
	Jesters Gambit
	Numerical Reflection: 1
	Addadive Distillation
	Flock's Disintegration
	Retrograde Purification
	Speaker's Decomposition
	Jester's Gambit
	Retrograde Purification
	Flock's Gambit
}
miyu
Posts: 5
Joined: Mon Jul 03, 2023 6:52 pm

Re: Macro Megathread

Post by miyu »

Duplicate Distillation
list, anynumber
Takes a list and an iota, and returns how many times the iota appears in the list.
aqadeeee

Code: Select all

Prospector's Gambit
Abacus Purification
Rotation Gambit II
Single's Purification
Exclusionary Distillation
Abacus Purification
Subtractive Distillation