Created arenas - a way of playing off a predefined set of bots without reconfiguring...
authorDaniel Axtens <[email protected]>
Thu, 1 Jul 2010 09:33:10 +0000 (17:33 +0800)
committerDaniel Axtens <[email protected]>
Thu, 1 Jul 2010 09:33:10 +0000 (17:33 +0800)
src/arenas/CSampleAgents.py [new file with mode: 0644]
src/arenas/PythonSampleAgents.py [new file with mode: 0755]
src/arenas/__init__.py [new file with mode: 0644]
src/conf.py
src/progcomp.xcodeproj/project.pbxproj
src/simulate.py

diff --git a/src/arenas/CSampleAgents.py b/src/arenas/CSampleAgents.py
new file mode 100644 (file)
index 0000000..a49d6df
--- /dev/null
@@ -0,0 +1,11 @@
+'''CSampleAgents.py
+An areana that runs the sample bots in C.
+Written by Daniel Axtens <[email protected]> for the UCC Programming Competition in 2010.
+
+Licensed under an MIT-style license: see the LICENSE file for details.
+'''
+
+from link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_frenchie
+
+class arena:
+       Agents =  [c_angel,c_lucifer,c_streetfighter,c_frenchie]
diff --git a/src/arenas/PythonSampleAgents.py b/src/arenas/PythonSampleAgents.py
new file mode 100755 (executable)
index 0000000..c0c1134
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/python2.5
+'''PythonSampleAgentsArena.py
+An areana that runs the sample bots in python.
+Written by Daniel Axtens <[email protected]> for the UCC Programming Competition in 2010.
+
+Licensed under an MIT-style license: see the LICENSE file for details.
+'''
+
+from SampleAgents import Angel, Lucifer, Dummy, Frenchie, Streetfighter
+
+
+# Import and add your agents here:
+class PythonSampleAgentsArena:
+    Agents =  [Angel,Lucifer,Streetfighter,Frenchie]
\ No newline at end of file
diff --git a/src/arenas/__init__.py b/src/arenas/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 8ffbb2f..aabd717 100644 (file)
@@ -6,7 +6,7 @@ from rpsconst import *
 VERBOSE = True
 
 # Enable for even more verbose output.
-DEBUG = True
+DEBUG = False
 
 # How many iterations to run before quitting.
 MAX_ITERATIONS = 150
index 36086a8..ca03935 100644 (file)
@@ -7,6 +7,8 @@
        objects = {
 
 /* Begin PBXFileReference section */
+               228D541011DB3CEB00258478 /* PythonSampleAgents.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = PythonSampleAgents.py; sourceTree = "<group>"; };
+               228D541311DB443B00258478 /* CSampleAgents.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = CSampleAgents.py; sourceTree = "<group>"; };
                22CA010611D9BD51001ECDEF /* bundle-agent.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "bundle-agent.sh"; path = "link/bundle-agent.sh"; sourceTree = "<group>"; };
                22CA010711D9C52B001ECDEF /* cAgent.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; name = cAgent.py; path = link/cAgent.py; sourceTree = "<group>"; };
                22CAFEEA11D84076001ECDEF /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
                                22CAFEEE11D84076001ECDEF /* selectAlgorithms.py */,
                                22CAFEEF11D84076001ECDEF /* simulate.py */,
                                22CAFEF011D84076001ECDEF /* uccProgComp.py */,
+                               228D540F11DB3CEB00258478 /* arenas */,
                        );
                        name = progcomp;
                        sourceTree = "<group>";
                };
+               228D540F11DB3CEB00258478 /* arenas */ = {
+                       isa = PBXGroup;
+                       children = (
+                               228D541011DB3CEB00258478 /* PythonSampleAgents.py */,
+                               228D541311DB443B00258478 /* CSampleAgents.py */,
+                       );
+                       path = arenas;
+                       sourceTree = "<group>";
+               };
                22CAFF7711D840CB001ECDEF /* link */ = {
                        isa = PBXGroup;
                        children = (
index d3afdf9..cdf6d86 100755 (executable)
@@ -5,11 +5,9 @@ Written by Luke Williams <[email protected]> for the UCC Programming Competiti
 Licensed under an MIT-style license: see the LICENSE file for details.
 '''
 
-# Import and add your agents here:
-#from link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_frenchie
-
-from SampleAgents import Angel, Lucifer, Dummy, Frenchie, Streetfighter
-Agents =  [Angel,Lucifer,Streetfighter,Frenchie]
+# this is the default arena. To chose a different one - for example to run your
+# own bots - use -a arenaName on the command line, or change this variable.
+arenaName = "PythonSampleAgents"
 
 ####################################
 # Developers only past this point! #
@@ -45,17 +43,24 @@ for i in range (1,len(sys.argv)):
                except:
                        print usage
                        sys.exit(1)
-
        elif sys.argv[i] == "-v":
                VERBOSE = True
+       elif sys.argv[i] == "-a":
+               arenaName = sys.argv[i+1]
+               i += 1
+
 
+#import the arena - NOTE THAT THIS IS A POTENTIAL SECURITY HOLE,
+# AS INPUT IS NOT SANITY CHECKED!
+importString = "from arenas." + arenaName + " import arena"
+exec importString
 
 iteration = 0
 trial = 0
 winners = {}
 while trial < TRIALS:
        sup = Supervisor ()
-       for Agent in Agents: sup.RegisterAgent (Agent)
+       for Agent in arena.Agents: sup.RegisterAgent (Agent)
        sup.GeneratePopulation (STARTING_POPULATION)
 
        trial += 1

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