Skip to content

Commit

Permalink
Merge branch 'draquila-parse_owned_cards_as_string'
Browse files Browse the repository at this point in the history
  • Loading branch information
zachanassian committed Jun 4, 2014
2 parents 679eb24 + 6b0cd54 commit 85717ec
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 24 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Flags for climb:
-o: restrict to the owned cards listed in "data/ownedcards.txt".
-o=<filename>: restrict to the owned cards listed in <filename>.
example: -o=data/mycards.txt.
-o=<cards>: restrict to the owned cards specified.
example: -o="Sacred Equalizer#2, Infantry".
target <num>: stop as soon as the score reaches <num>.

Operations:
Expand All @@ -50,6 +52,53 @@ Open https://github.com/zachanassian/tu_optimize/blob/master/README.md to get la

##Changelog

##Version 2.5.0
* Added missions Razogoth Mutant-1 to Razogoth Mutant-5 to <code>data/customdecks_template.txt</code>. Eg. Razogoth Mutant-5 contains all Razogoth Mutant cards at level 5
* Added option to specify owned cards at command line using -o=<cards> - credits [draquila](https://github.com/zachanassian/tu_optimize/pull/31)
<pre>
>tu_optimize "Constantine, Bolt Crag#5, Tempest Citadel#2" "Razogoth Mutant" -o="Barracus, Insanitius, Arch Nova, Omega Nexus, Sacred Sanctuary, Tazerious, Ayrkrane Vik, Necropocalypse, Mawcor" -r climb 10000
Your Deck: [S6-F9+loS+i] Constantine, Bolt Crag, Bolt Crag, Bolt Crag, Bolt Crag, Bolt Crag, Tempest Citadel, Tempest Citadel
Enemy's Deck: [U+-lE+i-lK+i-lQ+i-lW+i-lc+i] Razogoth Mutant, Shadow Mutant, Shadow Mutant, Razoling Mutant, Razoling Mutant, Gloom Mutant, Gloom Mutant, Typhon's Mutant, Typhon's Mutant, Dream Mutator, Dream Mutator
2.01 (201 / 10000)
2.01: Constantine, Bolt Crag #5, Tempest Citadel #2
Deck improved: S6-F9-cD-F9+joS+i 0 [4381] Bolt Crag -> 1 [5795] Tazerious: 2.05 (205 / 10000)
2.05: Constantine, Bolt Crag, Tazerious, Bolt Crag #3, Tempest Citadel #2
Deck improved: S6-F9+koS-F9oS 1 [5795] Tazerious -> 5 [4381] Bolt Crag: 2.12 (212 / 10000)
2.12: Constantine, Bolt Crag #4, Tempest Citadel, Bolt Crag, Tempest Citadel
Deck improved: S6-F9+koS+i-F9 5 [4381] Bolt Crag -> 6 [4381] Bolt Crag: 2.82 (282 / 10000)
2.82: Constantine, Bolt Crag #4, Tempest Citadel #2, Bolt Crag
Deck improved: S6-F9+i-c9-F9+ioS+i-F9 7 -void- -> 2 [5853] Arch Nova: 2.88 (288 / 10000)
2.88: Constantine, Bolt Crag #2, Arch Nova, Bolt Crag #2, Tempest Citadel #2, Bolt Crag
Deck improved: S6-F9-cD-F9-c9-F9+ioS+i-F9 8 -void- -> 1 [5795] Tazerious: 3.21 (321 / 10000)
3.21: Constantine, Bolt Crag, Tazerious, Bolt Crag, Arch Nova, Bolt Crag #2, Tempest Citadel #2, Bolt Crag
Deck improved: S6-F9-cD-F9-c9-F9+ioS+i-fN-F9 9 -void- -> 8 [5997] Insanitius: 3.47 (347 / 10000)
3.47: Constantine, Bolt Crag, Tazerious, Bolt Crag, Arch Nova, Bolt Crag #2, Tempest Citadel #2, Insanitius, Bolt Crag
Deck improved: S6-F9-cD-F9-c9-F9+ioS+i-F9-fN 9 [4381] Bolt Crag -> 8 [4381] Bolt Crag: 3.84 (384 / 10000)
3.84: Constantine, Bolt Crag, Tazerious, Bolt Crag, Arch Nova, Bolt Crag #2, Tempest Citadel #2, Bolt Crag, Insanitius
Deck improved: S6-F9+i-c9-F9+ikOoS+i-F9-fN 1 [5795] Tazerious -> 5 [2318] Sacred Sanctuary: 4.21 (421 / 10000)
4.21: Constantine, Bolt Crag #2, Arch Nova, Bolt Crag #2, Sacred Sanctuary, Tempest Citadel #2, Bolt Crag, Insanitius
Deck improved: S6-F9+kkOoS+i-GV-F9-fN 2 [5853] Arch Nova -> 7 [4405] Ayrkrane Vik: 5.97 (597 / 10000)
5.97: Constantine, Bolt Crag #4, Sacred Sanctuary, Tempest Citadel #2, Ayrkrane Vik, Bolt Crag, Insanitius
Deck improved: S6-F9+jkOoS-F9oS-GV-F9-fN 2 [4381] Bolt Crag -> 5 [4381] Bolt Crag: 5.98 (598 / 10000)
5.98: Constantine, Bolt Crag #3, Sacred Sanctuary, Tempest Citadel, Bolt Crag, Tempest Citadel, Ayrkrane Vik, Bolt Crag, Insanitius
Deck improved: S6-F9+joS-F9oSkO-GV-F9-fN 3 [2318] Sacred Sanctuary -> 6 [2318] Sacred Sanctuary: 6.1 (610 / 10000)
6.1: Constantine, Bolt Crag #3, Tempest Citadel, Bolt Crag, Tempest Citadel, Sacred Sanctuary, Ayrkrane Vik, Bolt Crag, Insanitius
Deck improved: S6-F9+joS+ikO-F9-GV-F9-fN 4 [4381] Bolt Crag -> 6 [4381] Bolt Crag: 6.31 (631 / 10000)
6.31: Constantine, Bolt Crag #3, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag, Ayrkrane Vik, Bolt Crag, Insanitius
Deck improved: S6-F9+joS+ikO-F9-c9-F9-fN 7 [4405] Ayrkrane Vik -> 7 [5853] Arch Nova: 6.5 (650 / 10000)
6.5: Constantine, Bolt Crag #3, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag, Arch Nova, Bolt Crag, Insanitius
Deck improved: S6-F9+joS+ikO-F9+i-c9-fN 7 [5853] Arch Nova -> 8 [5853] Arch Nova: 6.77 (677 / 10000)
6.77: Constantine, Bolt Crag #3, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag #2, Arch Nova, Insanitius
Deck improved: S6-F9+koS+ikO-F9-c9-fN 7 [4381] Bolt Crag -> 0 [4381] Bolt Crag: 6.92 (692 / 10000)
6.92: Constantine, Bolt Crag #4, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag, Arch Nova, Insanitius
Deck improved: S6-F9+koS+ikO-F9-cD-fN 8 [5853] Arch Nova -> 8 [5795] Tazerious: 7.38 (738 / 10000)
7.38: Constantine, Bolt Crag #4, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag, Tazerious, Insanitius
Deck improved: S6-F9+koS+ikO-F9-c9-cD 9 [5997] Insanitius -> 8 [5853] Arch Nova: 7.54 (754 / 10000)
7.54: Constantine, Bolt Crag #4, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag, Arch Nova, Tazerious
Evaluated 1250 decks (1681634 + 1362939 simulations).
Optimized Deck: 7.54: Constantine, Bolt Crag #4, Tempest Citadel #2, Sacred Sanctuary, Bolt Crag, Arch Nova, Tazerious
</pre>

##Version 2.4.0
* [FIX] jam all - [Issue#30](https://github.com/zachanassian/tu_optimize/issues/30)
* Added current <code>cards.xml</code> and <code>missions.xml</code> - mission Infested Rastax
Expand Down
5 changes: 5 additions & 0 deletions data/customdecks_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,8 @@ GT126k97: Typhon Vex, Bolt Crag, Charincinerator, Classified Rig, Delphan the Fu
GT126k98: Typhon Vex, Bolt Crag, Charincinerator, Havoc Genesis, Judgment Nova, Razogoth's Majesty, Sacred Sanctuary (2), Sculpted Aegis, Veiled Defiler,
GT126k99: Typhon Vex, Bolt Crag, Heart Devourer (4), Mobile Encampment, Promethium Solidus, Sculpted Aegis, Tempest Citadel, Yobedysseus,
GT126k: /^GT126k\d\d$/
Razogoth Mutant-1: [1337],[6367],[6367],[6373],[6373],[6379],[6379],[6391],[6391],[6385],[6385]
Razogoth Mutant-2: [1338],[6368],[6368],[6374],[6374],[6380],[6380],[6392],[6392],[6386],[6386]
Razogoth Mutant-3: [1339],[6369],[6369],[6375],[6375],[6381],[6381],[6393],[6393],[6387],[6387]
Razogoth Mutant-4: [1340],[6370],[6370],[6376],[6376],[6382],[6382],[6394],[6394],[6388],[6388]
Razogoth Mutant-5: [1341],[6371],[6371],[6377],[6377],[6383],[6383],[6395],[6395],[6389],[6389]
66 changes: 43 additions & 23 deletions read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,53 @@ unsigned read_custom_decks(Decks& decks, Cards& cards, std::string filename)
return(0);
}

void add_owned_card(Cards& cards, std::map<unsigned, unsigned>& owned_cards, std::string& card_spec, std::map<unsigned, unsigned>& buyable_cards)
{
unsigned card_id{0};
unsigned card_num{1};
char num_sign{0};
char mark{0};
parse_card_spec(cards, card_spec, card_id, card_num, num_sign, mark);
assert(mark == 0);
if(num_sign == 0)
{
owned_cards[card_id] = card_num;
}
else if(num_sign == '+')
{
owned_cards[card_id] += card_num;
}
else if(num_sign == '-')
{
owned_cards[card_id] = owned_cards[card_id] > card_num ? owned_cards[card_id] - card_num : 0;
}
else if(num_sign == '$')
{
buyable_cards[card_id] = card_num;
}
}

void read_owned_cards(Cards& cards, std::map<unsigned, unsigned>& owned_cards, std::map<unsigned, unsigned>& buyable_cards, const char *filename)
{
std::ifstream owned_file{filename};
if(!owned_file.good())
{
std::cerr << "Warning: Owned cards file '" << filename << "' does not exist.\n";
// try parse the string as a cards instead of as a filename
try
{
std::string card_list(filename);
boost::tokenizer<boost::char_delimiters_separator<char>> card_tokens{card_list, boost::char_delimiters_separator<char>{false, ":,", ""}};
auto token_iter = card_tokens.begin();
for (; token_iter != card_tokens.end(); ++token_iter)
{
std::string card_spec(*token_iter);
add_owned_card(cards, owned_cards, card_spec, buyable_cards);
}
}
catch (std::exception& e)
{
std::cerr << "Warning: Failed to parse owned cards: '" << filename << "' is neither a file nor a valid set of cards (" << e.what() << ")" << std::endl;
}
return;
}
unsigned num_line(0);
Expand All @@ -326,28 +367,7 @@ void read_owned_cards(Cards& cards, std::map<unsigned, unsigned>& owned_cards, s
}
try
{
unsigned card_id{0};
unsigned card_num{1};
char num_sign{0};
char mark{0};
parse_card_spec(cards, card_spec, card_id, card_num, num_sign, mark);
assert(mark == 0);
if(num_sign == 0)
{
owned_cards[card_id] = card_num;
}
else if(num_sign == '+')
{
owned_cards[card_id] += card_num;
}
else if(num_sign == '-')
{
owned_cards[card_id] = owned_cards[card_id] > card_num ? owned_cards[card_id] - card_num : 0;
}
else if(num_sign == '$')
{
buyable_cards[card_id] = card_num;
}
add_owned_card(cards, owned_cards, card_spec, buyable_cards);
}
catch(std::exception& e)
{
Expand Down
2 changes: 2 additions & 0 deletions tu_optimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,8 @@ void usage(int argc, char** argv)
" -o: restrict to the owned cards listed in \"data/ownedcards.txt\".\n"
" -o=<filename>: restrict to the owned cards listed in <filename>.\n"
" example: -o=data/mycards.txt.\n"
" -o=<cards>: restrict to the owned cards specified.\n"
" example: -o=\"Sacred Equalizer#2, Infantry\".\n"
//" fund <num>: fund <num> gold to buy/upgrade cards. prices are specified in ownedcards file.\n"
" target <num>: stop as soon as the score reaches <num>.\n"
//" -u: don't upgrade owned cards. (by default, upgrade owned cards when needed)\n"
Expand Down
2 changes: 1 addition & 1 deletion tyrant.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef TYRANT_H_INCLUDED
#define TYRANT_H_INCLUDED

#define TU_OPTIMIZER_VERSION "2.4.0"
#define TU_OPTIMIZER_VERSION "2.5.0"
#define NDEBUG

#include <string>
Expand Down

0 comments on commit 85717ec

Please sign in to comment.