bonefix.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include "../serialize.h"
  4. #include "../common_types.h"
  5. #include "../common.h"
  6. #include "../bones.h"
  7. #include "../nlp.h"
  8. int main(int argc, char** argv) {
  9. try {
  10. std::unordered_map<bones::key_t,double> money;
  11. try {
  12. serialize::Source source("bones.dat");
  13. while (1) {
  14. try {
  15. bones::key_t key;
  16. bones::pt xy;
  17. bones::bone_t bone;
  18. bones::session_t sess;
  19. serialize::read(source, key);
  20. serialize::read(source, xy);
  21. serialize::read(source, bone);
  22. serialize::read(source, sess);
  23. if (bone.cause.name == "VICTORY")
  24. continue;
  25. double w = std::max(-6000.0, bone.worth);
  26. money[key] += w;
  27. } catch (...) {
  28. std::cout << "oops" << std::endl;
  29. break;
  30. }
  31. }
  32. std::unordered_map<bones::key_t,double> money2;
  33. for (const auto& i : money) {
  34. std::cout << i.first.worldx << "," << i.first.worldy << ":" << i.first.worldz << " = " << i.second << std::endl;
  35. money2[bones::key_t(i.first.worldx, i.first.worldy, 0)] += i.second;
  36. }
  37. std::cout << "----" << std::endl;
  38. for (const auto& i : money2) {
  39. std::cout << i.first.worldx << "," << i.first.worldy << " = " << i.second << std::endl;
  40. }
  41. } catch (...) {
  42. }
  43. } catch (std::exception& e) {
  44. std::cerr << "Fatal error: " << e.what() << std::endl;
  45. return 1;
  46. } catch (...) {
  47. std::cerr << "Unknown fatal error." << std::endl;
  48. return 1;
  49. }
  50. return 0;
  51. }