The Easiest Hammer

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
Snazz
Posts: 8
Joined: Wed Dec 14, 2022 11:34 pm

The Easiest Hammer

Post by Snazz »

The tiny 3x3 hammer thread and various other discussions on discord lead me down a rabbit hole of trying to create the fewest patterns hammer possible in base hexcasting. Specifically, find the fewest total patterns you have to draw out in order to put an iota list for a hammer spell on the stack. (this includes patterns required for embedding data). Ideally the goal should be a short spell that just works, requiring no other spells, and no other mods.


My first attempt was an idea to break the center block, then use trig to rotate a vector in a circle perpendicular to the block face, breaking the other 8 blocks. I was able to get down to 40 patterns using this method.
Spoiler

Code: Select all

// rotary hammer
{
    // get the pos and side
    Mind's Reflection
    Compass' Purification
    Mind's Reflection
    Alidade's Purification
    Dioscuri Gambit
    Archer's Distillation
    Rotation Gambit II
    Architect's Distillation

    // break the center block
    Prospector's Gambit
    Break Block

    // get the vectors that define the normal of the side
    Gemini Decomposition
    Vector Disintegration
    Rotation Gambit
    Vector Exaltation
    Undertaker's Gambit
    Division Distillation

    // rotate about the center and break
    {
        Muninn's Reflection
        Additive Distillation
        Undertaker's Gambit
        Gemini Decomposition
        Huginn's Gambit
        Sine Purification
        Multiplicative Distillation
        Rotation Gambit II
        Cosine Purification
        Multiplicative Distillation
        Additive Distillation
        Additive Distillation
        Break Block
    }

    Numerical Reflection: 5.5 // roughly equal to pi * 7/4
    Numerical Reflection: 9
    Gemini Gambit // make 9 copies
    Huginn's Gambit // save an initial angle to the ravenmind
    Numerical Reflection: 8
    Flock's Gambit
    Thoth's Gambit
}
My second attempt was to use a nested Thoth gambit to iterate over a 3x3 area, and map this 3x3 to the surface I wanted to break by multiplying each number by the two surface basis vectors. This produced a hammer in just 36 patterns.
Spoiler

Code: Select all

// slinger's hammer
{
    // get the pos and side
    Mind's Reflection
    Compass' Purification
    Mind's Reflection
    Alidade's Purification

    Dioscuri Gambit
    Archer's Distillation
    Rotation Gambit II
    Architect's Distillation

    // get the vectors that define the normal of the side
    Gemini Decomposition
    Vector Disintegration
    Rotation Gambit
    Vector Exaltation
    Undertaker's Gambit
    Division Distillation

    // create the iteration list
    Numerical Reflection: -1
    Numerical Reflection: 0
    Numerical Reflection: 1
    Numerical Reflection: 3
    Flock's Gambit

    Undertaker's Gambit

    {
        Multiplicative Distillation
        Rotation Gambit II
        {
            Multiplicative Distillation
            Additive Distillation
            Additive Distillation
            Break Block
        }
        Jester's Gambit
        Thoth's Gambit
    }
    
    Jester's Gambit
    Thoth's Gambit
}
My third attempt was to use a double nested Thoth to iterate over a 3x3x3 area, and then project each vector to the plane defined by the surface normal. I was able to use a shortcut I learned from [object Object] for the projection, It turns out that taking the cross product has a similar effect to projecting a vector onto a plane; It always produces a vector that lies on the normal planes of both input vectors. This hammer took only 33 patterns, but has the major drawback of costing 3x as much media as other hammers.
Spoiler

Code: Select all

// wasteful hammer
{
    Mind's Reflection
    Compass' Purification
    Mind's Reflection
    Alidade's Purification

    Dioscuri Gambit
    Archer's Distillation
    Rotation Gambit II
    Architect's Distillation

    {
        {
            {
                Vector Exaltation
                Division Distillation
                Additive Distillation
                Break Block
            }
            Numerical Reflection: 4
            Fisherman's Gambit
            Thoth's Gambit
        }
        Rotation Gambit
        Thoth's Gambit
    }

    Numerical Reflection: -1
    Numerical Reflection: 0
    Numerical Reflection: 1

    Numerical Reflection: 3
    Flock's Gambit
    Undertaker's Gambit
    Undertaker's Gambit

    Thoth's Gambit
}


Thinking about that last idea, I realized that if I had 9 vectors that form a square when flattened in the x, y, or z directions, I could produce a normal media cost hammer with very few patterns. It turns out that such a set of vectors does exist, and are connected to a mathematical concept called Latin Squares.
https://www.youtube.com/watch?v=Cnhr6VaQKlg

