about summary refs log tree commit diff stats
path: root/data/maps/the_sturdy/rooms
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-09-11 22:49:16 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-09-11 22:49:16 -0400
commita94ed7a5cf0ffc86b50e8bd99ace3f671db22dec (patch)
tree995ce82503bf3662cb20c24851a007961919efbc /data/maps/the_sturdy/rooms
parent6cdf94124bcfda082e1cacb64a534ef881af35d2 (diff)
downloadlingo2-archipelago-a94ed7a5cf0ffc86b50e8bd99ace3f671db22dec.tar.gz
lingo2-archipelago-a94ed7a5cf0ffc86b50e8bd99ace3f671db22dec.tar.bz2
lingo2-archipelago-a94ed7a5cf0ffc86b50e8bd99ace3f671db22dec.zip
[Data] Renamed Sticks and Stones location
Diffstat (limited to 'data/maps/the_sturdy/rooms')
0 files changed, 0 insertions, 0 deletions
il.com> 2019-11-18 09:16:16 -0800 Cleanup & progress on tutorial' href='/witness-tutorializer/commit/Source/Randomizer2.cpp?h=tutorial-v0.3.0&id=bff40e55c9c55fbc8439bb225d1937b2d805e629'>bff40e5 ^
1b833a8 ^
bff40e5 ^
1b833a8 ^
bff40e5 ^


1b833a8 ^
98db209 ^
bff40e5 ^


98db209 ^
98db209 ^


bff40e5 ^



98db209 ^
98db209 ^
bff40e5 ^

98db209 ^

1b833a8 ^
























bff40e5 ^



98db209 ^
bff40e5 ^
98db209 ^
98db209 ^
1b833a8 ^
fc8649b ^
bff40e5 ^
fc8649b ^

















bff40e5 ^
fc8649b ^





0baa521 ^
bff40e5 ^


0baa521 ^
0baa521 ^
bff40e5 ^
fc8649b ^

0baa521 ^
fc8649b ^








0baa521 ^
fc8649b ^

0baa521 ^
bff40e5 ^
fc8649b ^


bff40e5 ^
fc8649b ^




bff40e5 ^
fc8649b ^

0baa521 ^
bff40e5 ^




0baa521 ^
fc8649b ^
bff40e5 ^
fc8649b ^

0baa521 ^
fc8649b ^








0baa521 ^
fc8649b ^


fd2fa22 ^

bff40e5 ^
fc8649b ^

0baa521 ^
bff40e5 ^
0baa521 ^

bff40e5 ^
fc8649b ^

0baa521 ^
fc8649b ^













1b833a8 ^
fc8649b ^


bff40e5 ^
fc8649b ^

0baa521 ^
bff40e5 ^
fc8649b ^




bff40e5 ^
fc8649b ^


bff40e5 ^



0baa521 ^
0baa521 ^
1b833a8 ^
bff40e5 ^





0baa521 ^

1b833a8 ^
0baa521 ^

1b833a8 ^

0baa521 ^





1b833a8 ^

0baa521 ^
fd2fa22 ^
0baa521 ^


fd2fa22 ^
1b833a8 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
                   
                        
                            


                   
 

                  
 
                                
 
                                                                                                                            
 


                               
 
 


                                       
                        


                                         



                                                          
     
 

                 

                        
























                                                                                              



                                                          
 
                                          
     
 
 
                                   
                 

















                                           
                                                                     





                                                                                
         


                                                
     
 
                 

                        
 








                                           
 

                                            
 
                                                                     


                                                       
                                             




                                            
                                       

                                                       
         




                                                          
     
    
                       

                        
 








                                           
 


                                            

                                                                              
                                                                     

                                                        
         
                                              

     
                 

                        
 













                                           
 


                                         
                                                                     

                                                       
         
                                             




                                         
                                       


                                                       



                                                          
     
 
 





                                                  

                                                    
                                             

                                            

                  





                                            

     
                               
                                                                            


                                                                
                                                                
 
#include "Memory.h"
#include "Randomizer2.h"
#include "Randomizer2Core.h"
#include "Puzzle.h"
#include "Random.h"
#include "Solver.h"

#include <cassert>
#include <string>

#pragma warning (disable: 26451)

Randomizer2::Randomizer2(const std::shared_ptr<Memory>& memory) : _memory(memory), _serializer(PuzzleSerializer(_memory)) {}

