summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pd_server.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/pd_server.c b/pd_server.c
index d0b2315..80fcb4f 100644
--- a/pd_server.c
+++ b/pd_server.c
@@ -14,14 +14,17 @@ enum {
};
int pay(int a, int b)
-{
- if (a == COORPERATION && b == DEFECTION) return 1;
- if (a == DEFECTION && b == DEFECTION) return 2;
- if (a == COORPERATION && b == COORPERATION) return 3;
- if (a == DEFECTION && b == COORPERATION) return 4;
+{
+ assert(a == COORPERATION || a == DEFECTION);
+ assert(b == COORPERATION || b == DEFECTION);
+
+ if (a == COORPERATION && b == DEFECTION) return 1;
+ if (a == DEFECTION && b == DEFECTION) return 2;
+ if (a == COORPERATION && b == COORPERATION) return 3;
+ if (a == DEFECTION && b == COORPERATION) return 4;
- exit(EXIT_FAILURE);
-}
+ exit(EXIT_FAILURE);
+}
int
main(int argc, char *argv[])
@@ -68,11 +71,11 @@ main(int argc, char *argv[])
continue;
}
- a_payment += pay(a, b);
- b_payment += pay(b, a);
+ a_payment += pay(a, b);
+ b_payment += pay(b, a);
- printf("A [%c]: %d Euro\tB [%c]: %d Euro\t\t\tA: %d\tB: %d\n",
- a, pay(a, b), b, pay(b, a), a_payment, b_payment);
+ printf("A [%c]: %d Euro\tB [%c]: %d Euro\t\t\tA: %d\tB: %d\n",
+ a, pay(a, b), b, pay(b, a), a_payment, b_payment);
write(player[0], &b, 1);
write(player[1], &a, 1);