I tested this idea using an embedded list of vectors, and It worked perfectly. Math321 pointed out that it was possible to use the solution of a Sudoku puzzle to produce the 81 vectors required for creating a 9x9 hammer with this method as every Sudoku solution is a Latin Square, so we started calling these sets of vectors the "Sudoku vectors" of the hammer.

The last step to completion of the spell was removing the overhead of having to use Kirin's Ruler to produce the Sudoku vectors.
Because there must be one vector in every row, column, and stack, I can iterate over the rows and columns, and use some function to determine how high on the stack the vector should be.
It turns out that if I use the sum of the row and column index for the stack index, I get a shape that nearly works. The only issue is when both the row and column index is -1 or +1, resulting in a stack index of -2 or +2, which is outside the bounds of the 3x3x3.
Image

To remedy this, -2 must be wrapped to +1, and +2 must be wrapped to -1. Instead of using the modulo pattern for this, I found a more compact method using the trig functions. It turns out that the function f(x) = sin(tan(x)) preserves -1, 0, and 1, but maps -2 to +0.817, and +2 to -0.817. It's okay that the function isn't super precise because when we call break block, it'll work if the vector is anywhere within the block volume (It always floors the vector to the block coordinate).
Image

Putting it all together, the resulting spell:

Sage's Hammer (31 patterns)
qqqqaqaaqaqwaaadadaawwqaawddddqddweddwaaqqqqqqaadadaawwaawwqqqqqadqqqqqqaaeqqqqqwdedwwaawqaqqqqqeeeaaeaadadadeeeNumerical Reflection: -1Numerical Reflection: 0Numerical Reflection: 1Numerical Reflection: 3ewdqdweddqaadadadeee

Code: Select all

// sage hammer
{
    // get the block coordinate, and the face normal
    Mind's Reflection
    Compass' Purification
    Mind's Reflection
    Alidade's Purification
    Dioscuri Gambit
    Archer's Distillation
    Rotation Gambit II
    Architect's Distillation

    {
        {
            // build the sudoku vector
            Dioscuri Gambit
            Additive Distillation
            Tangent Purification
            Sine Purification
            Vector Exaltation

            // cross the sudoku vector with the face normal
            Division Distillation
            // add the coordinate offset, and break the block
            Additive Distillation
            Break Block
        }
        // inner loop
        Rotation Gambit
        Thoth's Gambit
    }
    // build the iteration list
    Numerical Reflection: -1
    Numerical Reflection: 0
    Numerical Reflection: 1
    Numerical Reflection: 3
    Flock's Gambit
    // copy it for the inner loop
    Undertaker's Gambit
    // start the outer loop
    Thoth's Gambit
}
I am confident that this is the fewest patterns possible to produce a hammer with base hexcasting. The compact nested Thoth plus the Sudoku method makes it quite a challenge to get anything even close.
Last edited by Snazz on Sat Sep 30, 2023 11:40 pm, edited 1 time in total.
User avatar
petrakat
Posts: 10
Joined: Fri Dec 02, 2022 12:02 am

Re: The Easiest Hammer

Post by petrakat »

Holy shit
The creator of petrak@'s mods. Partially a test account, partially for me to chat in a non-admin capacity... probably just a test account.
User avatar
gamma_02
Posts: 3
Joined: Thu Dec 29, 2022 12:13 am

Re: The Easiest Hammer

Post by gamma_02 »

This is very cool! It reminds me a lot of another 3x3 digger I made, I might take another crack at it sometime.

I agree with petra's comment lol
User avatar
gamma_02
Posts: 3
Joined: Thu Dec 29, 2022 12:13 am

Re: The Easiest Hammer: My attempt

Post by gamma_02 »

Well, I took another crack at it!
This is my version of the 3x3 hammer, though I'm pretty sure I'm not exactly doing the challenge as It's doing a full 3x3x3 volume, but still, I got it down to 31 total patterns, the same as Snazz's. I'm rather proud of this, but it's probably misplaced.

