In all of my previous games, the maps I have all have predetermined spots. While that is interesting and certainly important just because it allows a coherent game that focuses more on story, I have wanted to make a maze generation game for a long time. I plan on making a game on the home screen where its kind of like a luigis mansion game. I want to generate a maze within a matrix and use that matrix to arrange the different rooms that way the mansion is completely randomly generated so that way even I dont know the answer. I know that its possible to randomly generate a maze on the calculator but I don´t know how. Could someone please send me some source code for generating a maze and explain the logic behind it? Thanks!

Here is a bit of code I made about a year ago for the TI-84+CSE using the graphscreen. Note: I haven't touched this code in awhile, so there is probably optimization to be done.

```
:Lbl 0:ClrDraw
:0→Xmin:1→ΔX
:0→Ymin:1→ΔY
:AxesOff
:For(A,0,266,2
:Vertical A
:End
:Pt-Off(264,2
:Pt-Off(0,162
:2→A:2→B:-3→E:2→F:1→I \\Initialization of the graph screen
:ClrList L₁
:Repeat K=45
:getKey→K
:If I=1
:randInt(1,4,4→L₁ \\Random direction for the "head" of the maze to go; also ensures it does not test the same direction twice
:L₁(I→D
:Pt-Off(B,164-A
:If D=1 and A≠2:Then
:pxl-Test(A-5,B→P \\Determine if the "head" can move in that direction (if there isn't a path already there)
:A-5P→A
:Pt-Off(B,164-A-2P
:End
:If D=2 and A≠162:Then
:pxl-Test(A+5,B→P \\Repeat for the remaining directions
:Pt-Off(B,164-A+2P
:End
:If D=3 and B≠2:Then
:pxl-Test(A,B-5→P
:B-5P→B
:Pt-Off(B+2P,164-A
:End
:If D=4 and B≠262:Then
:pxl-Test(A,B+5→P
:B+5P→B
:Pt-Off(B-2P,164-A
:End
:1+Inot(P→I
:Pt-Off(B,164-A
:If I=5:Then \\Tests to see if the "head" has become trapped by paths on all sides
:Repeat Q>0 and not(P
:E+5→E:F+5(E=167→F \\When the "head" is trapped, it will be moved to the next available entry spot
:If Ans=267:Goto 1
:E(E≠167)+2(E=167→E
:pxl-Test(E,F→P \\The "head" checks every column until it finds a valid starting point for the next path
:pxl-Test(E-5(E≠2),F)+pxl-Test(E+5(E≠162),F)+pxl-Test(E,F-5(F≠2))+pxl-Test(E,F+5(F≠262→Q
:End
:E→A:F→B:1→I
:End:End
:Lbl 1 \\This is just code to let the player solve the maze
```

This code can fill the screen with a maze in about 5-10 minutes. I know that you need something involving matrices, but this is the best I have and I think the concepts are still valid. Happy coding!

The solution to a complex problem is often a simple answer.

Ah thank you, yes I think the concepts within your code are valid. I figured that you used Prim's Algorithm, right? So I did a bit of research and taught myself how the algorithm works. (for those who dont know what it is, it's basically finding the minimal spanning tree on a weighted graph) I'm having a little trouble adapting it to ti-basic but I'll probably get there within a few days. Anyway when I'm done with it, should I post it for the community? (I'm new to the forum so idk) Anyway, thank you for answering my post and sorry for the late response, you're pretty much the only one answering my posts and I appreciate it. Thanks!

To answer the first question: No, I did not intentionally use Prim's Algorithm (though scrolling through the Wikipedia article has lead me to believe my code is perhaps a simple variation of either Prim's or Reverse backtracking). I considered using a graph theory algorithm like Prim's to make the maze, but most algorithms are, in my opinion, overly complicated for the task at hand and difficult to implement in TI-Basic.

To answer the second question: You should absolutely post it to the forums. The community can always benefit from a new program or routine. If you have a full-fledged program/game, you can put it in the Program Archives. If it's more of just a single concept or algorithm, you can post it here for others to see and build upon.

The solution to a complex problem is often a simple answer.