diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-20 00:11:23 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-20 00:11:23 +0100 |
commit | 2eef87c8970db643c4ef09e0fd9e8110c8193043 (patch) | |
tree | 78a9bcc7932ab8edb8669ded755ee2c81afc0912 /gst/gst.c | |
parent | c135f85fcdc1eeedd04e0c9e9f626b907500f20a (diff) |
finish condition and bad cost function
Diffstat (limited to 'gst/gst.c')
-rw-r--r-- | gst/gst.c | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -66,6 +66,24 @@ void gst_tobattle (gamestate *gst) { gst->starttime = FLT_MAX; gst->turn = 0; gst->coveredtime = 0; + gst->turn_until_finish = 5; + gst->over = 0; +} + +void gst_toeditor(gamestate *gst) { + gst->playernum = 1; +} + +int gst_check_victory (gamestate *gst) { + int counts[gst->playernum], max=-1, imax = -1; + for (int i=0; i<gst->ar.uslen; i++) { + counts[gst->ar.us[i].owner] ++; + if (counts[gst->ar.us[i].owner] > max) { + imax = gst->ar.us[i].owner; + max = counts[gst->ar.us[i].owner]; + } + } + return imax; } void gst_process (gamestate *gst, infos *info, float t) { @@ -76,8 +94,15 @@ void gst_process (gamestate *gst, infos *info, float t) { gst->turn ++; map *m; army *ar; gst_get_maparmy(gst, &m, &ar); - army_move(info, ar, m); - army_fire(info, ar, m); + int move = army_move(info, ar, m); + int fire = army_fire(info, ar, m); army_upkeep(info, ar, m); + printf("%d, %d\n", move, fire); + if (move == 0 && fire == 0) { + gst->turn_until_finish--; + } else { gst->turn_until_finish = 5; } + if (gst->turn_until_finish <= 0) { + gst->over = 1; + } } }
\ No newline at end of file |