This is what I started with, my 3x3 hammer from a while ago, about 40 patterns already.
qaqaaqaqwawqaawddqqqqqqqqqeqqqqqaaeddwaawqaqqqqqeeeNumerical Reflection: 1adeeedNumerical Reflection: 0edqdeNumerical Reflection: -1edqdedadadaawddBookkeeper's Gambit: Drop 1eeeNumerical Reflection: 1adeeedNumerical Reflection: 0edqdeNumerical Reflection: -1edqdedadadaawddBookkeeper's Gambit: Drop 1eeeNumerical Reflection: 1adeeedNumerical Reflection: 0edqdeNumerical Reflection: -1edqdedadad
From there, the first optimization is turning the offset list assembly from 6 patterns to 5, which saves a total of 3:
Numerical Reflection: 1adeeedNumerical Reflection: 0edqdeNumerical Reflection: -1edqdeInto Numerical Reflection: 1Numerical Reflection: 0Numerical Reflection: -1Numerical Reflection: 3ewdqdwe

The next important optimization is taking that list assembly and only using it once, referencing it with Fisherman's Gambit II and a knowledge of how tall the stack is at any given moment, which saves the most of all of these, 4 patterns total.

Code: Select all

Mind's Reflection
Compass' Purification
Mind's Reflection
Alidade's Purification
Archer's Distillation
{
    {
        {
            Vector Exaltation
            Prospector's Gambit
            Additive Distillation
            Break Block
        }
        Numerical Reflection: 1
        Numerical Reflection: 0
        Numerical Reflection: -1
        Numerical Reflection: 3
        Flock's Gambit
        Thoth's Gambit
        Jester's Gambit
        Bookkeeper's Gambit: v
    }
    Numerical Reflection: 1
    Numerical Reflection: 0
    Numerical Reflection: -1
    Numerical Reflection: 3
    Flock's Gambit
    Thoth's Gambit
    Jester's Gambit
    Bookkeeper's Gambit: v
}
Numerical Reflection: 1
Numerical Reflection: 0
Numerical Reflection: -1
Numerical Reflection: 3
Flock's Gambit
Thoth's Gambit
with 37 patterns.
That turns into:

Code: Select all

Numerical Reflection: 1
Numerical Reflection: 0
Numerical Reflection: -1
Numerical Reflection: 3
Flock's Gambit
Mind's Reflection
Compass' Purification
Mind's Reflection
Alidade's Purification
Archer's Distillation
{
    {
        {
            Vector Exaltation
            Prospector's Gambit
            Additive Distillation
            Break Block
        }
        //changes:
        Numerical Reflection: 4
        Fisherman's Gambit II
        Thoth's Gambit
        Jester's Gambit
        Bookkeeper's Gambit: v
    }
    //changes
    Numerical Reflection: 3
    Fisherman's Gambit II
    Thoth's Gambit
    Jester's Gambit
    Bookkeeper's Gambit: v
}
//changes
Numerical Reflection: 2
Fisherman's Gambit II
Thoth's Gambit
with 33 patterns.

The final optimization was eliminating the Jester's gambit and using a single Bookkeeper's Purification. This removes two patterns, making the final total 31:

Numerical Reflection: 1Numerical Reflection: 0Numerical Reflection: -1Numerical Reflection: 3ewdqdweqaqaaqaqwawqaawddqqqqqqqqqeqqqqqaaeddwaawqaqqqqqeeeNumerical Reflection: 4aadadadadBookkeeper's Gambit: Keep 1, Drop 1eeeNumerical Reflection: 3aadadadadBookkeeper's Gambit: Keep 1, Drop 1eeeNumerical Reflection: 2aadadadad
There is an explanation in the comments.

Code: Select all

Numerical Reflection: 1
Numerical Reflection: 0
Numerical Reflection: -1
Numerical Reflection: 3
Flock's Gambit
//build the offset list
Mind's Reflection
Compass' Purification
Mind's Reflection
Alidade's Purification
Archer's Distillation
//get the block the player is looking at
{
    {
        {
            //make the offsets on the stack a vector
            Vector Exaltation
            //fetch the block
            Prospector's Gambit
            //apply offsets
            Additive Distillation
            //break block at the offset vector
            Break Block
        }
        //stack is 5 tall, the list is at the bottom.
        Numerical Reflection: 4
        //grab list
        Fisherman's Gambit II
        //execute block break iteration layer #1
        Thoth's Gambit
        //clean up list
        Bookkeeper's Gambit: -v
    }
    //stack is 4 tall, list still at bottom
    Numerical Reflection: 3
    //fetch list
    Fisherman's Gambit II
    //execute iteration layer #2
    Thoth's Gambit
    Bookkeeper's Gambit: -v
}
//stack 3 tall, list at bottom
Numerical Reflection: 2
//grab the list
Fisherman's Gambit II
//execute iteration layer #3
Thoth's Gambit
This was super fun to make, and to make it offset on the block normal you just have to modify the offset list, adding 8 patterns. Here's that code:

Code: Select all

