Skip to content

Commit

Permalink
Call init everytime and fix genetic for pool without alpha_dominion
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky authored and APN-Pucky committed May 15, 2020
1 parent d3af2f3 commit 4a381d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ DeckResults genetic_algorithm(unsigned num_min_iterations, unsigned num_iteratio
{
for (unsigned i = it+1; i < pool_size;i++)
{
if(pool[it].first->hash().substr(8)==pool[i].first->hash().substr(8)) //ignore commander + dominion
if(pool[it].first->alpha_dominion && pool[i].first->alpha_dominion && pool[it].first->hash().substr(8)==pool[i].first->hash().substr(8)) //ignore commander + dominion
{
mutate(pool[i].first->clone(),pool[i].first,all_candidates,re,best_gap, evaluated_decks);

Expand Down
12 changes: 7 additions & 5 deletions tyrant_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ void init()
prefered_skills.clear();
prefered_factor=3;

for(Card *c : all_cards.all_cards) delete c; // prevent memory leak
all_cards.visible_cardset.clear();


//fix defaults
for (int i=0; i < Fix::num_fixes;++i) fixes[i]=false;

Expand Down Expand Up @@ -2412,10 +2416,7 @@ DeckResults run(int argc, const char** argv)
#endif
// TODO delete ? since prefix/suffix might change we reload all cards.
//if(all_cards.all_cards.size()>0) delete(&all_cards); // complains invalid pointer
for(Card *c : all_cards.all_cards) delete c; // prevent memory leak
all_cards.visible_cardset.clear();
owned_cards.clear();
//all_cards.organize();
//all_cards.organize();
all_cards = Cards();
Decks decks;
std::unordered_map<std::string, std::string> bge_aliases;
Expand Down Expand Up @@ -3221,6 +3222,7 @@ DeckResults start(int argc, const char** argv) {
//return run(argc,argv);
}
}
init();
return run(argc,argv);
}

Expand All @@ -3242,7 +3244,7 @@ int main(int argc,const char** argv)
usage(argc, argv);
return 255;
}
init();
//init();
start(argc,argv);
return 0;
}
Expand Down

0 comments on commit 4a381d3

Please sign in to comment.