slowing down my app

Just for fun I have made a sudoku generator. My program simply generates a complete sudoku with a backtracking algorithm and displays it.

I would like to display the evolution of the sudoku, seeing each square appear on screen as it is calculated. I would like to see it come to a dead end, go back, and resume. 

Currently attempts to insert text objects to display the sudoku while it’s being worked out have failed. Basically the whole thing happens way too fast and leads to odd results, sometimes having the same square printed multiple times. 

Is there some way to slow down the program so the printing to screen can keep up?

thanks.

user timers or coroutines

https://coronalabs.com/blog/2015/02/10/tutorial-using-coroutines-in-corona/

hi

I have tried to insert a simple coroutine into my app. I also tried the final code at the end of the tutorial. In both cases I get this runtime error:

File: attempt to yield across metamethod/C-call boundary

Well.  I don’t suggest trying to solve the problem w/ co-routines till you learn to use them.  So its a bad idea to insert code into your app/game till then.

As far as co-routines working.  They do and there is no question about it.  I have and do use them.

Download Me To See In Action

Some folks have had a little trouble following the article and if that is true for you, no worries.  There are other source of learning co-routines in Lua (this is not a Corona thing).

Also, you don’t have to use co-routines.  You can simply break up the work in other ways, but you’ll have to fully grok the methodology and the work you’re breaking up.  For example, my sample here breaks up a long search into small chunks to allow, dynamically changing the search and displaying results as they are found:

https://coronalabs.com/blog/2015/05/12/tutorial-responsive-real-time-searching/ 

This approach may be closer to what you need.

What I would do is build up a table of ‘moves’ and once the calculations are done, loop over the moves and either use transitions at certain intervals to run the display. Perhaps your transition could say fade in the display object, and in it’s onComplete, you do the next move.

Rob

Ah, that is a good suggestion @Rob.  Pre-calculate and accumulate, then post-display instead of trying to combine all of that in a complex way.

Nice.

thanks for the suggestion, I will try that.

The data I have to display is in a table. I’m playing around with transitions/tables and trying to get a simple table with 6 numbers to display each one, one after the other.  I tried this recursively: 

local solutionDisplay = "" myNumTable = {1,2,3,4,5,6} local function timedDisplay(i) while (i \<= 6) do local numToString = tostring(myNumTable[i]) solutionDisplay &nbsp;= &nbsp;display.newText(numToString,50\*i,100,FONT\_NAME,10) solutionDisplay:setFillColor(0,0,0) i = i + 1 transition.to( solutionDisplay, { time=1500, delay=1000, alpha=0, &nbsp;onComplete=timedDisplay(i)} ) end end timedDisplay(1)

but this just displays all 6 numbers at the same time. I’m not sure how to go about getting numbers in a table to display one after the other. Thanks.

user timers or coroutines

https://coronalabs.com/blog/2015/02/10/tutorial-using-coroutines-in-corona/

hi

I have tried to insert a simple coroutine into my app. I also tried the final code at the end of the tutorial. In both cases I get this runtime error:

File: attempt to yield across metamethod/C-call boundary

Well.  I don’t suggest trying to solve the problem w/ co-routines till you learn to use them.  So its a bad idea to insert code into your app/game till then.

As far as co-routines working.  They do and there is no question about it.  I have and do use them.

Download Me To See In Action

Some folks have had a little trouble following the article and if that is true for you, no worries.  There are other source of learning co-routines in Lua (this is not a Corona thing).

Also, you don’t have to use co-routines.  You can simply break up the work in other ways, but you’ll have to fully grok the methodology and the work you’re breaking up.  For example, my sample here breaks up a long search into small chunks to allow, dynamically changing the search and displaying results as they are found:

https://coronalabs.com/blog/2015/05/12/tutorial-responsive-real-time-searching/ 

This approach may be closer to what you need.

What I would do is build up a table of ‘moves’ and once the calculations are done, loop over the moves and either use transitions at certain intervals to run the display. Perhaps your transition could say fade in the display object, and in it’s onComplete, you do the next move.

Rob

Ah, that is a good suggestion @Rob.  Pre-calculate and accumulate, then post-display instead of trying to combine all of that in a complex way.

Nice.

thanks for the suggestion, I will try that.

The data I have to display is in a table. I’m playing around with transitions/tables and trying to get a simple table with 6 numbers to display each one, one after the other.  I tried this recursively: 

local solutionDisplay = "" myNumTable = {1,2,3,4,5,6} local function timedDisplay(i) while (i \<= 6) do local numToString = tostring(myNumTable[i]) solutionDisplay &nbsp;= &nbsp;display.newText(numToString,50\*i,100,FONT\_NAME,10) solutionDisplay:setFillColor(0,0,0) i = i + 1 transition.to( solutionDisplay, { time=1500, delay=1000, alpha=0, &nbsp;onComplete=timedDisplay(i)} ) end end timedDisplay(1)

but this just displays all 6 numbers at the same time. I’m not sure how to go about getting numbers in a table to display one after the other. Thanks.