From 9e286e01d45cc5b5d0e70bb03ed371e821998fdf Mon Sep 17 00:00:00 2001 From: brikikeks Date: Sat, 16 Sep 2017 01:43:30 +0200 Subject: [PATCH 1/4] Wworkaround for Number of Successes argument is x, but must be <= Number of Trials ! --- tyrant_optimize.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tyrant_optimize.cpp b/tyrant_optimize.cpp index 29d32fff..42c4dc03 100644 --- a/tyrant_optimize.cpp +++ b/tyrant_optimize.cpp @@ -569,8 +569,12 @@ FinalResults compute_score(const EvaluatedResults& results, std::ve final.wins += results.first[index].wins * factors[index]; final.draws += results.first[index].draws * factors[index]; final.losses += results.first[index].losses * factors[index]; - auto lower_bound = boost::math::binomial_distribution<>::find_lower_bound_on_p(results.second, results.first[index].points / max_possible, 1 - confidence_level) * max_possible; - auto upper_bound = boost::math::binomial_distribution<>::find_upper_bound_on_p(results.second, results.first[index].points / max_possible, 1 - confidence_level) * max_possible; + + // workaround for problem with wrong argument values: Number of Successes argument is x, but must be <= Number of Trials ! + auto successes = results.first[index].points / max_possible; + successes = successes > results.second ? results.second : successes; + auto lower_bound = boost::math::binomial_distribution<>::find_lower_bound_on_p(results.second, successes, 1 - confidence_level) * max_possible; + auto upper_bound = boost::math::binomial_distribution<>::find_upper_bound_on_p(results.second, successes, 1 - confidence_level) * max_possible; if (use_harmonic_mean) { final.points += factors[index] / results.first[index].points; From e982a52bdcb1aad9a1067c266aca05d82c29cde0 Mon Sep 17 00:00:00 2001 From: brikikeks Date: Sat, 16 Sep 2017 01:46:40 +0200 Subject: [PATCH 2/4] v2.54.3 On-Attack v2.54.3 with On-Attack triggers implementation from APN-Pucky https://github.com/APN-Pucky/tyrant_optimize/releases/tag/v2.54.2 --- card.h | 4 ++++ cards.cpp | 6 ++++++ sim.cpp | 17 ++++++++++++++++- sim.h | 2 ++ tyrant.cpp | 2 +- tyrant.h | 4 +++- update_xml.sh | 2 +- xml.cpp | 2 ++ 8 files changed, 35 insertions(+), 4 deletions(-) diff --git a/card.h b/card.h index ae676a3c..33fa01e2 100644 --- a/card.h +++ b/card.h @@ -23,6 +23,8 @@ class Card unsigned m_set; std::vector m_skills; std::vector m_skills_on_play; + //APN + std::vector m_skills_on_attacked; std::vector m_skills_on_death; unsigned m_skill_value[Skill::num_skills]; Skill::Trigger m_skill_trigger[Skill::num_skills]; @@ -48,6 +50,8 @@ class Card m_set(0), m_skills(), m_skills_on_play(), + //APN + m_skills_on_attacked(), m_skills_on_death(), m_type(CardType::assault), m_category(CardCategory::normal), diff --git a/cards.cpp b/cards.cpp index 41cc0ed1..ab942b31 100644 --- a/cards.cpp +++ b/cards.cpp @@ -191,6 +191,10 @@ void Card::add_skill(Skill::Trigger trigger, Skill::Skill id, unsigned x, Factio case Skill::Trigger::play: storage = &m_skills_on_play; break; + //APN + case Skill::Trigger::attacked: + storage = &m_skills_on_attacked; + break; case Skill::Trigger::death: storage = &m_skills_on_death; break; @@ -205,6 +209,8 @@ void Card::add_skill(Skill::Trigger trigger, Skill::Skill id, unsigned x, Factio m_skills.erase(std::remove_if(m_skills.begin(), m_skills.end(), pred), m_skills.end()); m_skills_on_play.erase(std::remove_if(m_skills_on_play.begin(), m_skills_on_play.end(), pred), m_skills_on_play.end()); m_skills_on_death.erase(std::remove_if(m_skills_on_death.begin(), m_skills_on_death.end(), pred), m_skills_on_death.end()); + //APN + m_skills_on_attacked.erase(std::remove_if(m_skills_on_attacked.begin(), m_skills_on_attacked.end(), pred), m_skills_on_attacked.end()); } // add a new one storage->push_back({id, x, y, n, c, s, s2, all, card_id}); diff --git a/sim.cpp b/sim.cpp index 8631aa13..78ae1c92 100644 --- a/sim.cpp +++ b/sim.cpp @@ -258,6 +258,8 @@ std::string card_description(const Cards& cards, const Card* c) if (c->m_faction != allfactions) { desc += " " + faction_names[c->m_faction]; } for (auto& skill: c->m_skills_on_play) { desc += ", " + skill_description(cards, skill, Skill::Trigger::play); } for (auto& skill: c->m_skills) { desc += ", " + skill_description(cards, skill, Skill::Trigger::activate); } + //APN + for (auto& skill: c->m_skills_on_attacked) { desc += ", " + skill_description(cards, skill, Skill::Trigger::attacked); } for (auto& skill: c->m_skills_on_death) { desc += ", " + skill_description(cards, skill, Skill::Trigger::death); } return desc; } @@ -312,12 +314,15 @@ std::string CardStatus::description() const if (m_enraged) { desc += ", enraged " + to_string(m_enraged); } if (m_entrapped) { desc += ", entrapped " + to_string(m_entrapped); } // if(m_step != CardStep::none) { desc += ", Step " + to_string(static_cast(m_step)); } - const Skill::Trigger s_triggers[] = { Skill::Trigger::play, Skill::Trigger::activate, Skill::Trigger::death }; + //APN + const Skill::Trigger s_triggers[] = { Skill::Trigger::play, Skill::Trigger::activate, Skill::Trigger::death , Skill::Trigger::attacked}; for (const Skill::Trigger& trig: s_triggers) { std::vector card_skills( (trig == Skill::Trigger::play) ? m_card->m_skills_on_play : (trig == Skill::Trigger::activate) ? m_card->m_skills : + //APN + (trig == Skill::Trigger::attacked) ? m_card->m_skills_on_attacked : (trig == Skill::Trigger::death) ? m_card->m_skills_on_death : std::vector()); @@ -344,6 +349,7 @@ std::string CardStatus::description() const { desc += ", " + ( (trig == Skill::Trigger::play) ? "(On Play)" : + (trig == Skill::Trigger::attacked) ? "(On Attacked)" : (trig == Skill::Trigger::death) ? "(On Death)" : std::string("")) + skill_names[ss.id] + skill_desc; } @@ -1116,6 +1122,15 @@ struct PerformAttack attack_damage(); if (__builtin_expect(fd->end, false)) { return att_dmg; } damage_dependant_pre_oa(); + //APN + // resolve On-Attacked skills + for (const auto& ss: def_status->m_card->m_skills_on_attacked) + { + _DEBUG_MSG(1, "On Attacked %s: Preparing (tail) skill %s\n", + status_description(def_status).c_str(), skill_description(fd->cards, ss).c_str()); + fd->skill_queue.emplace_back(def_status, ss); + resolve_skill(fd); + } // Enemy Skill: Counter if (def_status->has_skill(Skill::counter)) diff --git a/sim.h b/sim.h index e30f05b0..b0a9aac0 100644 --- a/sim.h +++ b/sim.h @@ -377,7 +377,9 @@ extern std::string card_name_by_id_safe(const Cards& cards, const unsigned card_ template inline std::string skill_description(const Cards& cards, const _SkillSpec& s, Skill::Trigger trig) { + //APN return ((trig == Skill::Trigger::play) ? "(On Play)" : + (trig == Skill::Trigger::attacked) ? "(On Attacked)" : (trig == Skill::Trigger::death) ? "(On Death)" : "") + skill_names[s.id] + (s.card_id == 0 ? "" : " " + card_name_by_id_safe(cards, s.card_id) + " id[" + to_string(s.card_id) + "]") + diff --git a/tyrant.cpp b/tyrant.cpp index 28b9afdb..54ac3b29 100644 --- a/tyrant.cpp +++ b/tyrant.cpp @@ -37,7 +37,7 @@ const std::string skill_names[Skill::num_skills] = const std::string skill_trigger_names[Skill::num_triggers] = { - "activate", "play", "death", + "activate", "play", "attacked","death", }; const std::string passive_bge_names[PassiveBGE::num_passive_bges] = diff --git a/tyrant.h b/tyrant.h index 40c945c8..7d2ee32b 100644 --- a/tyrant.h +++ b/tyrant.h @@ -1,7 +1,7 @@ #ifndef TYRANT_H_INCLUDED #define TYRANT_H_INCLUDED -#define TYRANT_OPTIMIZER_VERSION "2.54.2" +#define TYRANT_OPTIMIZER_VERSION "2.54.3" #include #include @@ -63,6 +63,8 @@ enum Trigger { activate, play, + //APN + attacked, death, num_triggers }; diff --git a/update_xml.sh b/update_xml.sh index a7ccb7e4..b393a6fa 100755 --- a/update_xml.sh +++ b/update_xml.sh @@ -1,4 +1,4 @@ #!/bin/bash -for fn in fusion_recipes_cj2 missions levels skills_set `seq -f cards_section_%g 1 13` ; do +for fn in fusion_recipes_cj2 missions levels skills_set `seq -f cards_section_%g 1 14` ; do curl http://mobile$1.tyrantonline.com/assets/${fn}.xml -R -z data/${fn}.xml -o data/${fn}.xml done diff --git a/xml.cpp b/xml.cpp index c76bc4d1..fe9c803c 100644 --- a/xml.cpp +++ b/xml.cpp @@ -293,6 +293,8 @@ void parse_card_node(Cards& all_cards, Card* card, xml_node<>* card_node) { // inherit no skill if there is skill node card->m_skills.clear(); card->m_skills_on_play.clear(); + //APN + card->m_skills_on_attacked.clear(); card->m_skills_on_death.clear(); memset(card->m_skill_value, 0, sizeof card->m_skill_value); memset(card->m_skill_trigger, 0, sizeof card->m_skill_trigger); From 8932390266f519628c52928c8f9c90d72dab4609 Mon Sep 17 00:00:00 2001 From: brikikeks Date: Fri, 22 Sep 2017 00:37:54 +0200 Subject: [PATCH 3/4] v2.54.3 --- SimpleTUOptimizeStarter.ahk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimpleTUOptimizeStarter.ahk b/SimpleTUOptimizeStarter.ahk index c0fbfa74..0de1c74e 100644 --- a/SimpleTUOptimizeStarter.ahk +++ b/SimpleTUOptimizeStarter.ahk @@ -94,7 +94,7 @@ Gui, Add, Edit, vSimOptions r1 xs w600, %IniSimOptions% Gui, Add, Button, default r2 w100 x100 y+15 section, Simulate Gui, Add, Checkbox, vx86 Checked%Inix86%, x86 (32-bit) Gui, Add, Button, r2 w100 ys xs+200, Exit -Gui, Show,, Simple Tyrant Unleashed Optimize Starter v2.54.2 +Gui, Show,, Simple Tyrant Unleashed Optimize Starter v2.54.3 return ButtonSimulate: From c1f8ac7558c8eb90480eccf8258867f6e988877c Mon Sep 17 00:00:00 2001 From: brikikeks Date: Fri, 22 Sep 2017 01:03:43 +0200 Subject: [PATCH 4/4] v2.54.5 Door of Khensu Raid --- SimpleTUOptimizeStarter.ahk | 2 +- data/raids.xml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/SimpleTUOptimizeStarter.ahk b/SimpleTUOptimizeStarter.ahk index 0de1c74e..d1315d30 100644 --- a/SimpleTUOptimizeStarter.ahk +++ b/SimpleTUOptimizeStarter.ahk @@ -94,7 +94,7 @@ Gui, Add, Edit, vSimOptions r1 xs w600, %IniSimOptions% Gui, Add, Button, default r2 w100 x100 y+15 section, Simulate Gui, Add, Checkbox, vx86 Checked%Inix86%, x86 (32-bit) Gui, Add, Button, r2 w100 ys xs+200, Exit -Gui, Show,, Simple Tyrant Unleashed Optimize Starter v2.54.3 +Gui, Show,, Simple Tyrant Unleashed Optimize Starter v2.54.5 return ButtonSimulate: diff --git a/data/raids.xml b/data/raids.xml index 8c6d31b1..fe6956fe 100644 --- a/data/raids.xml +++ b/data/raids.xml @@ -645,6 +645,22 @@ + + + 41 + Door of Khensu Raid + 25782 + + 26 + + + 55790 + 55800 + 55810 + + + +