Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. 68k Calculator Basic => TI-BASIC
Author Message
CDI


Advanced Member


Joined: 05 Nov 2005
Posts: 267

Posted: 30 May 2006 03:11:18 pm    Post subject:

AHH!!!! I was messing around with flood fill for MX68k (minesweeper) and if I have a 9x9 field with 1 mine it'll run out of memory! So I was wondering, if there was a easy way to give memory back while running somewhere in the range of 70 subprograms.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 30 May 2006 03:31:47 pm    Post subject:

There's a good chance if you're running out of memory you're doing something wrong.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 30 May 2006 03:44:33 pm    Post subject:

*glances at location of topic* I would venture the guess of TI-89 Basic.
Back to top
CDI


Advanced Member


Joined: 05 Nov 2005
Posts: 267

Posted: 31 May 2006 02:53:22 pm    Post subject:

Well. no. I'm not. Razz Here's what's happening (with how I do floodfill)

You select a spot to uncover, it then launches the floodfill program
The program uncovers the spot, then starts on the 9 spots around it (if it's blank)
When it does that, it calls itself, so the process starts over again

I can get up to ~70 spaces uncovered before getting a memory error
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 31 May 2006 04:31:54 pm    Post subject:

Can you post the code?
Back to top
CDI


Advanced Member


Joined: 05 Nov 2005
Posts: 267

Posted: 31 May 2006 07:55:55 pm    Post subject:

I can do better
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 31 May 2006 08:11:15 pm    Post subject:

Declaring a and b as Local is suspicious. I don't know if that's the problem, but I'm willing to bet it's a problem. They're your parameters, so they're already local.

I'd replace the expr() with RplcPic #("m"&string(int(mmap[a,b]))), 8*a-8, 8*b-8 since it gets tokenized better that way and looks better as well (might be faster).

I can't open the main program for some reason, but unless t is a global variable, it doesn't get changed.


If you still have problems with memory, you could try using a list instead of recursion.


Last edited by Guest on 19 Jan 2008 12:22:09 pm; edited 1 time in total
Back to top
CDI


Advanced Member


Joined: 05 Nov 2005
Posts: 267

Posted: 01 Jun 2006 10:27:13 am    Post subject:

k, I'll try the first thing... idk exactally how to do the list... hmm...


wow, that's fast... and it got down (on a 9x9) to 3 more to uncover before a mem error Smile


Last edited by Guest on 01 Jun 2006 10:29:43 am; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 01 Jun 2006 07:49:37 pm    Post subject:

Using a list:


Code:
{a}->alist
{b}->blist
While dim(alist)>0
alist[1]->a
blist[1]->b
mid(alist,2)->alist
mid(blist,2)->blist
/* uncover (a,b) */
If /* (a,b) was blank */ Then
For i, when(a=1,a,a-1), when(a=y,a,a+1)
For j, when(b=1,b,b-1), when(b=x,b,b+1)
If /* (i,j) not in alist and blist */ Then
/* add it */
EndIf
EndFor
EndFor
EndIf
EndWhile


It's more complicated this way, but avoids recursion, you might even be able to put this directly into your main program.


Last edited by Guest on 08 Dec 2007 07:06:52 pm; edited 1 time in total
Back to top
CDI


Advanced Member


Joined: 05 Nov 2005
Posts: 267

Posted: 02 Jun 2006 11:29:11 am    Post subject:

umm... where did xlist come from?
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 

Advertisement