1
0
Fork 0
forked from len0rd/rockbox

Call rb->yield() during the random game generation.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9847 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2006-05-01 08:23:53 +00:00
parent ac36f7101d
commit b4f0efc1dd

View file

@ -357,6 +357,8 @@ findmoves( void )
{ {
int i; int i;
rb->yield();
idx_possible = 0; idx_possible = 0;
for( i = 0 ; i < 9 ; ++i ) for( i = 0 ; i < 9 ; ++i )
{ {
@ -392,6 +394,9 @@ void
pairs( int el, int (*idx_fn)( int, int ) ) pairs( int el, int (*idx_fn)( int, int ) )
{ {
int i, j, k, mask, idx; int i, j, k, mask, idx;
rb->yield();
for( i = 0 ; i < 8 ; ++i ) for( i = 0 ; i < 8 ; ++i )
if( 7 == digits[ i ] ) /* 2 digits unknown */ if( 7 == digits[ i ] ) /* 2 digits unknown */
for( j = i + 1 ; j < 9 ; ++j ) 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; int i, idx;
rb->yield();
for( i = 0 ; i < 9 ; ++i ) for( i = 0 ; i < 9 ; ++i )
{ {
idx = (*idx_fn)( el, i ); idx = (*idx_fn)( el, i );
@ -434,6 +441,8 @@ exblock( int block, int el, int (*idx_fn)( int, int ) )
{ {
int i, idx, mask; int i, idx, mask;
rb->yield();
/* By assumption, all unknown squares in the block appear in the /* By assumption, all unknown squares in the block appear in the
* same row/column, so to construct a mask for these squares, it * same row/column, so to construct a mask for these squares, it
* is sufficient to invert the mask for the known squares in the * 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; int i, idx = 0, row, col;
rb->yield();
/* Find first unknown square */ /* Find first unknown square */
for( i = 0 ; i < 9 && !IS_EMPTY( idx = idx_block( el, i ) ) ; ++i ) 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; int i, idx, row, col, digit, mask;
rb->yield();
for( digit = 1 ; digit <= 9 ; ++digit ) for( digit = 1 ; digit <= 9 ; ++digit )
{ {
mask = DIGIT_STATE( digit ); mask = DIGIT_STATE( digit );
@ -525,6 +538,8 @@ position2( int el )
{ {
int digit, digit2, i, mask, mask2, posn, count, idx; int digit, digit2, i, mask, mask2, posn, count, idx;
rb->yield();
/* Calculate positions of each digit within block */ /* Calculate positions of each digit within block */
for( digit = 1 ; digit <= 9 ; ++digit ) for( digit = 1 ; digit <= 9 ; ++digit )
{ {
@ -574,6 +589,8 @@ allmoves( void )
{ {
int i, n; int i, n;
rb->yield();
n = findmoves( ); n = findmoves( );
if( 0 < n ) if( 0 < n )
return n; return n;
@ -619,6 +636,8 @@ findhints( void )
{ {
int i, n, mutated = 0; int i, n, mutated = 0;
rb->yield();
n = findmoves( ); n = findmoves( );
if( n < 2 ) if( n < 2 )
{ {
@ -687,6 +706,8 @@ deterministic( void )
{ {
int i, n; int i, n;
rb->yield();
n = allmoves( ); n = allmoves( );
while( 0 < n ) while( 0 < n )
{ {
@ -720,6 +741,9 @@ int
choice( void ) choice( void )
{ {
int i, n; int i, n;
rb->yield();
for( n = i = 0 ; i < 81 ; ++i ) for( n = i = 0 ; i < 81 ; ++i )
if( IS_EMPTY( i ) ) if( IS_EMPTY( i ) )
{ {
@ -746,6 +770,8 @@ static
int int
choose( int idx, int digit ) choose( int idx, int digit )
{ {
rb->yield();
for( ; digit <= 9 ; ++digit ) for( ; digit <= 9 ; ++digit )
if( !DISALLOWED( idx, digit ) ) if( !DISALLOWED( idx, digit ) )
{ {
@ -770,6 +796,8 @@ backtrack( void )
{ {
int digit, idx; int digit, idx;
rb->yield();
for( ; 0 <= --idx_history ; ) for( ; 0 <= --idx_history ; )
if( history[ idx_history ] & CHOICE ) if( history[ idx_history ] & CHOICE )
{ {
@ -796,6 +824,8 @@ solve( void )
{ {
int idx; int idx;
rb->yield();
while( 1 ) while( 1 )
{ {
if( 0 == deterministic( ) ) if( 0 == deterministic( ) )
@ -870,6 +900,8 @@ classify( void )
{ {
int i, score; int i, score;
rb->yield();
pass = 0; pass = 0;
clear_moves( ); clear_moves( );
if( -1 == solve( ) ) if( -1 == solve( ) )
@ -1049,9 +1081,13 @@ start:
for( i = 0 ; i < len_tmplt ; ++i ) for( i = 0 ; i < len_tmplt ; ++i )
fill( tmplt[ i ], digits[ i % 9 ] ); fill( tmplt[ i ], digits[ i % 9 ] );
rb->yield();
if( 0 != solve( ) || idx_history < 81 ) if( 0 != solve( ) || idx_history < 81 )
goto start; goto start;
rb->yield();
for( i = 0 ; i < len_tmplt ; ++i ) for( i = 0 ; i < len_tmplt ; ++i )
board[ tmplt[ i ] ] |= FIXED; board[ tmplt[ i ] ] |= FIXED;