vang1ong7ang / ExponentialIdle-ArrowPuzzle

the optimal solution for arrow puzzle of game exponential idle
9 stars 1 forks source link

In what order should you input the hexagons on hard or expert? #1

Open EricCreusen opened 11 months ago

EricCreusen commented 11 months ago

It's not clear in what order the entries in matrix B should be input for the hard or expert puzzles. I tried a few different ways, but kept getting incorrect solutions so I must be doing it wrong.

vang1ong7ang commented 11 months ago

I'M GOING TO SHOW YOU AN EXAMPLE TO EXPLAIN THAT.

======== EASY EXAMPLE ========

WHEN YOU OPEN THE GAME, IT SHOWS:

↑ ↓ ←
↓ ← →
← → ↑

LET'S FOLLOW THE SOLUTION STEPS:

let n denote the number of arrows

so n = 9

and m denote number of possible orientations of arrows (4 for easy and medium; 2 for hard; 6 for expert)

there are 4 possible orientations in easy mode: up/down/left/right so m = 4

give each arrow a number before the following steps

↑(1) ↓(2) ←(3)
↓(4) ←(5) →(6)
←(7) →(8) ↑(9)
  1. define a column vector X (size: n×1) each element X_i represents the number of taps needed for i-th arrow

    since n = 9, X is a column with length = 9 X = [unknown unknown unknown unknown unknown unknown unknown unknown unknown]^T

    the matrix X is actually what we want to solve and we will construct a equation to solve the matrix X

  2. define a square matrix A (size: n×n) element A_ij is 1 if i-th arrow is a neighbour of j-th arrow, otherwise, A_ij is 0

    let's construct a zero sqaure matrix first (size: n×n)

    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]

    have a look at the game board

    we gave a number to each arrow

    (1) (2) (3)
    (4) (5) (6)
    (7) (8) (9)

    1 is a neighbour of 1, 2, 4 and 5 fill in the coresponding cell with 1

    [ 1 0 0 0 0 0 0 0 0 ]
    [ 1 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 1 0 0 0 0 0 0 0 0 ]
    [ 1 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]

    2 is a neighbour of 1, 2, 3, 4, 5 and 6 fill in the coresponding cell with 1

    [ 1 1 0 0 0 0 0 0 0 ]
    [ 1 1 0 0 0 0 0 0 0 ]
    [ 0 1 0 0 0 0 0 0 0 ]
    [ 1 1 0 0 0 0 0 0 0 ]
    [ 1 1 0 0 0 0 0 0 0 ]
    [ 0 1 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]
    [ 0 0 0 0 0 0 0 0 0 ]

    ...

    finally we have the matrix A

    A =

    [1 1 0 1 1 0 0 0 0]
    [1 1 1 1 1 1 0 0 0]
    [0 1 1 0 1 1 0 0 0]
    [1 1 0 1 1 0 1 1 0]
    [1 1 1 1 1 1 1 1 1]
    [0 1 1 0 1 1 0 1 1]
    [0 0 0 1 1 0 1 1 0]
    [0 0 0 1 1 1 1 1 1]
    [0 0 0 0 1 1 0 1 1]
  3. define a column vector B (size: n×1) element B_i represents the initial orientation of i-th arrow 0 is up; 1 is right; 2 is down; 3 is left;

    have a look at the game board again:

    ↑(1) ↓(2) ←(3)
    ↓(4) ←(5) →(6)
    ←(7) →(8) ↑(9)

    obviously the column vector B is [ 0 2 3 2 3 1 3 1 0 ]^T

  4. then the following equation should be satisfied:

    A X + B = 0 (mod m)

  5. solve for X

    X = (A^-1)(-B) (mod m)

    then X = [3 2 1 2 1 1 1 1 1]^T

    NOW IT'S TIME TO VERIFY THE ANSWER:

    X = [3 2 1 2 1 1 1 1 1]^T

    IT MEANS YOU NEED TO:

    ↑(1) ↓(2) ←(3)
    ↓(4) ←(5) →(6)
    ←(7) →(8) ↑(9)

TYPE THE 1-TH ARROW 3 TIMES ←(1) →(2) ←(3) →(4) ↓(5) →(6) ←(7) →(8) ↑(9)

