MIENCR4F7 IN TI-BASIC W0000T!!!11Just some ideas but you should make the mines/ bombs into creepers XD
J/k, I wish :P It's actually Minesweeper, but with flood-fill and everything! :D
(http://img.removedfromgame.com/imgs/mine.gif)
That's full speed on a TI-84 Plus, so you can tell that the flood-filling is a bit slow. I'm still trying to improve it, but the code's about as optimized as I can get it right now O.O
Multiple levels coming soon. It's actually fully implemented; all I need to do is add a menu.
Your description implies you aren't randomly generating new boards. Why not?I am; I'm just trying to decide what board sizes to use for the other difficulty levels.
The stuff between lines 11 and 15 are what's really slowing the thing down. It goes through the eight surrounding pixels and individually tests them to see if they're valid or not, and if so they get appended to the queue (L2). Because it has to do this for every element on the queue that doesn't have any mines surrounding it, blank squares take a while to show up.{~1.01,~.01,.99,~1,1,~.99,.01,1.01->L3
DelVar I{A+sub(B->L2
Repeat I=dim(L2
I+1->I
L2(Ans
F+pxl-Test(600fPart(Ans)+2,6iPart(Ans)+2->F
sum(seq(max(L1=L2(I)+L3(J)),J,1,8
If Ans
Then
" "+sub("12345678",Ans,1)+"
Else
For(J,1,8)
L2(I)+L3(J
If Ans>=0 and iPart(Ans)<C and |E2fPart(Ans)<D and prod(L2-Ans
Ans->L2(1+dim(L2
End
"
End
Text(600fPart(L2(I))+1,6iPart(L2(I))+2,Ans
End
I never figured out how the heck to play minesweeper.Then learn cause fun to play
Yeah, I know why it's slow, and it's because my algorithm is pretty bad :/ Here's my flood-fill code:Quote from: TI-BASICThe stuff between lines 11 and 15 are what's really slowing the thing down. It goes through the eight surrounding pixels and individually tests them to see if they're valid or not, and if so they get appended to the queue (L2). Because it has to do this for every element on the queue that doesn't have any mines surrounding it, blank squares take a while to show up.{~1.01,~.01,.99,~1,1,~.99,.01,1.01->L3
DelVar I{A+sub(B->L2
Repeat I=dim(L2
I+1->I
L2(Ans
F+pxl-Test(600fPart(Ans)+2,6iPart(Ans)+2->F
sum(seq(max(L1=L2(I)+L3(J)),J,1,8
If Ans
Then
" "+sub("12345678",Ans,1)+"
Else
For(J,1,8)
L2(I)+L3(J
If Ans>=0 and iPart(Ans)<C and |E2fPart(Ans)<D and prod(L2-Ans
Ans->L2(1+dim(L2
End
"
End
Text(600fPart(L2(I))+1,6iPart(L2(I))+2,Ans
End
I tried to implement the third algorithm on the Wikipedia article (http://en.wikipedia.org/wiki/Flood_fill), but since there are eight directions in Minesweeper and three classes of elements (blank, numbered, mine), it turned out to be even slower than the one I have.
:A+sub(B
:sum(seq(max(L₁=Ans+L₃(I)),I,1,8
:If Ans
:Then
:Text(6B+1,6A+2," "+sub("12345678",Ans,1)+"
:Else
:Text(6B+1,6A+2,"
:DelVar I{A+sub(B➔L₂
:Repeat I=dim(L₂
:I+1➔I
:For(J,1,8
:L₂(I)+L₃(J
:If Ans≥0 and iPart(Ans)<C and ᴇ2fPart(Ans)<D
:Then
:If pxl-Test(600fPart(Ans)+2,6iPart(Ans)+2
:Then
:sum(seq(max(L₁=L₂(I)+L₃(J)+L₃(K)),K,1,8
:If Ans
:Then
:" "+sub("12345678",Ans,1)+"
:Else
:L₂(I)+L₃(J➔L₂(1+dim(L₂
:"
:End
:Text(600fPart(L₂(I)+L₃(J))+1,6iPart(L₂(I)+L₃(J))+2,Ans
:End
:End
:End
:End
:End
appears faster, although it could probably be optimized some more.