From 52eb4c5a3aadbf02361e4f11b5790ae489fd3900 Mon Sep 17 00:00:00 2001 From: Daniel Axtens <dja@ucc.asn.au> 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 | Bin 6211 -> 6884 bytes src/simulate.py | 19 ++++++++++++------- 6 files changed, 38 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 <dja@ucc.asn.au> 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 <dja@ucc.asn.au> 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 36086a89b8c33976f2f78ba08f73d090bc34b1b5..ca03935b7fd30746c09daa114d84eb2dbd8f8238 100644 GIT binary patch delta 283 zcmX?X@WgaNlY)hdsfnS1p`nYDv9qg_fq{{!g^9U^g1(kQKxIire%@qhmV7oSvx~(* z8m!(Jq~65D7)8A^NGYT9<SrJYjV(M}>YPSKAjJl5*bGlBO3h0wR?yPdncToDH+dD8 zBG@JP6i*J|6Pf&%OO~*c?{P}ub>}@!abZnsE>2F)g2a*x1zQD(YbL+tR@!`=tA-Z< D@K;Jc delta 24 gcmaE2de~q>(`F_nKCa2C0#cJhc@#J2@K*2w0BkS^mH+?% 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 <shmookey@ucc.asn.au> 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 -- GitLab