cleanup
[progcomp10.git] / src / link / C / c-link-lib / agents / c-lucifer.c
diff --git a/src/link/C/c-link-lib/agents/c-lucifer.c b/src/link/C/c-link-lib/agents/c-lucifer.c
new file mode 100644 (file)
index 0000000..1dabc34
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  c-lucifer.c
+ *  c-link-lib
+ *
+ *  Created by Daniel Axtens on 20/04/10.
+ *  Licensed under an MIT-style license: see the LICENSE file for details.
+ *
+ */
+
+
+#include <c_link.h>
+
+/* Implement the lucifer bot, which always lies expecting people to be good
+   and always goes for the kill */
+
+ATTACKTYPE Attack( char * foe_name ) {
+       ATTACKTYPE attack;
+       
+       attack.realAttack =  RandomAttack();
+       
+       /* Here we choose the thing that will hurt them if they go for a tie */
+       switch (attack.realAttack) {
+               case rock:
+                       result.promisedAttack = scissors;
+                       break;
+               case paper:
+                       result.promisedAttack = rock;
+                       break;
+               default: /* attack = scissors */
+                       result.promisedAttack = paper;
+                       break;
+       }
+       attack.promisedAttack = result.realAttack;      /* Tells the truth for its bluff */
+       
+       return attack;
+}
+
+/* Here we trust that they are telling the truth. And we try to kill them. */
+ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) {
+       ITEMTYPE defence;
+       switch (foePromisedAttack) {
+               case rock:
+                       defence = paper;
+                       break;
+               case paper:
+                       defence = scissors;
+                       break;
+               default:
+                       defence = rock;
+                       break;
+       }
+}
+
+/* You need to define a results function, even if it isn't used
+ (otherwise the linker will complain) */
+void Results( char * foeName, int isInstigatedByYou, ITEMTYPE yourItem, 
+                        ITEMTYPE theirItem, ITEMTYPE promisedItem) {
+       
+       return; /* Ignore whatever just happened. */
+}
+
+/* same for Cleanup() */
+
+void Cleanup() {
+       return;
+}
\ No newline at end of file

UCC git Repository :: git.ucc.asn.au