Beispiel #1
0
static int findCardToBuy(struct gameState *state) {
  // randomly order cards to buy
  int coins = countCoins(state);
  int cards[NUM_CARDS_TO_BUY];
  for (int i = 0; i < NUM_CARDS_TO_BUY; i++) {
    // pick card to check
    int card = randomCardToBuy();
    bool tmp = hasCard(cards, i, card);
    while (tmp) {
      card = randomCardToBuy();
      tmp = hasCard(cards, i, card);
    }
    cards[i] = card;

    // check card
    int cost = cardToBuyCost(card);
    int supply = supplyCount(card, state);
    if (supply > 0 && cost <= coins) {
      // found card to buy
      return card;
    }
  }

  // didn't find any card to buy
  return -1;
}
Beispiel #2
0
int getMinimalAmountOfCoins(int total){
	int i;
	for(i=0;i<=coins_count;i++){
		coins_buffer[i] = countCoins(total-coins[i],total);
	}

	return findMinimumValue(coins_buffer)+1;
}