diff options
author | Benji Dial <benji@benjidial.net> | 2023-05-30 00:22:29 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-05-30 00:22:29 -0400 |
commit | 28e855f5424df395dd1ba98354a53536d4598d47 (patch) | |
tree | 21e17429958fedf754ac7aad59377f6fdac2a08f /score | |
parent | e56afe88854d3da8d0d9d5c836da6024b02a9bac (diff) | |
download | lib94-28e855f5424df395dd1ba98354a53536d4598d47.tar.gz |
fix djn again, and pre-dec / post-inc; few other changes
Diffstat (limited to 'score')
-rw-r--r-- | score/main.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/score/main.cpp b/score/main.cpp index 1b29107..88536bb 100644 --- a/score/main.cpp +++ b/score/main.cpp @@ -3,10 +3,20 @@ #include <fstream> [[noreturn]] void usage(const char *argv0) { - std::cerr << "usage: " << argv0 << " <first warrior> <second warrior> <number of rounds> <steps until tie>\n"; + std::cout << "usage: " << argv0 << " <first warrior> <second warrior> <number of rounds> <steps until tie>\n"; exit(1); } +void print_warrior(const lib94::warrior *w) { + std::cerr << ";name " << w->name << '\n'; + std::cerr << ";author " << w->author << '\n'; + if (w->org != 0) + std::cerr << "org " << w->org << '\n'; + for (const auto &i : w->instructions) + std::cerr << lib94::instruction_to_string(i) << '\n'; + std::cerr << '\n'; +} + int main(int argc, const char **argv) { if (argc != 5) usage(argv[0]); @@ -37,12 +47,12 @@ int main(int argc, const char **argv) { auto w2 = lib94::compile_warrior(source2); if (std::holds_alternative<std::string>(w1)) { - std::cerr << "error compiling " << argv[1] << ": " << std::get<std::string>(w1) << '\n'; + std::cout << "error compiling " << argv[1] << ": " << std::get<std::string>(w1) << '\n'; return 1; } if (std::holds_alternative<std::string>(w2)) { - std::cerr << "error compiling " << argv[2] << ": " << std::get<std::string>(w2) << '\n'; + std::cout << "error compiling " << argv[2] << ": " << std::get<std::string>(w2) << '\n'; return 1; } @@ -50,6 +60,9 @@ int main(int argc, const char **argv) { ws[0] = std::get<lib94::warrior *>(w1); ws[1] = std::get<lib94::warrior *>(w2); + print_warrior(ws[0]); + print_warrior(ws[1]); + unsigned w1_wins = 0; unsigned w2_wins = 0; @@ -57,6 +70,8 @@ int main(int argc, const char **argv) { for (unsigned round_number = 0; round_number < round_count; ++round_number) { + std::cerr << "round " << round_number + 1 << "\x1b[0G"; + lib94::clear_core({ .op = lib94::DAT, .mod = lib94::F, .amode = lib94::DIRECT, .bmode = lib94::DIRECT, |