summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-05-01 08:23:53 +0000
committerDave Chapman <dave@dchapman.com>2006-05-01 08:23:53 +0000
commitb4f0efc1dd2810f68e5fe7e10c49a425505e6840 (patch)
treef5afcf59247a294eb1ff9149c07470de25d2009c /apps/plugins
parentac36f7101de54531b4b7f8dac6e7d724f8216ae7 (diff)
downloadrockbox-b4f0efc1dd2810f68e5fe7e10c49a425505e6840.zip
rockbox-b4f0efc1dd2810f68e5fe7e10c49a425505e6840.tar.gz
rockbox-b4f0efc1dd2810f68e5fe7e10c49a425505e6840.tar.bz2
rockbox-b4f0efc1dd2810f68e5fe7e10c49a425505e6840.tar.xz
Call rb->yield() during the random game generation.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9847 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/sudoku/generator.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/apps/plugins/sudoku/generator.c b/apps/plugins/sudoku/generator.c
index d43e970..037798d 100644
--- a/apps/plugins/sudoku/generator.c
+++ b/apps/plugins/sudoku/generator.c
@@ -357,6 +357,8 @@ findmoves( void )
{
int i;
+ rb->yield();
+
idx_possible = 0;
for( i = 0 ; i < 9 ; ++i )
{
@@ -392,6 +394,9 @@ void
pairs( int el, int (*idx_fn)( int, int ) )
{
int i, j, k, mask, idx;
+
+ rb->yield();
+
for( i = 0 ; i < 8 ; ++i )
if( 7 == digits[ i ] ) /* 2 digits unknown */
for( j = i + 1 ; j < 9 ; ++j )
@@ -419,6 +424,8 @@ exmask( int mask, int block, int el, int (*idx_fn)( int, int ) )
{
int i, idx;
+ rb->yield();
+
for( i = 0 ; i < 9 ; ++i )
{
idx = (*idx_fn)( el, i );
@@ -434,6 +441,8 @@ exblock( int block, int el, int (*idx_fn)( int, int ) )
{
int i, idx, mask;
+ rb->yield();
+
/* By assumption, all unknown squares in the block appear in the
* same row/column, so to construct a mask for these squares, it
* is sufficient to invert the mask for the known squares in the
@@ -455,6 +464,8 @@ block( int el )
{
int i, idx = 0, row, col;
+ rb->yield();
+
/* Find first unknown square */
for( i = 0 ; i < 9 && !IS_EMPTY( idx = idx_block( el, i ) ) ; ++i )
;
@@ -487,6 +498,8 @@ common( int el )
{
int i, idx, row, col, digit, mask;
+ rb->yield();
+
for( digit = 1 ; digit <= 9 ; ++digit )
{
mask = DIGIT_STATE( digit );
@@ -525,6 +538,8 @@ position2( int el )
{
int digit, digit2, i, mask, mask2, posn, count, idx;
+ rb->yield();
+
/* Calculate positions of each digit within block */
for( digit = 1 ; digit <= 9 ; ++digit )
{
@@ -574,6 +589,8 @@ allmoves( void )
{
int i, n;
+ rb->yield();
+
n = findmoves( );
if( 0 < n )
return n;
@@ -619,6 +636,8 @@ findhints( void )
{
int i, n, mutated = 0;
+ rb->yield();
+
n = findmoves( );
if( n < 2 )
{
@@ -687,6 +706,8 @@ deterministic( void )
{
int i, n;
+ rb->yield();
+
n = allmoves( );
while( 0 < n )
{
@@ -720,6 +741,9 @@ int
choice( void )
{
int i, n;
+
+ rb->yield();
+
for( n = i = 0 ; i < 81 ; ++i )
if( IS_EMPTY( i ) )
{
@@ -746,6 +770,8 @@ static
int
choose( int idx, int digit )
{
+ rb->yield();
+
for( ; digit <= 9 ; ++digit )
if( !DISALLOWED( idx, digit ) )
{
@@ -770,6 +796,8 @@ backtrack( void )
{
int digit, idx;
+ rb->yield();
+
for( ; 0 <= --idx_history ; )
if( history[ idx_history ] & CHOICE )
{
@@ -796,6 +824,8 @@ solve( void )
{
int idx;
+ rb->yield();
+
while( 1 )
{
if( 0 == deterministic( ) )
@@ -870,6 +900,8 @@ classify( void )
{
int i, score;
+ rb->yield();
+
pass = 0;
clear_moves( );
if( -1 == solve( ) )
@@ -1049,9 +1081,13 @@ start:
for( i = 0 ; i < len_tmplt ; ++i )
fill( tmplt[ i ], digits[ i % 9 ] );
+ rb->yield();
+
if( 0 != solve( ) || idx_history < 81 )
goto start;
+ rb->yield();
+
for( i = 0 ; i < len_tmplt ; ++i )
board[ tmplt[ i ] ] |= FIXED;