Skip to content

Commit

Permalink
Add yfpool/efpool parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Sep 9, 2018
1 parent 8a6687e commit 98fd287
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
21 changes: 16 additions & 5 deletions deck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,18 @@ void Deck::add_forts(const std::string& deck_string)
}
}

void Deck::add_pool_forts(const std::string& deck_string, unsigned amount)
{
auto && id_marks = string_to_ids(all_cards, deck_string, "fortress_cards");
unsigned replicates{1};
std::vector<const Card*> cards;
for (auto id: id_marks.first)
{
cards.push_back(all_cards.by_id(id));
}
variable_forts.push_back(std::make_tuple(amount,replicates,cards));
}

void Deck::add_dominions(const std::string& deck_string, bool override_dom)
{
auto && id_marks = string_to_ids(all_cards, deck_string, "dominion_cards");
Expand Down Expand Up @@ -591,7 +603,7 @@ const Card* Deck::next(Field* f)
hand2.deck = &deck2;
hand1.deck->strategy = DeckStrategy::random;
hand2.deck->strategy = DeckStrategy::random;

//copy Field
Field fd(*f);
fd.players = {{&hand1,&hand2}};
Expand Down Expand Up @@ -651,7 +663,7 @@ void Deck::shuffle(std::mt19937& re)
boost::insert(shuffled_cards, shuffled_cards.end(), cards);
if (!variable_forts.empty())
{
if (strategy != DeckStrategy::random)
if (decktype == DeckType::raid && strategy != DeckStrategy::random)
{
throw std::runtime_error("Support only random strategy for raid/quest deck.");
}
Expand All @@ -670,7 +682,7 @@ void Deck::shuffle(std::mt19937& re)
}
if (!variable_cards.empty())
{
if (strategy != DeckStrategy::random)
if (decktype == DeckType::raid && strategy != DeckStrategy::random)
{
throw std::runtime_error("Support only random strategy for raid/quest deck.");
}
Expand Down Expand Up @@ -745,7 +757,7 @@ void Deck::shuffle(std::mt19937& re)
}
std::shuffle(shufflable_iter, pool->end(), re);
}
#if 0
#if 0
if (!given_hand.empty())
{
for (auto card: cards) std::cout << ", " << card->m_name;
Expand Down Expand Up @@ -789,4 +801,3 @@ Deck* Decks::find_deck_by_name(const std::string& deck_name)
auto it = by_name.find(simplify_name(deck_name));
return it == by_name.end() ? nullptr : it->second;
}

1 change: 1 addition & 0 deletions deck.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Deck
void set_vip_cards(const std::string& deck_string_);
void set_given_hand(const std::string& deck_string_);
void add_forts(const std::string& deck_string_);
void add_pool_forts(const std::string& deck_string_,unsigned amount);
void add_dominions(const std::string& deck_string_, bool override_dom);
void add_dominion(const Card* dom_card, bool override_dom);

Expand Down
23 changes: 21 additions & 2 deletions tyrant_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace {
long double maximum_time{0};
long double temperature = 1000;
long double coolingRate = 0.001;
unsigned yfpool{0};
unsigned efpool{0};
}

using namespace std::placeholders;
Expand Down Expand Up @@ -2383,11 +2385,21 @@ int main(int argc, char** argv)
opt_forts = std::string(argv[argIndex + 1]);
argIndex += 1;
}
else if (strcmp(argv[argIndex], "yfpool") == 0 || strcmp(argv[argIndex], "yfortpool") == 0) // set forts
{
yfpool = std::stoi(argv[argIndex + 1]);
argIndex += 1;
}
else if (strcmp(argv[argIndex], "ef") == 0 || strcmp(argv[argIndex], "efort") == 0) // set enemies' forts
{
opt_enemy_forts = std::string(argv[argIndex + 1]);
argIndex += 1;
}
else if (strcmp(argv[argIndex], "efpool") == 0 || strcmp(argv[argIndex], "efortpool") == 0) // set forts
{
efpool = std::stoi(argv[argIndex + 1]);
argIndex += 1;
}
else if (strcmp(argv[argIndex], "yd") == 0 || strcmp(argv[argIndex], "ydom") == 0) // set dominions
{
opt_doms = std::string(argv[argIndex + 1]);
Expand Down Expand Up @@ -2658,7 +2670,10 @@ int main(int argc, char** argv)
{
try
{
your_deck->add_forts(opt_forts + ",");
if(!yfpool)
your_deck->add_forts(opt_forts + ",");
else
your_deck->add_pool_forts(opt_forts + ",",yfpool);
}
catch(const std::runtime_error& e)
{
Expand Down Expand Up @@ -2949,7 +2964,11 @@ int main(int argc, char** argv)
{
try
{
enemy_deck->add_forts(opt_enemy_forts + ",");
if(!efpool)
enemy_deck->add_forts(opt_enemy_forts + ",");
else
enemy_deck->add_pool_forts(opt_enemy_forts + ",",efpool);

}
catch(const std::runtime_error& e)
{
Expand Down

0 comments on commit 98fd287

Please sign in to comment.