From b5e291c69ca8638c26480770783cd1e3ef7f4840 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 3 Dec 2018 21:43:19 +0100 Subject: [PATCH] test added for Crystal Round Table sizes --- crystal.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/crystal.cpp b/crystal.cpp index d8e6819a..f7369da4 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -833,6 +833,36 @@ void set_crystal(int sides) { ginf[gCrystal].distlimit = distlimit_table[sides]; } +void test_crt() { + start_game(); + auto m = crystal_map(); + manual_celllister cl; + cl.add(m->camelot_center); + for(int i=0; igamestart()); + if(c1->land == laCamelot && c1->wall == waNone) + cl.add(c1); + } + println(hlog, "actual = ", isize(cl.lst), " algorithm = ", get_table_volume()); + if(its(isize(cl.lst)) != get_table_volume()) exit(1); + } + +void unit_test_tables() { + stop_game(); + specialland = laCamelot; + set_crystal(5); + test_crt(); + set_crystal(6); + test_crt(); + set_crystal(5); set_variation(eVariation::bitruncated); + test_crt(); + set_crystal(6); set_variation(eVariation::bitruncated); + test_crt(); + set_crystal(6); set_variation(eVariation::bitruncated); set_variation(eVariation::bitruncated); + test_crt(); + } + int readArgs() { using namespace arg; @@ -853,6 +883,9 @@ int readArgs() { surface::sh = surface::dsCrystal; rug::good_shape = true; } + else if(argis("-test:crt")) { + test_crt(); + } else return 1; return 0; } @@ -888,7 +921,8 @@ void show() { } auto crystalhook = addHook(hooks_args, 100, readArgs) - + addHook(hooks_drawcell, 100, crystal_cell); + + addHook(hooks_drawcell, 100, crystal_cell) + + addHook(hooks_tests, 200, unit_test_tables); map, bignum> volume_memo;