22
33std::ostringstream all_logs;
44
5+ // make global object for holding all ids of attackers whose abilities activated
6+
57void init_constants () {
68 // All the attacker types
79 std::cin >> Constants::NO_OF_ATTACKER_TYPES;
810
911 std::unordered_map<size_t , Attributes> attacker_type_to_attributes;
1012 for (size_t i = 1 ; i <= Constants::NO_OF_ATTACKER_TYPES; i++) {
11- unsigned hp, range, attack_power, speed, price, is_aerial , weight;
12- std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial >> weight;
13+ unsigned hp, range, attack_power, speed, price, is_aerial , weight, num_ability_turns, ability_activation_cost ;
14+ std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial >> weight >> num_ability_turns >> ability_activation_cost ;
1315 attacker_type_to_attributes.insert (
14- std::make_pair (i, Attributes (hp, range, attack_power, speed, price, is_aerial,weight)));
16+ std::make_pair (i, Attributes (hp, range, attack_power, speed, price, is_aerial,weight, num_ability_turns,ability_activation_cost )));
1517 }
1618 Constants::ATTACKER_TYPE_ATTRIBUTES = attacker_type_to_attributes;
1719
@@ -23,7 +25,7 @@ void init_constants() {
2325 unsigned hp, range, attack_power, speed, price, is_aerial;
2426 std::cin >> hp >> range >> attack_power >> speed >> price >> is_aerial;
2527 defender_type_to_attributes.insert (
26- std::make_pair (i, Attributes (hp, range, attack_power, speed, price, is_aerial,0 )));
28+ std::make_pair (i, Attributes (hp, range, attack_power, speed, price, is_aerial,0 , 0 , 0 )));
2729 }
2830 Constants::DEFENDER_TYPE_ATTRIBUTES = defender_type_to_attributes;
2931}
@@ -47,6 +49,7 @@ void output(size_t turn_no, Game &game) {
4749 // Game details logged
4850 const auto &spawn_positions = game.get_spawn_positions ();
4951 const auto &player_set_targets = game.get_player_set_targets ();
52+ const auto &ability_activations = game.get_ability_activations ();
5053
5154 std::cout << spawn_positions.size () << std::endl;
5255 for (const auto &entry : spawn_positions) {
@@ -58,6 +61,11 @@ void output(size_t turn_no, Game &game) {
5861 for (const auto &entry : player_set_targets) {
5962 std::cout << entry.first << " " << entry.second << std::endl;
6063 }
64+
65+ std::cout << ability_activations.size () << std::endl;
66+ for (const auto &attacker_id : ability_activations) {
67+ std::cout << attacker_id << std::endl;
68+ }
6169}
6270
6371void dump_logs (State &state, Game &game) {}
@@ -71,9 +79,9 @@ State next_state(size_t cur_turn_no) {
7179 std::cin >> no_of_active_attackers;
7280 std::vector<Attacker> attackers;
7381 for (size_t i = 0 ; i < no_of_active_attackers; i++) {
74- size_t id, hp, x, y, type;
75- std::cin >> id >> x >> y >> type >> hp;
76- attackers.push_back (Attacker (id, hp, type, Position (x, y)));
82+ size_t id, hp, x, y, type, is_ability_active ;
83+ std::cin >> id >> x >> y >> type >> hp >> is_ability_active ;
84+ attackers.push_back (Attacker (id, hp, type, Position (x, y), is_ability_active ));
7785 }
7886
7987 std::cin >> no_of_active_defenders;
@@ -97,17 +105,17 @@ PvPState pvp_next_state(size_t cur_turn_no) {
97105 std::cin >> no_of_active_attackers;
98106 std::vector<Attacker> attackers;
99107 for (size_t i = 0 ; i < no_of_active_attackers; i++) {
100- size_t id, hp, x, y, type;
101- std::cin >> id >> x >> y >> type >> hp;
102- attackers.push_back (Attacker (id, hp, type, Position (x, y)));
108+ size_t id, hp, x, y, type, is_ability_active ;
109+ std::cin >> id >> x >> y >> type >> hp >> is_ability_active ;
110+ attackers.push_back (Attacker (id, hp, type, Position (x, y), is_ability_active ));
103111 }
104112
105113 std::cin >> no_of_opponent_attackers;
106114 std::vector<Attacker> opponent_attackers;
107115 for (size_t i = 0 ; i < no_of_opponent_attackers; i++) {
108- size_t id, hp, x, y, type;
109- std::cin >> id >> x >> y >> type >> hp;
110- opponent_attackers.push_back (Attacker (id, hp, type, Position (x, y)));
116+ size_t id, hp, x, y, type, is_ability_active ;
117+ std::cin >> id >> x >> y >> type >> hp >> is_ability_active ;
118+ opponent_attackers.push_back (Attacker (id, hp, type, Position (x, y), is_ability_active ));
111119 }
112120
113121 return {move (attackers), move (opponent_attackers), Constants::PVP_FIXED_COINS, cur_turn_no + 1 };
0 commit comments