void Randomizer2::Randomize() {
    RandomizeTutorial();
    RandomizeKeep();
}

void Randomizer2::RandomizeTutorial() {
    { // Far center
        Puzzle p;
        p.NewGrid(4, 4);
        p.grid[0][8].start = true;
        p.grid[8][0].end = Cell::Dir::UP;

        for (Pos pos : Randomizer2Core::CutEdges(p, 14)) {
            p.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        _serializer.WritePuzzle(p, 0x293);
    }

    {
        Puzzle p;
        p.NewGrid(7, 7);

        switch (Random::RandInt(1, 4)) {
            case 1:
                p.grid[Random::RandInt(0, p.width-1)][0].end = Cell::Dir::UP;
                break;
            case 2:
                p.grid[Random::RandInt(0, p.width-1)][p.height-1].end = Cell::Dir::DOWN;
                break;
            case 3:
                p.grid[0][Random::RandInt(0, p.height-1)].end = Cell::Dir::LEFT;
                break;
            case 4:
                p.grid[p.width-1][Random::RandInt(0, p.height-1)].end = Cell::Dir::RIGHT;
                break;
        }
        switch (Random::RandInt(1, 3)) {
            case 1: // Horiz (6) [5/7][4/6/8]
                p.grid[Random::RandInt(0, 1)*2 + 5][Random::RandInt(0, 2)*2 + 4].start = true;
                break;
            case 2: // Verti (6) [4/6/8][5/7]
                p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 1)*2 + 5].start = true;
                break;
            case 3: // Inter (9) [4/6/8][4/6/8]
                p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 2)*2 + 4].start = true;
                break;
        }
    
        for (Pos pos : Randomizer2Core::CutEdges(p, 35)) {
            p.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }

        _serializer.WritePuzzle(p, 0x295);
    }
}