TYPE THE 2-TH ARROW 2 TIMES →(1) ←(2) →(3) ←(4) ↑(5) ←(6) ←(7) →(8) ↑(9)

TYPE THE 3-TH ARROW 1 TIMES →(1) ↑(2) ↓(3) ←(4) →(5) ↑(6) ←(7) →(8) ↑(9)

TYPE THE 4-TH ARROW 2 TIMES ←(1) ↓(2) ↓(3) →(4) ←(5) ↑(6) →(7) ←(8) ↑(9)

TYPE THE 5-TH ARROW 1 TIMES ↑(1) ←(2) ←(3) ↓(4) ↑(5) →(6) ↓(7) ↑(8) →(9)

TYPE THE 6-TH ARROW 1 TIMES ↑(1) ↑(2) ↑(3) ↓(4) →(5) ↓(6) ↓(7) →(8) ↓(9)

TYPE THE 7-TH ARROW 1 TIMES ↑(1) ↑(2) ↑(3) ←(4) ↓(5) ↓(6) ←(7) ↓(8) ↓(9)

TYPE THE 8-TH ARROW 1 TIMES ↑(1) ↑(2) ↑(3) ↑(4) ←(5) ←(6) ↑(7) ←(8) ←(9)

TYPE THE 9-TH ARROW 1 TIMES ↑(1) ↑(2) ↑(3) ↑(4) ↑(5) ↑(6) ↑(7) ↑(8) ↑(9)

!NICE! ======== EASY EXAMPLE END ========

FEEL FREE TO DISCUSS WITH ME IF YOU STILL HAVE QUESTIONS

EricCreusen commented 11 months ago

I solved the easy problem by forming matrix B, and then just calling X=easy(B);

I want to similarly use X=hard(B) to solve the hard problem, but to do that I need to know in what order the arrows should be input into vector B.

vang1ong7ang commented 11 months ago

In fact, any order is ok. (you can go from left to right top to bottom, or a spiral that unfolds counterclockwise, ... ...)

just keep the same order in all the matrixes(vectors) X A B and:

element A_ij is 1 if i = j or i-th arrow is a neighbour of j-th arrow, otherwise, A_ij is 0

vang1ong7ang commented 11 months ago

and if you want to solve to hard and expert problems:

Patch for Hard and Expert

follow the steps above, you will find that A is not invertible.

actually the rank of matrix A is 33 and n is 37, which means that A is not a full rank matrix.

solution: just remove 4 arrows of any edge of the hexagon from A, X and B, then A will be invertible and we never need to touch the 4 ignored arrows.

verify: use the unignored matrix A and B and X to verify the equation. actually the puzzle has a solution if and only if our solution is verified.

EricCreusen commented 10 months ago

I was under the impression that the hard() and expert() function create the Matrix A for you. Is that not the case?

vang1ong7ang commented 10 months ago

ahuahuahua you mean the python example code hard.py.

essentially you can calculate the solution easily by following the readme.md file. (this way you don't need to understand my coordinate system).

if you want to use the hard.py, the order is for x in range(1-N, N) for y in range(1-N, N) for z in range(1-N, N) if x+y+z == 0 where N is 4, (the x-axis, y-axis and z-axis are the lines connecting the midpoints of the three opposite sides of the hexagon. they form an angle of 120 degrees with each other.):

[(-3, 0, 3), (-3, 1, 2), (-3, 2, 1), (-3, 3, 0), (-2, -1, 3), (-2, 0, 2), (-2, 1, 1), (-2, 2, 0), (-2, 3, -1), (-1, -2, 3), (-1, -1, 2), (-1, 0, 1), (-1, 1, 0), (-1, 2, -1), (-1, 3, -2), (0, -3, 3), (0, -2, 2), (0, -1, 1), (0, 0, 0), (0, 1, -1), (0, 2, -2), (0, 3, -3), (1, -3, 2), (1, -2, 1), (1, -1, 0), (1, 0, -1), (1, 1, -2), (1, 2, -3), (2, -3, 1), (2, -2, 0), (2, -1, -1), (2, 0, -2), (2, 1, -3), (3, -3, 0), (3, -2, -1), (3, -1, -2), (3, 0, -3)]

an example of my three-dimensional coordinate system on the plane:

image