Пример #1
0
Файл: genKPK.cpp Проект: hof/qm2
 /**
  * Calculate table index
  * 
  * @return {int} table index (range: 0 .. MAX_IDX) 
  * 
  * | 0-5        | 6-7            | 8-10
  * | wk (0..63) | wp file (0..3) | wp rank (0..5)
  */
 inline int index(int wk, int wp) {
     int result = wk + (FILE(wp) << 6) + ((RANK(wp) - 1) << 8);
     assert(result >= 0 && result < MAX_IDX);
     assert(FILE(wp) <= 3);
     assert(RANK(wp) <= 6);
     return result;
 }
Пример #2
0
GString *board_format_line(board *b, char handsep, char suitsep)
{
	GString *out = g_string_new(NULL);

	int h;
	for (h = 1; h < 5; h++) {
		int c;
		for (c = 51; c >= 39; c--)
			if (b->dealt_cards[c] == h)
				g_string_append_printf(out, "%c", rank_char(RANK(c)));
		g_string_append_printf(out, "%c", suitsep);
		for (c = 38; c >= 26; c--)
			if (b->dealt_cards[c] == h)
				g_string_append_printf(out, "%c", rank_char(RANK(c)));
		g_string_append_printf(out, "%c", suitsep);
		for (c = 25; c >= 13; c--)
			if (b->dealt_cards[c] == h)
				g_string_append_printf(out, "%c", rank_char(RANK(c)));
		g_string_append_printf(out, "%c", suitsep);
		for (c = 12; c >= 0; c--)
			if (b->dealt_cards[c] == h)
				g_string_append_printf(out, "%c", rank_char(RANK(c)));

		if (h < 4)
			g_string_append_printf(out, "%c", handsep);
	}
	return out;
}
Пример #3
0
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;
        }
    }
}
Пример #4
0
void YukonSolver::undo_move(MOVE *m)
{
#if PRINT
    if ( m->totype == O_Type )
        fprintf( stderr, "\nundo move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "\nundo move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();

#endif
	int from, to;
	card_t card;

	from = m->from;
	to = m->to;

        /* Add to 'from' pile. */
        if ( m->turn_index > 0 )
        {
            card_t card2 = *Wp[from];
            if ( !DOWN( card2 ) )
                card2 = ( SUIT( card2 ) << 4 ) + RANK( card2 ) + ( 1 << 7 );
            *Wp[from] = card2;
        }

	if (m->totype == O_Type) {
            card = O[to] + Osuit[to];
            O[to]--;
            Wp[from]++;
            *Wp[from] = card;
            Wlen[from]++;
        } else {
            for ( int l = m->card_index; l >= 0; l-- )
            {
                card = W[to][Wlen[to]-l-1];
                Wp[from]++;
                *Wp[from] = card;
                Wlen[from]++;
                *Wp[to]--;
            }
            Wlen[to] -= m->card_index + 1;
            hashpile(to);
	}

        if ( m->turn_index == 0 )
        {
            card_t card = *Wp[from];
            if ( DOWN( card ) )
                card = ( SUIT( card ) << 4 ) + RANK( card );
            else
                card += ( 1 << 7 );
            *Wp[from] = card;
        }

        hashpile(from);
#if PRINT
        print_layout();
#endif
}
Пример #5
0
void YukonSolver::make_move(MOVE *m)
{
#if PRINT
    if ( m->totype == O_Type )
        fprintf( stderr, "\nmake move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "\nmake move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();
#else
    //print_layout();
#endif

	int from, to;
	card_t card = NONE;

	from = m->from;
	to = m->to;

        for ( int l = m->card_index; l >= 0; l-- )
        {
            card = W[from][Wlen[from]-l-1];
            Wp[from]--;
            if ( m->totype != O_Type )
            {
                Wp[to]++;
                *Wp[to] = card;
                Wlen[to]++;
            }
        }
        Wlen[from] -= m->card_index + 1;

        if ( m->turn_index == 0 )
        {
            if ( DOWN( card ) )
                card = ( SUIT( card ) << 4 ) + RANK( card );
            else
                card += ( 1 << 7 );
            W[to][Wlen[to]-m->card_index-1] = card;
        } else if ( m->turn_index != -1 )
        {
            card_t card2 = *Wp[from];
            if ( DOWN( card2 ) )
                card2 = ( SUIT( card2 ) << 4 ) + RANK( card2 );
            *Wp[from] = card2;
        }

        hashpile(from);
	/* Add to pile. */

	if (m->totype == O_Type) {
            O[to]++;
            Q_ASSERT( m->card_index == 0 );
        } else {
            hashpile(to);
	}
#if PRINT
        print_layout();
#endif
}
Пример #6
0
static inline int square_distance(int s1, int s2)
{
    int r = abs(RANK(s1) - RANK(s2));
    int c = abs(COLUMN(s1) - COLUMN(s2));
    if (r > c)
        return r;
    else
        return c;
};
Пример #7
0
int GypsySolver::good_automove(int o, int r)
{
    int i;

    if (r <= 2) {
        return true;
    }

    /* Check the Out piles of opposite color. */
    int red_piles[]   = { 0, 1, 4, 5 };
    int black_piles[] = { 2, 3, 6, 7 };

    for (i = 0; i < 4; ++i)
    {
        int pile = 0;
        if ( COLOR( o ) == PS_BLACK )
            pile = red_piles[i] + outs;
        else
            pile = black_piles[i] + outs;
        if ( !Wlen[pile] || RANK( *Wp[pile] ) < r - 1)
        {
            /* Not all the N-1's of opposite color are out
               yet.  We can still make an automove if either
               both N-2's are out or the other same color N-3
               is out (Raymond's rule).  Note the re-use of
               the loop variable i.  We return here and never
               make it back to the outer loop. */

            for (i = 0; i < 4; ++i )
            {
                if ( COLOR( o ) == PS_BLACK )
                    pile = red_piles[i] + outs;
                else
                    pile = black_piles[i] + outs;
                if ( !Wlen[pile] || RANK( *Wp[pile] ) < r - 2)
                    return false;
            }

            for (i = 0; i < 4; ++i )
            {
                if ( COLOR( o ) == PS_BLACK )
                    pile = black_piles[i] + outs;
                else
                    pile = red_piles[i] + outs;
                if ( !Wlen[pile] || RANK( *Wp[pile] ) < r - 3)
                    return false;
            }

            return true;
        }
    }

    return true;
}
Пример #8
0
// '[' RANK ']'
// '[' '*' ']'
BOOL CLRTypeName::TypeNameParser::ARRAY()
{
    IfFalseReturn(TokenIs(TypeNameARRAY));

    NextToken();

    if (TokenIs(TypeNameAstrix))
    {
        m_pTypeName->SetArray(1);

        NextToken();
    }
    else
    {
        DWORD dwRank = 1;
        IfFalseReturn(RANK(&dwRank));

        if (dwRank == 1)
        {
            m_pTypeName->SetSzArray();
        }
        else
        {
            m_pTypeName->SetArray(dwRank);
        }
    }

    IfFalseReturn(TokenIs(TypeNameCloseSqBracket));
    NextToken();

    return TRUE;
}
Пример #9
0
HandRank EvaluateHand(int hand[5])
{    
    int rankcount[13]= {0};
    for (int i=0; i< 5; i++)
        rankcount[RANK(hand[i])]++;

    if (is_royal(hand))
        return eRoyal;
    if (is_straight_flush(hand, rankcount))
        return eStraightFlush;
    if (is_four(rankcount))
        return eFour;
    if (is_full(rankcount))
        return eFull;
    if (is_flush(hand))
        return eFlush;
    if (is_straight(rankcount))
        return eStraight;
    if (is_three(rankcount))
        return eThree;
    if (is_TwoPair(rankcount))
        return eTwoPair;
    if (is_Pair(rankcount))
        return ePair;

    return eBust;
}
Пример #10
0
void
PrettyPrint(Heap * h)
{
  Heap * h1;

  if(h == NULL_HEAP)
  {
    printf(" nil ");
    return;
  }

  printf("(");

  h1 = h;
  do
  {
    PrintItem(ITEM(h1));
    printf("[%u] ", RANK(h1));
    PrettyPrint(CHILD(h1));
    h1 = FORWARD(h1);
  }
  while(h1 != h);

  printf(")");
}
Пример #11
0
int GypsySolver::getOuts()
{
    int k = 0;
    for (int o = 0; o < 8; ++o)
        if ( Wlen[outs + o] )
            k += RANK( *Wp[outs + o] );

    return k;
}
Пример #12
0
inline bool higher( const card_t &c1, const card_t &c2)
{
    // Sanity check.
    if (c1 == c2)
        return false;

    // Must be same suit.
    if ( SUIT( c1 ) != SUIT( c2 ) )
        return false;

    // Aces form a special case.
    if (RANK( c2 ) == PS_ACE)
        return true;
    if (RANK( c1 ) == PS_ACE)
        return false;

    return (RANK( c1 ) < RANK( c2 ));
}
Пример #13
0
void SimonSolver::undo_move(MOVE *m)
{
#if PRINT
    //qDebug() << "\n\nundo_move\n";
    if ( m->totype == O_Type )
        fprintf( stderr, "move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();

#endif
	int from, to;
	card_t card;

	from = m->from;
	to = m->to;

        if (m->totype == O_Type) {
            for ( int j = PS_KING; j >= PS_ACE; --j )
            {
                Wp[from]++;
                *Wp[from] = O[to] + j;
                Wlen[from]++;
            }
            O[to] = -1;
            hashpile( from );
#if PRINT
            print_layout();
#endif
            return;
        }

        /* Add to 'from' pile. */
        if ( m->turn_index > 0 )
        {
            card_t card2 = *Wp[from];
            if ( !DOWN( card2 ) )
                card2 = ( SUIT( card2 ) << 4 ) + RANK( card2 ) + ( 1 << 7 );
            *Wp[from] = card2;
        }

        for ( int l = m->card_index; l >= 0; --l )
        {
            card = W[to][Wlen[to]-l-1];
            Wp[from]++;
            *Wp[from] = card;
            Wlen[from]++;
            Wp[to]--;
        }
        Wlen[to] -= m->card_index + 1;
        hashpile(to);
        hashpile(from);
#if PRINT
        print_layout();
#endif
}
Пример #14
0
int
SanityCheck2(Heap * h)
{
  int   sum;
  Heap * h1;
  Heap * h2;

  if(h == NULL_HEAP)
  {
     return(TRUE);
  }

  h1 = h;
  do
  {
    if(CHILD(h1) != NULL_HEAP)
    {
      sum = 0;
      h2 = CHILD(h1);
      do
      {
         sum += RANK(h2) + 1;

         h2 = FORWARD(h2);
      }
      while(h2 != CHILD(h1));
      if(sum != RANK(h1))
      {
        return(FALSE);
      }

      if(!SanityCheck2(CHILD(h1)))
      {
        return(FALSE);
      }
    }

    h1 = FORWARD(h1);
  }
  while(h1 != h);

  return(TRUE);
}
Пример #15
0
/* Wrapper over uvwrite_c to deal with numpy arrays, conversion of baseline
 * codes, and accepts preamble as a tuple.
 */
PyObject * UVObject_write(UVObject *self, PyObject *args) {
    PyArrayObject *data=NULL, *flags=NULL, *uvw=NULL;
    int i, j;
    double preamble[PREAMBLE_SIZE], t;
    // Parse arguments and typecheck
    if (!PyArg_ParseTuple(args, "(O!d(ii))O!O!", 
        &PyArray_Type, &uvw, &t, &i, &j,
        &PyArray_Type, &data, &PyArray_Type, &flags)) return NULL;
    if (RANK(uvw) != 1 || DIM(uvw,0) != 3) {
        PyErr_Format(PyExc_ValueError,
            "uvw must have shape (3,) %d", RANK(uvw));
        return NULL;
    } else if (RANK(data)!=1 || RANK(flags)!=1 || DIM(data,0)!=DIM(flags,0)) {
        PyErr_Format(PyExc_ValueError,
            "data and flags must be 1 dimensional and have the same shape");
        return NULL;
    }
    CHK_ARRAY_TYPE(uvw, NPY_DOUBLE);
    CHK_ARRAY_TYPE(data, NPY_CFLOAT);
    // Check for both int,long, b/c label of 32b number is platform dependent
    if (TYPE(flags) != NPY_INT && \
            (sizeof(int) == sizeof(long) && TYPE(flags) != NPY_LONG)) {
        PyErr_Format(PyExc_ValueError, "type(flags) != NPY_LONG or NPY_INT");
        return NULL;
    }
    // Fill up the preamble
    preamble[0] = IND1(uvw,0,double);
    preamble[1] = IND1(uvw,1,double);
    preamble[2] = IND1(uvw,2,double);
    preamble[3] = t;
    preamble[4] = MKBL(i,j);
    // Here is the MIRIAD call
    try {
        uvwrite_c(self->tno, preamble,
            (float *)data->data, (int *)flags->data, DIM(data,0));
    } catch (MiriadError &e) {
        PyErr_Format(PyExc_RuntimeError, e.get_message());
        return NULL;
    }
    Py_INCREF(Py_None);
    return Py_None;
}
Пример #16
0
bool GypsySolver::isWon()
{
    // maybe won?
    for (int o = 0; o < 8; ++o)
    {
        if ( ( Wlen[outs + o] == 0 ) || ( RANK( *Wp[outs + o] ) != PS_KING ) )
            return false;
    }

    return true;
}
Пример #17
0
std::string SqToStr( int sq )
{
    char file = FILE(sq);
    char rank = RANK(sq);
    char buf[3];
    buf[0] = file;
    buf[1] = rank;
    buf[2] = '\0';
    std::string s = buf;
    return s;
}
Пример #18
0
string refresh(int *cl, int b, int e)
{
        string output = "";
        int i, ls, ns;
        if (b < 0 || e < 0)
                return output;
        if (cl[b] < 0 || cl[e] > 51)
                return output;
        output = sprintf("%18s%s:", "", suit_str[ls = ns = SUIT(cl[b])]);
        for (i = b; i <= e; i++) {
                ns = SUIT(cl[i]);
                if (ls == ns) 
                        output += rank_str[RANK(cl[i])] + " ";
                else {
                        output = sprintf("%s\n%18s%s:", output, "",
                                        suit_str[ls = ns]);
                        output += rank_str[RANK(cl[i])] + " ";
                }
        }
        return output + "\n";
}
Пример #19
0
void SimonSolver::make_move(MOVE *m)
{
#if PRINT
    //qDebug() << "\n\nmake_move\n";
    if ( m->totype == O_Type )
        fprintf( stderr, "move %d from %d out (at %d) Prio: %d\n\n", m->card_index, m->from, m->turn_index, m->pri );
    else
        fprintf( stderr, "move %d from %d to %d (%d) Prio: %d\n\n", m->card_index, m->from, m->to, m->turn_index, m->pri );
    print_layout();
#else
    //print_layout();
#endif

	int from, to;
	card_t card = NONE;

	from = m->from;
	to = m->to;

	if (m->totype == O_Type) {
            O[to] = SUIT( *Wp[from] );
            Wlen[from] -= 13;
            Wp[from] -= 13;
            hashpile( from );
            if ( Wlen[from] && DOWN( *Wp[from] ) )
            {
                *Wp[from] = ( SUIT( *Wp[from] ) << 4 ) + RANK( *Wp[from] );
            }
#if PRINT
            print_layout();
#endif
            return;
        }

        for ( int l = m->card_index; l >= 0; --l )
        {
            card = W[from][Wlen[from]-l-1];
            Wp[from]--;
            if ( m->totype != O_Type )
            {
                Wp[to]++;
                *Wp[to] = card;
                Wlen[to]++;
            }
        }
        Wlen[from] -= m->card_index + 1;

        hashpile(from);
        hashpile(to);
#if PRINT
        print_layout();
#endif
}
Пример #20
0
static char *lin_card_string(board *b)
{
	static char out[39+16+4+1];
	int i = 0, h;
	for (h = 4; h != 3; h = (h == 4 ? 1 : h + 1)) {
		int c;
		out[i++] = 'S';
		for (c = 39; c < 52; c++)
			if (b->dealt_cards[c] == h) out[i++] = rank_char(RANK(c));
		out[i++] = 'H';
		for (c = 26; c < 39; c++)
			if (b->dealt_cards[c] == h) out[i++] = rank_char(RANK(c));
		out[i++] = 'D';
		for (c = 13; c < 26; c++)
			if (b->dealt_cards[c] == h) out[i++] = rank_char(RANK(c));
		out[i++] = 'C';
		for (c = 0; c < 13; c++)
			if (b->dealt_cards[c] == h) out[i++] = rank_char(RANK(c));
		out[i++] = ',';
	}
	return out;
}
Пример #21
0
// *empty*
// ',' RANK
BOOL CLRTypeName::TypeNameParser::RANK(DWORD* pdwRank)
{
    if (!TokenIs(TypeNameRANK))
    {
        return TRUE;
    }

    NextToken();
    *pdwRank = *pdwRank + 1;
    IfFalseReturn(RANK(pdwRank));

    return TRUE;
}
Пример #22
0
void IdiotSolver::make_move(MOVE *m)
{
#if PRINT
    if ( m->totype == O_Type )
        fprintf( stderr, "\nmake move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "\nmake move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();
#else
    //print_layout();
#endif

    int from, to;
    card_t card = NONE;

    from = m->from;
    to = m->to;

    if ( from == 4 )
    {
        Q_ASSERT( Wlen[from] >= 4 );

        for ( int i = 0; i < 4; ++i )
        {
            Wp[i]++;
            card = *Wp[from];
            *Wp[i] = ( SUIT( card ) << 4 ) + RANK( card );
            Wp[from]--;
            Wlen[from]--;
            Wlen[i]++;
            hashpile( i );
        }
        hashpile( from );
    } else {

        card = *Wp[from];
        Wp[from]--;
        Wlen[from]--;
        *Wp[to]++;
        *Wp[to] = card;
        Wlen[to]++;

        hashpile( to );
        hashpile(from);
    }

#if PRINT
    print_layout();
#endif
}
Пример #23
0
void GolfSolver::make_move(MOVE *m)
{
#if PRINT
    if ( m->totype == O_Type )
        fprintf( stderr, "\nmake move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "\nmake move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();
#else
    //print_layout();
#endif

    int from = m->from;
    int to = m->to;

    Q_ASSERT( to == 7 );
    Q_ASSERT( from != 7 );

    // move to pile
    if ( from == 8 && to == 7 )
    {
        card_t card = *Wp[8];
        Wp[8]--;
        Wlen[8]--;
        card = ( SUIT( card ) << 4 ) + RANK( card );
        Wp[7]++;
        *Wp[7] = card;
        Wlen[7]++;
        hashpile( 7 );
        hashpile( 8 );
#if PRINT
        print_layout();
#endif
        return;
    }

    card_t card = *Wp[from];
    Wp[from]--;
    Wlen[from]--;

    Wp[to]++;
    *Wp[to] = card;
    Wlen[to]++;

    hashpile(from);
    hashpile(to);
#if PRINT
    print_layout();
#endif
}
Пример #24
0
char GetRankChar(unsigned char c)
{
	/*
	*
	*/

	const char randChars[] = "  23456789TJQKA";

	if(ISCARDBACK(c))
		return '?';
	if(ISUNKNOWN(c))
		return '_';

	return randChars[RANK(c)];
}
Пример #25
0
int
SanityCheck3(Heap * h, int rank)
{
  int   sum;
  Heap * h1;
  Heap * h2;

  if((h == NULL_HEAP) && (rank == 0))
  {
     return(TRUE);
  }

  sum = 0;
  h1 = h;
  do
  {
    sum += RANK(h1) + 1;

    if(!SanityCheck3(CHILD(h1), RANK(h1)))
    {
      return(FALSE);
    }

    h1 = FORWARD(h1);
  }
  while(h1 != h);

  if(sum == rank)
  {
    return(TRUE);
  }
  else
  {
    return(FALSE);
  }
}
Пример #26
0
 // CAdds data to a at indices specified in ind.  Assumes arrays are safe.
 static int caddloop(PyArrayObject *a, PyArrayObject *ind, 
         PyArrayObject *data) {
     char *index = NULL;
     int v;
     for (int i=0; i < DIM(ind,0); i++) {
         index = a->data;
         for (int j=0; j < RANK(a); j++) {
             v = IND2(ind,i,j,long);
             if (v < 0) v += DIM(a,j);
             if (v < 0 || v >= DIM(a,j)) return -1;
             index += v * a->strides[j];
         }
         CADD(index,PNT1(data,i),T);
     }
     return 0;
 }
Пример #27
0
void IdiotSolver::undo_move(MOVE *m)
{
#if PRINT
    if ( m->totype == O_Type )
        fprintf( stderr, "\nundo move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "\nundo move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();

#endif
    int from, to;
    card_t card;

    from = m->from;
    to = m->to;

    if ( from == 4 )
    {
        for ( int i = 3; i >= 0; --i )
        {
            card = *Wp[i];
            Wp[i]--;
            Wlen[i]--;
            Wp[from]++;
            *Wp[from] = ( SUIT( card ) << 4 ) + RANK( card ) + ( 1 << 7 );
            Wlen[from]++;
            hashpile( i );
        }
        hashpile( from );

    } else {

        card = *Wp[to];
        Wp[to]--;
        Wlen[to]--;
        *Wp[from]++;
        *Wp[from] = card;
        Wlen[from]++;

        hashpile( to );
        hashpile(from);
    }

#if PRINT
    print_layout();
#endif
}
Пример #28
0
char*
StringPosition(Position pos)
{
  char ret[2+1];

  // Unsigned so we don't need to check < 0.
  if(pos > 63) {
    return strdup("#invalid position");
  }

  if(sprintf(ret, "%c%d", 'a'+FILE(pos), RANK(pos)+1) != 2) {
    panic("Couldn't string position");
  }

  ret[2] = '\0';

  return strdup(ret);
}
Пример #29
0
void ClockSolver::undo_move(MOVE *m)
{
#if PRINT2
    if ( m->totype == O_Type )
        fprintf( stderr, "\nundo move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
    else
        fprintf( stderr, "\nundo move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();

#endif
    int from, to;
    card_t card;

    from = m->from;
    to = m->to;

    if (m->totype == O_Type) {
        card = W[8][to];
        if ( RANK( card ) == PS_ACE )
            W[8][to] = W[8][to] - PS_ACE + PS_KING;
        else
            W[8][to]--;
        Wp[from]++;
        *Wp[from] = card;
        Wlen[from]++;
        hashpile( 8 );
        hashpile( from );
    } else {
        card = *Wp[to];
        Wp[from]++;
        *Wp[from] = card;
        Wlen[from]++;
        Wp[to]--;
        Wlen[to]--;
        hashpile(to);
        hashpile( from );
    }

#if PRINT2
    print_layout();
#endif
}
Пример #30
0
void ClockSolver::make_move(MOVE *m)
{
#if PRINT
    if ( m->totype == O_Type )
        fprintf( stderr, "\nmake move %d from %d out %d (at %d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    else
        fprintf( stderr, "\nmake move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
    print_layout();
#else
    //print_layout();
#endif

    int from, to;
    from = m->from;
    to = m->to;

    card_t card = *Wp[from];
    Wlen[from]--;
    Wp[from]--;

    hashpile(from);
    /* Add to pile. */

    if (m->totype == O_Type) {
        if ( RANK( W[8][to] ) == PS_KING )
            W[8][to] = W[8][to] - PS_KING + PS_ACE;
        else
            W[8][to]++;
        Q_ASSERT( m->card_index == 0 );
        hashpile( 8 );
    } else {
        Wp[to]++;
        *Wp[to] = card;
        Wlen[to]++;
        hashpile( to );
    }

#if PRINT
    print_layout();
#endif
}