void Randomizer2::RandomizeKeep() {
    { // Hedges 1
        Puzzle p;
        p.NewGrid(4, 4);

        p.grid[2][1].gap = Cell::Gap::FULL;
        p.grid[4][1].gap = Cell::Gap::FULL;
        p.grid[6][1].gap = Cell::Gap::FULL;
        p.grid[3][2].gap = Cell::Gap::FULL;
        p.grid[5][2].gap = Cell::Gap::FULL;
        p.grid[8][3].gap = Cell::Gap::FULL;
        p.grid[2][5].gap = Cell::Gap::FULL;
        p.grid[6][5].gap = Cell::Gap::FULL;
        p.grid[7][6].gap = Cell::Gap::FULL;
        p.grid[2][7].gap = Cell::Gap::FULL;
        p.grid[4][7].gap = Cell::Gap::FULL;

        p.grid[4][8].start = true;
        p.grid[6][0].end = Cell::Dir::UP;

        std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 5);
        Puzzle copy = p;
        std::vector<int> gates = {0x00344, 0x00488,  0x00489, 0x00495, 0x00496};
        for (int i=0; i<gates.size(); i++) {
            Pos pos = cutEdges[i];
            copy.grid[pos.x][pos.y].gap = Cell::Gap::BREAK;
            SetGate(gates[i], pos.x, pos.y);
        }
        auto solution = GetUniqueSolution(copy);
        p.sequence = solution.sequence;
        _serializer.WritePuzzle(p, 0x139);
    }

    { // Hedges 2
        Puzzle p;
        p.NewGrid(4, 4);

        p.grid[2][1].gap = Cell::Gap::FULL;
        p.grid[1][2].gap = Cell::Gap::FULL;
        p.grid[5][2].gap = Cell::Gap::FULL;
        p.grid[7][4].gap = Cell::Gap::FULL;
        p.grid[4][5].gap = Cell::Gap::FULL;
        p.grid[6][5].gap = Cell::Gap::FULL;
        p.grid[1][6].gap = Cell::Gap::FULL;
        p.grid[2][7].gap = Cell::Gap::FULL;
        p.grid[5][8].gap = Cell::Gap::FULL;

        p.grid[0][8].start = true;
        p.grid[8][0].end = Cell::Dir::RIGHT;

        std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 7);
        for (Pos pos : cutEdges) {
            p.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        auto solution = GetUniqueSolution(p);

        Puzzle q;
        q.NewGrid(4, 4);
        q.grid[0][8].start = true;
        q.grid[8][0].end = Cell::Dir::RIGHT;
        q.sequence = solution.sequence;
        for (Pos pos : cutEdges) {
            q.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        // Cut to 6 of 9 additional edges
        for (Pos pos : Randomizer2Core::CutEdges2(q, 6)) {
            q.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        _serializer.WritePuzzle(q, 0x19DC);
    }
    
    { // Hedges 3 [WIP]
        Puzzle p;
        p.NewGrid(4, 4);

        p.grid[2][1].gap = Cell::Gap::FULL;
        p.grid[5][2].gap = Cell::Gap::FULL;
        p.grid[7][2].gap = Cell::Gap::FULL;
        p.grid[4][3].gap = Cell::Gap::FULL;
        p.grid[1][4].gap = Cell::Gap::FULL;
        p.grid[6][5].gap = Cell::Gap::FULL;
        p.grid[1][6].gap = Cell::Gap::FULL;
        p.grid[3][6].gap = Cell::Gap::FULL;
        p.grid[6][7].gap = Cell::Gap::FULL;

        p.grid[0][8].start = true;
        p.grid[8][2].end = Cell::Dir::RIGHT;

        std::vector<int> pebbleMarkers = {0x034a9, 0x034b1, 0x034be, 0x034c4};

        std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 7);
        for (Pos pos : cutEdges) {
            p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK;
        }
        // _serializer.WritePuzzle(p, 0x19E7);
    }

    { // Hedges 4
        Puzzle p;
        p.NewGrid(4, 4);

        p.grid[3][0].gap = Cell::Gap::FULL;
        p.grid[4][1].gap = Cell::Gap::FULL;
        p.grid[8][1].gap = Cell::Gap::FULL;
        p.grid[1][2].gap = Cell::Gap::FULL;
        p.grid[4][3].gap = Cell::Gap::FULL;
        p.grid[8][3].gap = Cell::Gap::FULL;
        p.grid[1][4].gap = Cell::Gap::FULL;
        p.grid[5][4].gap = Cell::Gap::FULL;
        p.grid[2][5].gap = Cell::Gap::FULL;
        p.grid[6][5].gap = Cell::Gap::FULL;
        p.grid[3][6].gap = Cell::Gap::FULL;
        p.grid[0][7].gap = Cell::Gap::FULL;
        p.grid[8][7].gap = Cell::Gap::FULL;
        p.grid[5][8].gap = Cell::Gap::FULL;

        p.grid[0][8].start = true;
        p.grid[4][0].end = Cell::Dir::UP;

        std::vector<Pos> cutEdges = Randomizer2Core::CutEdges2(p, 2);
        for (Pos pos : cutEdges) {
            p.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        auto solution = GetUniqueSolution(p);

        Puzzle q;
        q.NewGrid(4, 4);
        q.grid[0][8].start = true;
        q.grid[4][0].end = Cell::Dir::UP;
        q.sequence = solution.sequence;
        for (Pos pos : cutEdges) {
            q.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        for (Pos pos : Randomizer2Core::CutEdges2(q, 7)) {
            q.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
        }
        _serializer.WritePuzzle(q, 0x1A0F);
    }
}

Puzzle Randomizer2::GetUniqueSolution(Puzzle& p) {
    auto solutions = Solver::Solve(p);
    assert(solutions.size() == 1);
    return solutions[0];
}

void Randomizer2::SetGate(int panel, int X, int Y) {
    float x, y, z, w;
    if (X%2 == 0 && Y%2 == 1) { // Horizontal
        x = -1.49f * X + 0.22f * Y + 66.58f;
        y = 0.275f * X +  1.6f * Y + 108.4f;
        z = -.77f;
        w = .63f;
    } else { // Vertical
        assert(X%2 == 1 && Y%2 == 0);
        x = -1.6f * X + 0.35f * Y +   66.5f;
        y = 0.25f * X +  1.6f * Y + 108.55f;
        z = -0.1f;
        w = 1.0f;
    }

    SetPos(panel, x, y, 19.2f);
    _memory->WriteEntityData<float>(panel, ORIENTATION, {0.0f, 0.0f, z, w});
}

void Randomizer2::SetPos(int panel, float x, float y, float z) {
    _memory->WriteEntityData<float>(panel, POSITION, {x, y, z});
}