void Mod3Solver::translate_layout() { /* Read the workspace. */ int w = 0; int total = 0; for ( int row = 0; row < 4; ++row ) { for ( int col = 0; col < 8; ++col ) { int i = translate_pile(deal->stack[row][col], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; w++; } } aces = w; int i = translate_pile(deal->aces, W[w], 52); Wp[w] = &W[w][i-1]; Wlen[w] = i; deck = ++w; i = translate_pile(deal->talon, W[w], 104); Wp[w] = &W[w][i-1]; Wlen[w] = i; }
void GolfSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 7; ++w ) { int i = translate_pile(deal->stack[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; } int i = translate_pile( deal->waste, W[7], 52 ); Wp[7] = &W[7][i-1]; Wlen[7] = i; total += i; i = translate_pile( deal->talon, W[8], 52 ); Wp[8] = &W[8][i-1]; Wlen[8] = i; total += i; for ( int i = 0; i < 9; i++ ) { for ( int l = 0; l < Wlen[i]; l++ ) { card_t card = W[i][l]; if ( DOWN( card ) ) card = RANK( card ) + PS_SPADE + ( 1 << 7 ); else card = RANK( card ) + PS_SPADE; W[i][l] = card; } } }
void YukonSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 7; ++w ) { int i = translate_pile(deal->store[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; } /* Output piles, if any. */ for (int i = 0; i < 4; i++) { O[i] = NONE; } if (total != 52) { for (int i = 0; i < 4; i++) { Card *c = deal->target[i]->top(); if (c) { O[translateSuit( c->suit() ) >> 4] = c->rank(); total += c->rank(); } } } Q_ASSERT( total == 52 ); }
void ClockSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 8; ++w ) { int i = translate_pile(deal->store[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; } /* Output piles, if any. */ for (int i = 0; i < 12; ++i) { KCard *c = deal->target[i]->topCard(); // It is not safe to assume that each target pile will always have a // card on it. If it takes particularly long to render the card graphics // at the start of a new game, it is possible that this method can be // called before the initial deal has been completed. if (c) W[8][i] = translateSuit( c->suit() ) + c->rank(); } Wp[8] = &W[8][11]; Wlen[8] = 12; }
void FreecellSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 8; ++w ) { int i = translate_pile(deal->store[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; if (w == Nwpiles) { break; } } /* Temp cells may have some cards too. */ for (int w = 0; w < Ntpiles; ++w) { int i = translate_pile( deal->freecell[w], W[w+Nwpiles], 52 ); Wp[w+Nwpiles] = &W[w+Nwpiles][i-1]; Wlen[w+Nwpiles] = i; total += i; } /* Output piles, if any. */ for (int i = 0; i < 4; ++i) { O[i] = NONE; } if (total != 52) { for (int i = 0; i < 4; ++i) { KCard *c = deal->target[i]->topCard(); if (c) { O[translateSuit( c->suit() ) >> 4] = c->rank(); total += c->rank(); } } } }
void KlondikeSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 7; ++w ) { int i = translate_pile(deal->play[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; } int i = translate_pile( deal->pile, W[7], 52 ); Wp[7] = &W[7][i-1]; Wlen[7] = i; total += i; i = translate_pile( deal->talon, W[8], 52 ); Wp[8] = &W[8][i-1]; Wlen[8] = i; total += i; /* Output piles, if any. */ for (int i = 0; i < 4; ++i) { O[i] = NONE; } if (total != 52) { for (int i = 0; i < 4; ++i) { KCard *c = deal->target[i]->topCard(); if (c) { O[translateSuit( c->suit() ) >> 4] = c->rank(); total += c->rank(); } } } }
void IdiotSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 4; ++w ) { int i = translate_pile(deal->m_play[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; } int i = translate_pile( Deck::deck(), W[4], 52 ); Wp[4] = &W[4][i-1]; Wlen[4] = i; total += i; i = translate_pile( deal->m_away, W[5], 52 ); Wp[5] = &W[5][i-1]; Wlen[5] = i; total += i; Q_ASSERT( total == 52 ); }
void GypsySolver::translate_layout() { /* Read the workspace. */ for ( int w = 0; w < 8; ++w ) { int i = translate_pile(deal->store[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; } deck = 8; int i = translate_pile( deal->talon, W[deck], 80 ); Wp[deck] = &W[deck][i-1]; Wlen[deck] = i; outs = 9; /* Output piles, if any. */ for (int i = 0; i < 8; ++i) { Wlen[outs + i] = 0; Wp[outs + i] = &W[outs + i][-1]; } for (int i = 0; i < 8; ++i) { KCard *c = deal->target[i]->topCard(); if (c) { int suit = translateSuit( c->suit() ) >> 4; int target = outs + suit*2; if ( Wlen[target] ) target++; Wp[target]++; Wlen[target]++; *Wp[target] = ( suit << 4 ) + c->rank(); } } }
void SimonSolver::translate_layout() { /* Read the workspace. */ int total = 0; for ( int w = 0; w < 10; ++w ) { int i = translate_pile(deal->store[w], W[w], 52); Wp[w] = &W[w][i - 1]; Wlen[w] = i; total += i; } for (int i = 0; i < 4; ++i) { O[i] = -1; KCard *c = deal->target[i]->topCard(); if (c) { total += 13; O[i] = translateSuit( c->suit() ); } } }