diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-03-02 18:26:39 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-03-02 18:26:39 +0100 |
commit | a988df656b4d37dfa2472a4cde390185cfcea8b5 (patch) | |
tree | 262b48644a5aff086b6ead687d0f2297bf946c2b /test/test_gst.c | |
parent | 7932daa7e308b1c92ab97dde00fcc0ed790895a6 (diff) |
test foundation and functional reimplementation of cost function
Diffstat (limited to 'test/test_gst.c')
-rw-r--r-- | test/test_gst.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/test_gst.c b/test/test_gst.c new file mode 100644 index 0000000..75e2606 --- /dev/null +++ b/test/test_gst.c @@ -0,0 +1,53 @@ +#include <stdio.h> + +#include "test.h" + +#include "../gst/fxs.h" +#include "../gst/gst.h" + +int test_gst_mirror_match (infos *info, int n); + + +int test_gst_run (infos *info) { + int result = 0; + for (int i=0; i<1; i++) { + result += test_gst_mirror_match(info, i); + } + return result; +} + +int test_gst_mirror_match (infos *info, int n) { + if(TEST_VERBOSE) printf("test_gst: mirror match __test%d\n", n); + fxs fx; + fx_init(&fx); + gamestate gst; + gst_init(&gst); + + char name[64]; sprintf(name, "hidden/__test%d", n); + info_load_army(gst.army_bp+0, name); + info_load_army(gst.army_bp+1, name); + gst.playernum = 2; + gst_tobattle(&gst, info); + + float t = 0; int i=0; + for (; i < 2000; i++) { + gst_process(&gst, info, &fx, t); + t += gst.turnspeed; + if (gst.over == 1) { + break; + } + } + if (i < 2000) { + if(TEST_VERBOSE) printf("test_gst: %d turns\n", i); + int winner = gst_check_victory(&gst); + if (winner == -1) { + if(TEST_VERBOSE) printf("test_gst success: draw\n"); + } else { + printf("test_gst failed: not draw (%d)\n", winner); + return 1; + } + gst_destroy(&gst); + return 0; + } + return 1; +}
\ No newline at end of file |