- TI Basic Minesweeper!
- 07 Apr 2019 09:51:43 pm
- Last edited by Eidolon on 18 Apr 2019 05:21:07 pm; edited 1 time in total
This is a minesweeper clone that I made, and I've drastically improved the speed since my last post!
Here's the code if you're curious:
Code:
And here's a drive link to download the required files. The title program must be named "ZTITLE".
https://drive.google.com/open?id=1UQ4ko-BUW4G2LFbbtVLEYzOrZM7T-g4j
The controls are:
enter to search a space
+ to flag a space
- to check for a win
x to run the auto search function that searches zero adjacent spaces (runs once at the beginning by default)
The difficulty setting represents the chance that a mine will be placed in any given space (1/difficulty+1). For example, 5 means that 1 in 6 spaces will be a mine.
Let me know what you think, and happy sweeping!
Here's the code if you're curious:
Code:
8->Z //Title
"Minesweeper"->Str1
prgmZTITLE
Input "Difficulty, 5 is best ",F
Output(4,5,"Generating Terrain..."
{10,26->dim([A]
{10,26->dim([B]
For(A,1,10
For(B,1,26
If A=1 or A=10 or B=1 or B=26
Then
11->[A](A,B
Else
0->[A](A,B
End
If not(randInt(0,F)) and not([A](A,B //Place Mines
Then
1->[B](A,B
Else
0->[B](A,B
End
If [A](A,B)=11 //Drawing
Then
Output(A,B,"+"
Else
Output(A,B,"-"
End
End
End
2->A
2->B
Repeat K=105 //Place Starting Area
getKey->K
A+(K=34)-(K=25->A
B+(K=26)-(K=24->B
Output(A,B," "
If [A](A,B
Then
Output(A,B,"+"
Else
Output(A,B,"-"
End
End
1->[A](A,B
Output(A,B,0
For(C,A-1,A+1 //Clear Starting Area
For(D,B-1,B+1
0->[B](C,D)
End
End
Repeat K=23 //Main Loop
105->K //Auto Search
For(E,2,9
For(F,2,25
If [A](E,F)=1
Then
E->G
F->H
For(A,E+1,E-1,~1
For(B,F+1,F-1,~1
If not([A](A,B
Then
Goto A
Lbl B
If [A](A,B)=1 and (A<G or (A=G and B<H
Then
A->G
B-1->H
End
End
End
End
G->E
H->F
End
End
End
DelVar EDelVar K
Repeat K=75 or K=23 //Key Loop
getKey->K
If K
Then
A+(K=34)-(K=25->A //Movement
B+(K=26)-(K=24->B
If K=95 and not([A](A,B //Flagging
Then
10->[A](A,B
Else
If K=95 and [A](A,B)=10
0->[A](A,B
End
If K=85 //Win Check
Then
1->E
For(C,2,9
For(D,2,25
If not([A](C,D
0->E
If [A](C,D)=10 and not([B](C,D
0->E
End
End
If E
Then
DelVar E
"A winner is you!!"->Str1
6->Z
prgmZTITLE
23->K
End
End
Lbl A
If K=105 and not([A](A,B //Searching
Then
If not([B](A,B
Then
1->[A](A,B
For(C,A-1,A+1
For(D,B-1,B+1
[B](C,D)+[A](A,B->[A](A,B
End
End
Else
23->K
"BOOM!"->Str1
12->Z
prgmZTITLE
End
End
End
Output(A,B," " //Drawing
If [A](A,B
Then
If [A](A,B)<10
Then
Output(A,B,[A](A,B)-1
Else
If [A](A,B)=10
Then
Output(A,B,"F"
Else
Output(A,B,"+"
End
End
Else
Output(A,B,"-"
End
If E
Goto B
End
End
ClrHome
And here's a drive link to download the required files. The title program must be named "ZTITLE".
https://drive.google.com/open?id=1UQ4ko-BUW4G2LFbbtVLEYzOrZM7T-g4j
The controls are:
enter to search a space
+ to flag a space
- to check for a win
x to run the auto search function that searches zero adjacent spaces (runs once at the beginning by default)
The difficulty setting represents the chance that a mine will be placed in any given space (1/difficulty+1). For example, 5 means that 1 in 6 spaces will be a mine.
Let me know what you think, and happy sweeping!