Numerical Reflection: 1
Numerical Reflection: 0
Numerical Reflection: -1
//normal offset code
Vector Exaltation
Mind's Reflection
Compass' Purification
Mind's Reflection
Alidade's Purification
Architect's Distillation
Additive Distillation
Vector Disintegration
//end normal offset code
Numerical Reflection: 3
Flock's Gambit
//build the offset list
Mind's Reflection
Compass' Purification
Mind's Reflection
Alidade's Purification
Archer's Distillation
//get the block the player is looking at
{
    {
        {
            //make the offsets on the stack a vector
            Vector Exaltation
            //fetch the block
            Prospector's Gambit
            //apply offsets
            Additive Distillation
            //break block at the offset vector
            Break Block
        }
        //stack is 5 tall, the list is at the bottom.
        Numerical Reflection: 4
        //grab list
        Fisherman's Gambit II
        //execute block break iteration layer #1
        Thoth's Gambit
        //clean up list
        Bookkeeper's Gambit: -v
    }
    //stack is 4 tall, list still at bottom
    Numerical Reflection: 3
    //fetch list
    Fisherman's Gambit II
    //execute iteration layer #2
    Thoth's Gambit
    Bookkeeper's Gambit: -v
}
//stack 3 tall, list at bottom
Numerical Reflection: 2
//grab the list
Fisherman's Gambit II
//execute iteration layer #3
Thoth's Gambit
User avatar
Snazz
Posts: 8
Joined: Wed Dec 14, 2022 11:34 pm

Re: The Easiest Hammer

Post by Snazz »

A 3x3x3 volume hammer is a separate, but also interesting undertaking.

But if we want to compare spells fairly, we should stick to the same guidelines. The patterns that I am counting are all the patterns required to construct a spell, not just the patterns required to produce the spell effect. This distinction is important firstly because you are gonna want to use the spell more than once, and secondly because some spell constructors may embed non-pattern iotas. The count of patterns required for the spell effect in these spells is ill-defined.

I will also note that my 3x3x3 hammer spells are always offset one block behind the block you are looking at because I feel it has greater utility and you will more often get your full 27 blocks worth.


My 3rd attempt at the normal hammer is actually really close to being a cube hammer as well, It's only off by two patterns. Just by replacing the division distl. and additive distil. in the most nested part with an additive distl. and a subtractive distl. respectively, it turns into a cube hammer spell:

Hammer Cube (33 patterns)
qqqqaqaaqaqwaaadadaawwqaawddddqddweddwaaqqqqqqqqqeqqqqqwaawwddwqaqqqqqeeeNumerical Reflection: 4ddaddadadeeeaaeaadadadeeeNumerical Reflection: -1Numerical Reflection: 0Numerical Reflection: 1Numerical Reflection: 3ewdqdweddqaaddqaadadadeee

Code: Select all

// hammer cube
{
    Mind's Reflection
    Compass' Purification
    Mind's Reflection
    Alidade's Purification

    Dioscuri Gambit
    Archer's Distillation
    Rotation Gambit II
    Architect's Distillation
    
    {
        {
            {
                Vector Exaltation
                Additive Distillation
                Subtractive Distillation
                Break Block
            }
            Numerical Reflection: 4
            Fisherman's Gambit
            Thoth's Gambit
        }
        Rotation Gambit
        Thoth's Gambit
    }

    Numerical Reflection: -1
    Numerical Reflection: 0
    Numerical Reflection: 1

    Numerical Reflection: 3
    Flock's Gambit
    Undertaker's Gambit
    Undertaker's Gambit

    Thoth's Gambit
}

For mining specifically, I have a different 3x3x3 hammer that I really like, Instead of using break block on all 27 blocks, I just break the middle block, then conjure an explosion in the center, which breaks the other blocks. It is surprisingly consistent at breaking an exact 3x3x3 cube of stone or deepslate. The drawback, of course is that you lose the item dropped from the center block in the explosion. But in my opinion, the spell totally makes up for this because it costs less than half the media to cast (13.27 dust instead of 30.43)

Blast Hammer (15 patterns)
qqqqaqaaqaqwaaadadaawwqaawddddqddweddwaawddwaadaaqaqqqqqNumerical Reflection: 4aawaawaaeee

Code: Select all

{
    Mind's Reflection
    Compass' Purification
    Mind's Reflection
    Alidade's Purification
    
    Dioscuri Gambit
    Archer's Distillation
    Rotation Gambit II
    Architect's Distillation
    Subtractive Distillation
    
    Gemini Decomposition
    Break Block
    Numerical Reflection: 4
    Explosion
}