From 28e855f5424df395dd1ba98354a53536d4598d47 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 30 May 2023 00:22:29 -0400 Subject: fix djn again, and pre-dec / post-inc; few other changes --- score/main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'score') 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 [[noreturn]] void usage(const char *argv0) { - std::cerr << "usage: " << argv0 << " \n"; + std::cout << "usage: " << argv0 << " \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(w1)) { - std::cerr << "error compiling " << argv[1] << ": " << std::get(w1) << '\n'; + std::cout << "error compiling " << argv[1] << ": " << std::get(w1) << '\n'; return 1; } if (std::holds_alternative(w2)) { - std::cerr << "error compiling " << argv[2] << ": " << std::get(w2) << '\n'; + std::cout << "error compiling " << argv[2] << ": " << std::get(w2) << '\n'; return 1; } @@ -50,6 +60,9 @@ int main(int argc, const char **argv) { ws[0] = std::get(w1); ws[1] = std::get(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, -- cgit v1.2.3