コード例 #1
0
 void unnecessary_copy_emplace_move_test(T*)
 {
     reset();
     T x;
     BOOST_DEDUCED_TYPENAME T::value_type a;
     COPY_COUNT(1); MOVE_COUNT(0);
     x.emplace(std::move(a));
     COPY_COUNT(1); MOVE_COUNT(1);
 }
コード例 #2
0
ファイル: ai.c プロジェクト: ejrh/ejrh
int is_valid_move(GAME *game, MOVE move)
{
    int move_value;
    int move_count;
    int pile_value;
    int pile_count;

    /* Pass is valid if the pile belongs to someone else, or the player is out. */
    if (move == MOVE_PASS)
    {
        if (get_hand_size(game->players[game->current_player].hand) == 0)
            return 1;
        
        return (game->current_player != game->pile_owner);
    }
    
    /* Joker is always valid. */
    if (move == MOVE_JOKER)
    {
        return 1;
    }

    /* If the pile is empty or belongs to us, the move is valid. */
    pile_count = MOVE_COUNT(game->pile);

    if (pile_count == 0 || game->pile_owner == game->current_player)
    {
        return 1;
    }

    /* Otherwise, if the move is the same size of pile but higher value,
       then it's is valid. */
    pile_value = MOVE_VALUE(game->pile);
    move_value = MOVE_VALUE(move);
    move_count = MOVE_COUNT(move);

    if (move_count == pile_count && move_value > pile_value)
        return 1;

    return 0;
}
コード例 #3
0
ファイル: ai.c プロジェクト: ejrh/ejrh
void apply_move(GAME *game, MOVE move)
{
    PLAYER *player = &game->players[game->current_player];
    int next_player;
    
    if (move != MOVE_PASS)
    {
        int move_value = MOVE_VALUE(move);
        int move_count = MOVE_COUNT(move);

        DECKP hand = player->hand;

        hand[move_value] -= move_count;

        game->pile = move;
        game->pile_owner = game->current_player;
        
        /* Is this player out? */
        if (get_hand_size(player->hand) == 0)
        {
            player->rank = game->next_rank;
            game->next_rank++;
        }
    }
    
    /* Move to next player. */
    next_player = game->current_player;
    do
    {
        next_player = (next_player+1) % game->num_players;
        if (next_player == game->current_player)
        {
            /* Game is over. */
            game->players[next_player].rank = game->next_rank;
            return;
        }
    }
    while (game->players[next_player].rank != UNRANKED);
    
    game->current_player = next_player;
}
コード例 #4
0
ファイル: ai.c プロジェクト: ejrh/ejrh
void print_move(MOVE move)
{
    int value = MOVE_VALUE(move);
    int count = MOVE_COUNT(move);
    int i;

    if (move == MOVE_INVALID)
    {
        printf("invalid");
        return;
    }

    printf("[");
    for (i = 0; i < count; i++)
    {
        if (i > 0)
            printf(" ");
        printf("%s", card_names[value]);
    }
    printf("]");
}