Added C++ agent
[progcomp2013.git] / agents / agent++ / main.cpp
diff --git a/agents/agent++/main.cpp b/agents/agent++/main.cpp
new file mode 100644 (file)
index 0000000..316df26
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * agent++ : A Sample agent for UCC::Progcomp2013
+ * @file main.cpp
+ * @purpose The main function 
+ */
+#include <cstdlib>
+#include <cstdio>
+#include <iostream>
+
+#include "agent.h" // Declarations for agent, see also agent.cpp
+
+using namespace std;
+
+/**
+ * @funct main
+ * @purpose The main function; starts the agent
+ * @param argc - Number of arguments, unused
+ * @param argv - Argument string array, unused
+ */
+int main(int argc, char ** argv)
+{
+       srand(time(NULL)); // seed random number generator
+
+       string colour; cin >> colour; // first read the colour of the agent
+       Agent agent(colour); // create an agent using the colour
+       agent.Run(cin, cout); // run the agent (it will read from cin and output to cout)
+       
+       return 0; // Don't use exit(3), because it causes memory leaks in the C++ stdlib
+}

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