Author Topic: Mine  (Read 12001 times)

0 Members and 2 Guests are viewing this topic.

Offline Stefan Bauwens

  • Creator of Myst 89 - סטיבן
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1799
  • Rating: +162/-24
  • 68k programmer
    • View Profile
    • Portfolio
Re: Mine
« Reply #15 on: November 21, 2011, 11:43:26 am »
Looks nice, Deep. :)


Very proud Ticalc.org POTY winner (2011 68k) with Myst 89!
Very proud TI-Planet.org DBZ winner(2013)

Interview with me

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Mine
« Reply #16 on: November 21, 2011, 01:16:52 pm »
I never figured out how the heck to play minesweeper.
Then learn cause fun to play
I'm not a nerd but I pretend:

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Mine
« Reply #17 on: November 21, 2011, 04:48:46 pm »
really good! one of the best versions I've seen yet!
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Mine
« Reply #18 on: November 22, 2011, 03:23:22 am »
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-BASIC
{~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
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.

I tried to implement the third algorithm on the Wikipedia article, 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.

Replacing the above code with
Code: [Select]
: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.

Edit to show how good I am at minesweeper ;)
J/k, actually to see the speed difference (I hope).
« Last Edit: November 22, 2011, 03:43:11 am by jacobly »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Mine
« Reply #19 on: November 22, 2011, 09:42:20 am »
I was *just* about to post that I made the engine about 50% faster by using a pxl-Text XD But yep, there really is a noticeable difference. Thanks anyway for taking the time to help :)

I've also added the menu, timing, and all that other stuff I was going to add. I'll post an update later today.
« Last Edit: November 22, 2011, 09:42:26 am by Deep Thought »




Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Mine
« Reply #20 on: November 24, 2011, 03:05:04 pm »
Major update! This version has everything I mentioned above, plus slight GUI changes (flags are now white on black to distinguish them from numbered squares), plus the my most beautiful pure-BASIC title screen yet:





Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Mine
« Reply #21 on: November 28, 2011, 12:22:36 am »
Well, I've decided. This will be my zContest entry for the TI-BASIC section unless (until) I finish Madness.