Created
July 30, 2014 04:55
-
-
Save dkuebric/145dc1b8638d5d574cbf to your computer and use it in GitHub Desktop.
blotto zombies weighted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dan@ponderous:~/code/blotto $ git diff | |
diff --git a/blotto.c b/blotto.c | |
index e900988..41ec57c 100644 | |
--- a/blotto.c | |
+++ b/blotto.c | |
@@ -196,8 +196,19 @@ int main(int argc, char **argv) { | |
/* fight! */ | |
for(i = 0; i < battlefields; i++) { | |
- if(player[p1].soldiers[i] > player[p2].soldiers[i]) score++; | |
- else if(player[p1].soldiers[i] < player[p2].soldiers[i]) score--; | |
+ int left = player[p1].soldiers[i]; | |
+ int right = player[p2].soldiers[i]; | |
+ if (i > 0) { | |
+ left += player[p1].soldiers[i-1]/2; | |
+ right += player[p2].soldiers[i-1]/2; | |
+ } | |
+ if (left > right) { | |
+ score += i; | |
+ } else if (right < left) { | |
+ score -= i; | |
+ } else { | |
+ /* no penalty */ | |
+ } | |
} | |
/* administer points */ | |
dan@ponderous:~/code/blotto $ ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5 | |
Pos Name W D L Pts Soldiers | |
1 team1 9999 0 0 19998 12 9 7 12 15 8 10 9 8 10 | |
2 team2 9998 0 1 19996 6 12 11 11 9 6 13 9 11 12 | |
3 team3 9997 0 2 19994 11 6 10 12 13 12 5 10 7 14 | |
4 team5 9995 0 4 19990 13 10 5 13 8 9 14 9 11 8 | |
dan@ponderous:~/code/blotto $ ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5 | |
Pos Name W D L Pts Soldiers | |
1 team1 9999 0 0 19998 13 13 9 9 14 9 9 8 10 6 | |
2 team2 9998 0 1 19996 14 8 9 9 12 13 4 10 10 11 | |
3 team3 9997 0 2 19994 12 11 8 9 10 7 9 10 14 10 | |
4 team4 9995 1 3 19991 11 7 6 7 12 15 9 8 15 10 | |
dan@ponderous:~/code/blotto $ ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5 | |
Pos Name W D L Pts Soldiers | |
1 team1 9999 0 0 19998 10 7 9 13 8 11 9 10 6 17 | |
2 team2 9998 0 1 19996 6 7 9 8 15 13 14 10 11 7 | |
3 team3 9997 0 2 19994 10 8 10 8 9 12 9 11 9 14 | |
4 team5 9995 0 4 19990 13 6 7 12 11 8 15 7 13 8 | |
dan@ponderous:~/code/blotto $ ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5 | |
Pos Name W D L Pts Soldiers | |
1 team1 9999 0 0 19998 9 11 8 12 10 5 13 11 12 9 | |
2 team2 9998 0 1 19996 14 8 12 8 6 7 12 10 6 17 | |
3 team3 9997 0 2 19994 6 14 7 13 5 16 9 8 8 14 | |
4 team4 9996 0 3 19992 13 13 10 14 13 5 9 7 11 5 | |
dan@ponderous:~/code/blotto $ ./genteam 10 100 10000 | ./blotto 10 100 | head -n 5 | |
Pos Name W D L Pts Soldiers | |
1 team1 9999 0 0 19998 11 11 9 11 10 9 10 8 10 11 | |
2 team2 9998 0 1 19996 12 12 9 8 10 10 8 6 13 12 | |
3 team3 9997 0 2 19994 6 9 15 9 9 8 9 12 15 8 | |
4 team4 9996 0 3 19992 5 13 8 15 10 5 10 8 9 17 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment