From 52eb4c5a3aadbf02361e4f11b5790ae489fd3900 Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Thu, 1 Jul 2010 17:33:10 +0800 Subject: [PATCH] Created arenas - a way of playing off a predefined set of bots without reconfiguring simulate.py. --- src/arenas/CSampleAgents.py | 11 +++++++++++ src/arenas/PythonSampleAgents.py | 14 ++++++++++++++ src/arenas/__init__.py | 0 src/conf.py | 2 +- src/progcomp.xcodeproj/project.pbxproj | 12 ++++++++++++ src/simulate.py | 19 ++++++++++++------- 6 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 src/arenas/CSampleAgents.py create mode 100755 src/arenas/PythonSampleAgents.py create mode 100644 src/arenas/__init__.py diff --git a/src/arenas/CSampleAgents.py b/src/arenas/CSampleAgents.py new file mode 100644 index 0000000..a49d6df --- /dev/null +++ b/src/arenas/CSampleAgents.py @@ -0,0 +1,11 @@ +'''CSampleAgents.py +An areana that runs the sample bots in C. +Written by Daniel Axtens 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 index 0000000..c0c1134 --- /dev/null +++ b/src/arenas/PythonSampleAgents.py @@ -0,0 +1,14 @@ +#!/usr/bin/python2.5 +'''PythonSampleAgentsArena.py +An areana that runs the sample bots in python. +Written by Daniel Axtens 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 index 0000000..e69de29 diff --git a/src/conf.py b/src/conf.py index 8ffbb2f..aabd717 100644 --- a/src/conf.py +++ b/src/conf.py @@ -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 diff --git a/src/progcomp.xcodeproj/project.pbxproj b/src/progcomp.xcodeproj/project.pbxproj index 36086a8..ca03935 100644 --- a/src/progcomp.xcodeproj/project.pbxproj +++ b/src/progcomp.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXFileReference section */ + 228D541011DB3CEB00258478 /* PythonSampleAgents.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = PythonSampleAgents.py; sourceTree = ""; }; + 228D541311DB443B00258478 /* CSampleAgents.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = CSampleAgents.py; sourceTree = ""; }; 22CA010611D9BD51001ECDEF /* bundle-agent.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "bundle-agent.sh"; path = "link/bundle-agent.sh"; sourceTree = ""; }; 22CA010711D9C52B001ECDEF /* cAgent.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; name = cAgent.py; path = link/cAgent.py; sourceTree = ""; }; 22CAFEEA11D84076001ECDEF /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; @@ -32,10 +34,20 @@ 22CAFEEE11D84076001ECDEF /* selectAlgorithms.py */, 22CAFEEF11D84076001ECDEF /* simulate.py */, 22CAFEF011D84076001ECDEF /* uccProgComp.py */, + 228D540F11DB3CEB00258478 /* arenas */, ); name = progcomp; sourceTree = ""; }; + 228D540F11DB3CEB00258478 /* arenas */ = { + isa = PBXGroup; + children = ( + 228D541011DB3CEB00258478 /* PythonSampleAgents.py */, + 228D541311DB443B00258478 /* CSampleAgents.py */, + ); + path = arenas; + sourceTree = ""; + }; 22CAFF7711D840CB001ECDEF /* link */ = { isa = PBXGroup; children = ( diff --git a/src/simulate.py b/src/simulate.py index d3afdf9..cdf6d86 100755 --- a/src/simulate.py +++ b/src/simulate.py @@ -5,11 +5,9 @@ Written by Luke Williams 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 -- 2.20.1