diff --git a/src/link/C/agents/c_angel.c b/src/link/C/agents/c_angel.c
old mode 100644
new mode 100755
index 62e214735b1aea21f60fc46494868ff58000eec0..d11b551da5f1661b4e109dd69c19cf8dc9ff8d8c
--- a/src/link/C/agents/c_angel.c
+++ b/src/link/C/agents/c_angel.c
@@ -1,41 +1,45 @@
-/*
- *  c_angel.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 angel bot, which always tells the truth
-   and expects others to do the same */
-
-ATTACKTYPE Attack( char * foe_name ) {
-	ATTACKTYPE attack;
-	
-	attack.realAttack =  RandomAttack();		/* Chooses randomly from Rock, Paper, Scissors */ 
-	attack.promisedAttack = attack.realAttack;	/* Tells the truth for its bluff */
-
-	return attack;
-}
-
-ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) {
-	return foePromisedAttack;	/* Trusts them to be going for a tie */
-}
-
-/* You need to define a results function, even if it isn't used
-   (otherwise the linker will complain) */
-void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
-             ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
-             int pointDelta ) {
-	
-	return;	/* Ignore whatever just happened. */
-}
-
-/* same for Cleanup() */
-
-void Cleanup() {
-	return;
-}
\ No newline at end of file
+/*
+ *  c_angel.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>
+
+void * Initialise( char * me ) {
+	return NULL;
+}
+
+/* Implement the angel bot, which always tells the truth
+   and expects others to do the same */
+
+ATTACKTYPE Attack( void * this, char * foe_name ) {
+	ATTACKTYPE attack;
+	
+	attack.realAttack =  RandomAttack();		/* Chooses randomly from Rock, Paper, Scissors */ 
+	attack.promisedAttack = attack.realAttack;	/* Tells the truth for its bluff */
+
+	return attack;
+}
+
+ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack ) {
+	return foePromisedAttack;	/* Trusts them to be going for a tie */
+}
+
+/* You need to define a results function, even if it isn't used
+   (otherwise the linker will complain) */
+void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,
+             ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
+             int pointDelta ) {
+	
+	return;	/* Ignore whatever just happened. */
+}
+
+/* same for Cleanup() */
+
+void Cleanup( void * this ) {
+	return;
+}
diff --git a/src/link/C/agents/c_lucifer.c b/src/link/C/agents/c_lucifer.c
old mode 100644
new mode 100755
index f497366a967e0c1a6f7d1f23d159f1c062a8f258..83258400976d122c432bb9b4219980bd9dc6d7d8
--- a/src/link/C/agents/c_lucifer.c
+++ b/src/link/C/agents/c_lucifer.c
@@ -1,67 +1,71 @@
-/*
- *  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:
-			attack.promisedAttack = scissors;
-			break;
-		case paper:
-			attack.promisedAttack = rock;
-			break;
-		default: /* attack = scissors */
-			attack.promisedAttack = paper;
-			break;
-	}
-	
-	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;
-	}
-    return defence;
-}
-
-/* You need to define a results function, even if it isn't used
- (otherwise the linker will complain) */
-void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
-             ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
-             int pointDelta ) {
-	
-	return;	/* Ignore whatever just happened. */
-}
-
-/* same for Cleanup() */
-
-void Cleanup() {
-	return;
-}
\ No newline at end of file
+/*
+ *  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 */
+
+void * Initialise( char * myName ) {
+	return NULL;
+}
+
+ATTACKTYPE Attack( void * this, 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:
+			attack.promisedAttack = scissors;
+			break;
+		case paper:
+			attack.promisedAttack = rock;
+			break;
+		default: /* attack = scissors */
+			attack.promisedAttack = paper;
+			break;
+	}
+	
+	return attack;
+}
+
+/* Here we trust that they are telling the truth. And we try to kill them. */
+ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack ) {
+	ITEMTYPE defence;
+	switch (foePromisedAttack) {
+		case rock:
+			defence = paper;
+			break;
+		case paper:
+			defence = scissors;
+			break;
+		default:
+			defence = rock;
+			break;
+	}
+    return defence;
+}
+
+/* You need to define a results function, even if it isn't used
+ (otherwise the linker will complain) */
+void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,
+             ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
+             int pointDelta ) {
+	
+	return;	/* Ignore whatever just happened. */
+}
+
+/* same for Cleanup() */
+
+void Cleanup( void * this ) {
+	return;
+}
diff --git a/src/link/C/agents/c_streetfighter.c b/src/link/C/agents/c_streetfighter.c
old mode 100644
new mode 100755
index 39a8cdab1999eb1c35beeb09da1a22a9fb25f556..3ddf6973e2378d3d86bf1308f5b9f4f40dd824dc
--- a/src/link/C/agents/c_streetfighter.c
+++ b/src/link/C/agents/c_streetfighter.c
@@ -1,65 +1,69 @@
-/*
- *  c_streetfighter.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 streetfighter bot, which thinks everyone has it in for him. */
-
-ATTACKTYPE Attack( char * foe_name ) {
-	ATTACKTYPE attack;
-	
-	attack.realAttack =  RandomAttack();
-	
-	/* Here we choose the thing that will hurt them if they go for the kill */
-	switch (attack.realAttack) {
-		case rock:
-			attack.promisedAttack = paper;
-			break;
-		case paper:
-			attack.promisedAttack = scissors;
-			break;
-		default: /* attack = scissors */
-			attack.promisedAttack = rock;
-			break;
-	}
-	return attack;
-}
-
-/* Here we assume they are lying, trying to kill us. And we try to kill them. */
-ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack ) {
-	ITEMTYPE defence;
-	switch (foePromisedAttack) {
-		case rock:
-			defence = scissors;
-			break;
-		case paper:
-			defence = rock;
-			break;
-		default:
-			defence = paper;
-			break;
-	}
-    return defence;
-}
-
-/* You need to define a results function, even if it isn't used
- (otherwise the linker will complain) */
-void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
-             ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
-             int pointDelta ) {
-	
-	return;	/* Ignore whatever just happened. */
-}
-
-/* same for Cleanup() */
-
-void Cleanup() {
-	return;
-}
+/*
+ *  c_streetfighter.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 streetfighter bot, which thinks everyone has it in for him. */
+
+void * Initialise( char * myName ) {
+	return NULL;
+}
+
+ATTACKTYPE Attack( void * this, char * foe_name ) {
+	ATTACKTYPE attack;
+	
+	attack.realAttack =  RandomAttack();
+	
+	/* Here we choose the thing that will hurt them if they go for the kill */
+	switch (attack.realAttack) {
+		case rock:
+			attack.promisedAttack = paper;
+			break;
+		case paper:
+			attack.promisedAttack = scissors;
+			break;
+		default: /* attack = scissors */
+			attack.promisedAttack = rock;
+			break;
+	}
+	return attack;
+}
+
+/* Here we assume they are lying, trying to kill us. And we try to kill them. */
+ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack ) {
+	ITEMTYPE defence;
+	switch (foePromisedAttack) {
+		case rock:
+			defence = scissors;
+			break;
+		case paper:
+			defence = rock;
+			break;
+		default:
+			defence = paper;
+			break;
+	}
+    return defence;
+}
+
+/* You need to define a results function, even if it isn't used
+ (otherwise the linker will complain) */
+void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,
+             ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
+             int pointDelta ) {
+	
+	return;	/* Ignore whatever just happened. */
+}
+
+/* same for Cleanup() */
+
+void Cleanup( void * this ) {
+	return;
+}
diff --git a/src/link/C/agents/c_wash.c b/src/link/C/agents/c_wash.c
new file mode 100644
index 0000000000000000000000000000000000000000..9ca4a413965031cad4ab35562abb5b06f79b5a47
--- /dev/null
+++ b/src/link/C/agents/c_wash.c
@@ -0,0 +1,177 @@
+/*
+ *  c_frechie.c
+ *  c-link-lib
+ *
+ *  Created by Daniel Axtens on 22/04/10.
+ *  Licensed under an MIT-style license: see the LICENSE file for details.
+ *
+ */
+
+#include <c_link.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Implement the wash agent, that is by default nice but will 
+   permanently turn against any agent that betrays it.
+   This is trickier in C than in any other language, for a number of reasons:
+     - there's no classes in C, so we can't just write a generic learning agent
+       and subclass it.
+     - your agent has no idea how many agents it's going to battle, or how many
+       battles it is going to fight, so you've got to do dynamic memory allocation.
+        (anyone who tries to read the source of the supervisor to find out is liable
+         to have their program break unexpectedly)
+ */
+
+/* To simplify things, we just look at whether we have lost to a particular agent.
+   Unlike in the Python version, we don't keep a generic list
+   This is also done in a inefficient (O(bot-cout)) way.
+   Implementing a faster version is left as an exercise to the DSA student. */
+
+/* Our guess at the number of agents I'm going to fight in my lifetime
+   (note that this is only a guess, not an upper limit. Do *not* take it as 
+   gospel on the number of agents you're going to see. */
+#define NUMBEROFAGENTSGUESS 100
+
+/* data for each instance of my agent */
+typedef struct {
+	/* The name of the n-th foe who has beaten us */
+	char (*defeatingFoes)[MAXFOENAMELEN];
+
+	/* The length of the array, and how far we are along it */
+	size_t foesLen;
+	unsigned int foesCount;
+} wash_data;
+
+
+/* an internal function - have I lost to a given foe? */
+int haveLostTo( wash_data * me, char * foeName ) {
+    
+	int foe;
+    
+    /* check every foe we know to have defeated us */
+    for (foe=0; foe<me->foesCount; foe++) {
+        if (strncmp( me->defeatingFoes[foe], foeName, MAXFOENAMELEN) == 0) {
+            //debugmsg( "%d\thaveLostTo( %s ) -> Yes\n", me, foeName );
+            return 1;
+        }
+    }
+    
+    /* this foe not found */
+    return 0;
+}
+
+/* set up myself */
+void * Initialise( char * myName ) {
+	wash_data * me = malloc( sizeof( wash_data ) );
+	
+	me->defeatingFoes = calloc( NUMBEROFAGENTSGUESS, sizeof( MAXFOENAMELEN*sizeof(char) ) );
+	me->foesLen = NUMBEROFAGENTSGUESS;
+    me->foesCount = 0;
+	
+	return (void *) me;
+}
+
+/* Attack */
+ATTACKTYPE Attack( void * this, char * foeName ) {
+	wash_data * me = (wash_data *)this;
+    
+	ATTACKTYPE attack;
+	
+	attack.realAttack =  RandomAttack();
+	
+    /* have I lost to this foe? */
+    if ( haveLostTo(me, foeName) ) {
+        /* Assume they are lying  */
+        switch (attack.realAttack) {
+            case rock:
+                attack.promisedAttack = scissors;
+                break;
+            case paper:
+                attack.promisedAttack = rock;
+                break;
+            default: /* attack = scissors */
+                attack.promisedAttack = paper;
+                break;
+        }
+    } else {
+        /* be nice! */
+        attack.promisedAttack = attack.realAttack;
+    }
+
+	
+	return attack;
+}
+
+/* defend */
+ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack ) {
+	wash_data * me = (wash_data *)this;
+	
+	ITEMTYPE defence;
+	
+    if (haveLostTo(me, foeName)) {
+        /* They've screwed us in the past, assume they're lying and go for the
+           kill. */
+        switch (foePromisedAttack) {
+            case rock:
+                defence = scissors;
+                break;
+            case paper:
+                defence = rock;
+                break;
+            default:
+                defence = paper;
+                break;
+        }
+    } else {
+        /* be nice! */
+        defence = foePromisedAttack;
+    }
+
+    return defence;
+}
+
+/* This is so much less fun in C */
+void Results( void * this, char * foeName, int isInstigatedByYou, 
+			 RESULTTYPE winner, ITEMTYPE attItem, ITEMTYPE defItem, 
+			 ITEMTYPE bluffItem, int pointDelta ) {
+	
+    wash_data * me = (wash_data *)this;
+	
+	int foe;
+    
+    /* figure out if we lost, which is the only thing we care about
+       if we didn't, move on. */
+    if ((winner == tie) || 
+        (winner==attacker && isInstigatedByYou) ||
+        (winner==defender && !isInstigatedByYou) ) return;
+    
+    //fprintf( stderr, "%d\tsaving loss from %s\n", me, foeName );
+    
+    /* if we've already lost the foe, don't store again */
+    for (foe=0; foe<me->foesCount; foe++) {
+        if (strncmp( me->defeatingFoes[foe], foeName, MAXFOENAMELEN ) == 0) {
+            /* we've found it! */
+            return;
+        }
+    }
+    
+    /* we haven't found the foe. add it, expanding the array if needed */
+    if (me->foesCount==me->foesLen) {
+        /* double the array size. This should error check, but doesn't */
+        me->defeatingFoes = realloc( me->defeatingFoes, 
+		                             me->foesLen*2*sizeof( MAXFOENAMELEN*sizeof(char) ) );
+        me->foesLen *= 2;
+    }
+    
+    strncpy( me->defeatingFoes[me->foesCount], foeName, MAXFOENAMELEN );
+    me->foesCount++;
+    
+    return;
+}
+
+/* Cleanup */
+void Cleanup( void * this ) {
+	wash_data * me = (wash_data *) this;
+	free(me->defeatingFoes);
+	free(me);
+}
\ No newline at end of file
diff --git a/src/link/C/c_link.c b/src/link/C/c_link.c
old mode 100644
new mode 100755
index fdb1ffcd6519af738e4992789a6d8a25dd83f782..39dda6b8e58387da9b9b246ff3d5f9385e250552
--- a/src/link/C/c_link.c
+++ b/src/link/C/c_link.c
@@ -1,107 +1,110 @@
-/*
- *  c_link.c
- *  c-link-lib
- *
- *  Created by Daniel Axtens on 19/04/10.
- *  Licensed under an MIT-style license: see the LICENSE file for details.
- *
- */
-
-#include "c_link.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <time.h>
-
-/* You don't need to read this file.
-   All you have to do is implement the bot functions defined in <c_link.h>
-   This file sets up the I/O for you, as well as some utility functions and tables. 
- */
-
-char ITEMNAMES[3][MAXITEMLEN] = {"Rock", "Paper", "Scissors"};
-
-/* rock-rock     rock-paper     rock-scissors 
-   paper-rock    paper-paper    paper-scissors
-   scissors-rock scissors-paper scissors-scissors */  
-   
-RESULTTYPE RESULTOF[3][3] = { { tie, defender, attacker },
-                              { attacker, tie, defender },
-                              { defender, attacker, tie } };
-
-
-ITEMTYPE RandomAttack() {
-	return (ITEMTYPE)rand()%3;
-}
-
-ITEMTYPE stringToItem( char * str ) {
-	if (strcasecmp( str, "Rock" ) == 0) return rock;
-	if (strcasecmp( str, "Paper" ) == 0) return paper;
-	if (strcasecmp( str, "Scissors" ) == 0) return scissors;
-	/* If we reach this point, we've got real problems. */
-	fprintf( stderr, "Attempt to convert invalid string \"%s\" into an ITEMTYPE! Aborting.\n", str );
-	exit(EXIT_FAILURE);
-	return -1;
-}
-	
-
-RESULTTYPE stringToResult( char * str ) {
-    if (strcasecmp( str, "Attacker" ) == 0) return attacker;
-    if (strcasecmp( str, "Defender" ) == 0) return defender;
-    if (strcasecmp( str, "Tie" ) == 0) return tie;
-    /* If we reach this point, we've got real problems. */
-	fprintf( stderr, "Attempt to convert invalid string \"%s\" into an ITEMTYPE! Aborting.\n", str );
-	exit(EXIT_FAILURE);
-	return -1;
-}
-
-int main( int argc, char * argv[] ) {
-	srand( time( NULL ) );
-	
-	char command[MAXCOMMANDLEN];
-	char foeName[MAXFOENAMELEN];
-	char attItem[MAXITEMLEN], defItem[MAXITEMLEN], bluffItem[MAXITEMLEN];
-	char didYouInstigate[MAXBOOLLEN];
-    char winner[MAXRESULTLEN];
-	int pointChange;
-	
-	ATTACKTYPE attack;
-	ITEMTYPE defence;
-	
-    /* generate a random id for this bot. Hopefully it's unique
-       I can't use the UUID, because python doesn't pass it to me! */
-    me = rand();
-    
-    
-	scanf( "%s", command );
-	
-	while (strcasecmp("BYE",command) != 0) {
-		
-		if (strcasecmp("ATTACK", command) == 0) {
-			scanf( "%s", foeName );
-			attack = Attack( foeName );
-			printf("ATTACKING %s %s\n", ITEMNAMES[attack.realAttack], ITEMNAMES[attack.promisedAttack]);
-		
-		} else if (strcasecmp("DEFEND", command) == 0) {
-			scanf( "%s %s", foeName, bluffItem );
-			defence = Defend(foeName, stringToItem(bluffItem));
-			printf("DEFENDING %s\n", ITEMNAMES[defence]);
-		
-		} else if (strcasecmp("RESULTS", command) == 0) {
-            /* (foeName, isInstigatedByYou, winner, attItem, defItem, bluffItem, pointDelta) */
-			scanf( "%s %s %s %s %s %s %d", foeName, didYouInstigate, winner, attItem, defItem, bluffItem, &pointChange );
-			Results(foeName, (strcasecmp("True",didYouInstigate)==0), stringToResult(winner),
-					stringToItem(attItem), stringToItem(defItem), stringToItem(bluffItem), pointChange);
-			printf("OK\n");
-		}
-	
-        fflush(stdout);
-        fflush(stderr);
-        
-		// read the next command!
-		scanf( "%s", command );
-	}
-	
-	Cleanup();
-	
-	return 0;
-}
\ No newline at end of file
+/*
+ *  c_link.c
+ *  c-link-lib
+ *
+ *  Created by Daniel Axtens on 19/04/10.
+ *  Licensed under an MIT-style license: see the LICENSE file for details.
+ *
+ */
+
+#include "c_link.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <time.h>
+
+/* You don't need to read this file.
+   All you have to do is implement the bot functions defined in <c_link.h>
+   This file sets up the I/O for you, as well as some utility functions and tables. 
+ */
+
+char ITEMNAMES[3][MAXITEMLEN] = {"Rock", "Paper", "Scissors"};
+
+/* rock-rock     rock-paper     rock-scissors 
+   paper-rock    paper-paper    paper-scissors
+   scissors-rock scissors-paper scissors-scissors */  
+   
+RESULTTYPE RESULTOF[3][3] = { { tie, defender, attacker },
+                              { attacker, tie, defender },
+                              { defender, attacker, tie } };
+
+ITEMTYPE RandomAttack() {
+	return (ITEMTYPE)rand()%3;
+}
+
+ITEMTYPE stringToItem( char * str ) {
+	if (strcasecmp( str, "Rock" ) == 0) return rock;
+	if (strcasecmp( str, "Paper" ) == 0) return paper;
+	if (strcasecmp( str, "Scissors" ) == 0) return scissors;
+	/* If we reach this point, we've got real problems. */
+	fprintf( stderr, "Attempt to convert invalid string \"%s\" into an ITEMTYPE! Aborting.\n", str );
+	exit(EXIT_FAILURE);
+	return -1;
+}
+	
+
+RESULTTYPE stringToResult( char * str ) {
+	if (strcasecmp( str, "Attacker" ) == 0) return attacker;
+	if (strcasecmp( str, "Defender" ) == 0) return defender;
+	if (strcasecmp( str, "Tie" ) == 0) return tie;
+	/* If we reach this point, we've got real problems. */
+	fprintf( stderr, "Attempt to convert invalid string \"%s\" into an ITEMTYPE! Aborting.\n", str );
+	exit(EXIT_FAILURE);
+	return -1;
+}
+
+int main( int argc, char * argv[] ) {
+	srand( time( NULL ) );
+	
+	char command[MAXCOMMANDLEN];
+	char foeName[MAXFOENAMELEN];
+	char attItem[MAXITEMLEN], defItem[MAXITEMLEN], bluffItem[MAXITEMLEN];
+	char didYouInstigate[MAXBOOLLEN];
+	char winner[MAXRESULTLEN];
+	int pointChange;
+	void *thisInstance;
+
+	ATTACKTYPE attack;
+	ITEMTYPE defence;
+	
+	/* generate a random id for this bot. Hopefully it's unique
+	   I can't use the UUID, because python doesn't pass it to me! */
+	me = rand();
+	
+	// TODO: Get the UUID passed by python
+	// Currently, just pass an empty string to the initialise function
+	thisInstance = Initialise( "" );
+	
+	scanf( "%s", command );
+	
+	while (strcasecmp("BYE",command) != 0) {
+		
+		if (strcasecmp("ATTACK", command) == 0) {
+			scanf( "%s", foeName );
+			attack = Attack( thisInstance, foeName );
+			printf("ATTACKING %s %s\n", ITEMNAMES[attack.realAttack], ITEMNAMES[attack.promisedAttack]);
+		
+		} else if (strcasecmp("DEFEND", command) == 0) {
+			scanf( "%s %s", foeName, bluffItem );
+			defence = Defend(thisInstance, foeName, stringToItem(bluffItem));
+			printf("DEFENDING %s\n", ITEMNAMES[defence]);
+		
+		} else if (strcasecmp("RESULTS", command) == 0) {
+			/* (foeName, isInstigatedByYou, winner, attItem, defItem, bluffItem, pointDelta) */
+			scanf( "%s %s %s %s %s %s %d", foeName, didYouInstigate, winner, attItem, defItem, bluffItem, &pointChange );
+			Results(thisInstance, foeName, (strcasecmp("True",didYouInstigate)==0), stringToResult(winner),
+					stringToItem(attItem), stringToItem(defItem), stringToItem(bluffItem), pointChange);
+			printf("OK\n");
+		}
+	
+		fflush(stdout);
+		fflush(stderr);
+        
+		// read the next command!
+		scanf( "%s", command );
+	}
+	
+	Cleanup(thisInstance);
+	
+	return 0;
+}
diff --git a/src/link/C/c_link.h b/src/link/C/c_link.h
old mode 100644
new mode 100755
index c3bd87cf7e5851534ac6b9d53dccaa6623cbe566..5953acbb64ff14bad5d66639b74470f78c8a8cfc
--- a/src/link/C/c_link.h
+++ b/src/link/C/c_link.h
@@ -1,106 +1,118 @@
-/*
- *  c_link.h
- *  c-link-lib
- *
- *  Created by Daniel Axtens on 19/04/10.
- *  Licensed under an MIT-style license: see the LICENSE file for details.
- *
- */
-
-#include <stdio.h>
-
-#define MAXCOMMANDLEN	15
-#define MAXFOENAMELEN	50
-#define MAXITEMLEN		10
-#define MAXRESULTLEN    10
-#define MAXBOOLLEN		6
-
-/********** Type definitions **********/
-
-/* The type of item used in an attack or defence */
-typedef enum {rock, paper, scissors} ITEMTYPE;
-
-/* A result of a battle, in terms of who won */
-typedef enum {attacker, defender, tie} RESULTTYPE;
-
-
-/* An attack, consisting of the real attack and the attack promised */
-typedef struct {
-	ITEMTYPE realAttack;
-	ITEMTYPE promisedAttack;
-} ATTACKTYPE;
-
-
-/********** Utility Function definitions **********/
-/* These are implemented in c-link.c, and automagically linked in */
-
-/* prints a debug message. Same arguments as printf().
-   (you can't use printf because it is used to talk between
-    the agent and supervisor) 
- */
-
-#define debugmsg(x...) fprintf(stderr, x)
-
-/* A (hopefully) unique identifier for this particular instance of your agent,
-   to help with debugging */
-int me;
-
-
-/* Returns a random item */
-
-ITEMTYPE RandomAttack();
-
-/* A useful translation table
-   eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
-
-extern char ITEMNAMES[3][MAXITEMLEN];
-
-/* Another useful table - who's the victor given an 
-   attacker with first item vs defender with the second item? */
-extern RESULTTYPE RESULTOF[3][3];
-
-/********** Bot Function definitions **********/
-/* You need to provide implementations for these to create a bot */
-
-/* Defend( foeName : string - the name of your foe;
-           foePromisedAttack : ITEMTYPE - the item your foe promised to use
-         ) : ITEMTYPE - the item you wish to use to defend;
- 
- Called when your agent needs to defend itself.
- 
- */
-ITEMTYPE Defend( char * foeName, ITEMTYPE foePromisedAttack );
-
-
-/* Attack( foeName : string - the name of your foe
-		 ) : ATTACKTYPE - the real and promised attack you wish to use
-
- Called when your agent needs to attack another agent.
- 
- */
-ATTACKTYPE Attack( char * foeName );
-
-
-/* Results( foeName : string - the name of your foe;
-            isInstigatedByYou : 0=you defended/1=you attacked;
-            winner : RESULTTYPE - who won
-			attItem : ITEMTYPE - the item used to attack;
-            defItem : ITEMTYPE - the item used to defend;
-            bluffItem : ITEMTYPE - the item that was promised
-            pointDelta : integer - how your points were affected.
-          );
-
- Called after your agent battles another agent, to tell you how the battle goes.
- 
- */
-void Results( char * foeName, int isInstigatedByYou, RESULTTYPE winner,
-              ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
-              int pointDelta );
-
-/* Cleanup();
-
-   Called when your agent is no longer needed, either due to the round ending
-   or due to your agent being eliminated.
-
- */
-void Cleanup();
\ No newline at end of file
+/*
+ *  c_link.h
+ *  c-link-lib
+ *
+ *  Created by Daniel Axtens on 19/04/10.
+ *  Licensed under an MIT-style license: see the LICENSE file for details.
+ *
+ */
+
+#include <stdio.h>
+
+#define MAXCOMMANDLEN	15
+#define MAXFOENAMELEN	50
+#define MAXITEMLEN		10
+#define MAXRESULTLEN    10
+#define MAXBOOLLEN		6
+
+/********** Type definitions **********/
+
+/* The type of item used in an attack or defence */
+typedef enum {rock, paper, scissors} ITEMTYPE;
+
+/* A result of a battle, in terms of who won */
+typedef enum {attacker, defender, tie} RESULTTYPE;
+
+
+/* An attack, consisting of the real attack and the attack promised */
+typedef struct {
+	ITEMTYPE realAttack;
+	ITEMTYPE promisedAttack;
+} ATTACKTYPE;
+
+
+/********** Utility Function definitions **********/
+/* These are implemented in c-link.c, and automagically linked in */
+
+/* prints a debug message. Same arguments as printf().
+   (you can't use printf because it is used to talk between
+    the agent and supervisor) 
+ */
+
+#define debugmsg(x...) fprintf(stderr, x)
+
+/* A (hopefully) unique identifier for this particular instance of your agent,
+   to help with debugging */
+int me;
+
+
+/* Returns a random item */
+
+ITEMTYPE RandomAttack();
+
+/* A useful translation table
+   eg debugmsg( "I use %s.\n", ITEMNAMES[rock] ); */
+
+extern char ITEMNAMES[3][MAXITEMLEN];
+
+/* Another useful table - who's the victor given an 
+   attacker with first item vs defender with the second item? */
+extern RESULTTYPE RESULTOF[3][3];
+
+/********** Bot Function definitions **********/
+/* You need to provide implementations for these to create a bot */
+
+/* Initialise( yourName : string - name of this instance (you)
+             ) : void * - A data pointer to represent this instance
+ 
+ Called to create a new instance of this agent
+
+ */
+void *Initialise( char * yourName );
+
+/* Defend( this : pointer - value returned from Initialise();
+           foeName : string - the name of your foe;
+           foePromisedAttack : ITEMTYPE - the item your foe promised to use
+         ) : ITEMTYPE - the item you wish to use to defend;
+ 
+ Called when your agent needs to defend itself.
+ 
+ */
+ITEMTYPE Defend( void * this, char * foeName, ITEMTYPE foePromisedAttack );
+
+
+/* Attack( this: pointer - value returned from Initialise();
+           foeName : string - the name of your foe
+		 ) : ATTACKTYPE - the real and promised attack you wish to use
+
+ Called when your agent needs to attack another agent.
+ 
+ */
+ATTACKTYPE Attack( void * this, char * foeName );
+
+
+/* Results( this : pointer - value returned from Initialise();
+            foeName : string - the name of your foe;
+            isInstigatedByYou : 0=you defended/1=you attacked;
+            winner : RESULTTYPE - who won
+			attItem : ITEMTYPE - the item used to attack;
+            defItem : ITEMTYPE - the item used to defend;
+            bluffItem : ITEMTYPE - the item that was promised
+            pointDelta : integer - how your points were affected.
+          );
+
+ Called after your agent battles another agent, to tell you how the battle goes.
+ 
+ */
+void Results( void * this, char * foeName, int isInstigatedByYou, RESULTTYPE winner,
+              ITEMTYPE attItem, ITEMTYPE defItem, ITEMTYPE bluffItem,
+              int pointDelta );
+
+/* Cleanup( this: pointer - value returned from Initialise()
+          );
+
+   Called when your agent is no longer needed, either due to the round ending
+   or due to your agent being eliminated.
+
+ */
+void Cleanup( void * this );