From: Luke Williams Date: Mon, 28 Jun 2010 09:41:50 +0000 (+0800) Subject: Pulling out magic numbers into conf.py. X-Git-Tag: v01~20 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=bde6a9634c116c190cb631e962ccda551503a5c5;p=progcomp10.git Pulling out magic numbers into conf.py. --- diff --git a/src/conf.py b/src/conf.py new file mode 100644 index 0000000..8ffbb2f --- /dev/null +++ b/src/conf.py @@ -0,0 +1,39 @@ +''' Configuration settings for the RPS simulator. ''' + +from rpsconst import * + +# Enable for verbose output. +VERBOSE = True + +# Enable for even more verbose output. +DEBUG = True + +# How many iterations to run before quitting. +MAX_ITERATIONS = 150 + +# How many of each agent to create initially. +STARTING_POPULATION = 10 + +# ??? +TRIALS = 1 + +# How much health to give each agent on birth. +DEFAULT_HEALTH = 50 + +# How much health at which an agent can reproduce. +REPRODUCE_HEALTH = 100 + +# How much health at which an agent dies. +DIE_HEALTH = 0 + +# The age at which to kill any agent. +MAX_AGE = 100 + +# Game dynamics - these are not final: +# WINNER TRUTH ATTPoints, DEFPoints +pointsTable [Attacker] [False] = (2, -2) +pointsTable [Attacker] [True] = (2, -2) +pointsTable [Defender] [False] = (-2, 2) +pointsTable [Defender] [True] = (-2, 2) +pointsTable [Tie] [False] = (0, 0) +pointsTable [Tie] [True] = (1, 1) diff --git a/src/simulate.py b/src/simulate.py index 1a38656..d3afdf9 100755 --- a/src/simulate.py +++ b/src/simulate.py @@ -6,22 +6,19 @@ 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 link.C.c_agents import c_angel, c_lucifer, c_streetfighter, c_frenchie from SampleAgents import Angel, Lucifer, Dummy, Frenchie, Streetfighter -Agents = [c_angel,c_lucifer,c_streetfighter,c_frenchie] +Agents = [Angel,Lucifer,Streetfighter,Frenchie] #################################### # Developers only past this point! # #################################### import sys +from conf import * from uccProgComp import Supervisor -maxIterations = 150 -startingPopulations = 10 -verbose = False -trials = 1 usage = "Usage: rps [-v] [-i iterations=150] [-n starting_populations=10] [-t trials=1]" for i in range (1,len(sys.argv)): if sys.argv[i] == "-i": @@ -50,23 +47,23 @@ for i in range (1,len(sys.argv)): sys.exit(1) elif sys.argv[i] == "-v": - verbose = True + VERBOSE = True iteration = 0 trial = 0 winners = {} -while trial < trials: +while trial < TRIALS: sup = Supervisor () for Agent in Agents: sup.RegisterAgent (Agent) - sup.GeneratePopulation (startingPopulations) + sup.GeneratePopulation (STARTING_POPULATION) trial += 1 iteration = 0 - while iteration < maxIterations and not sup.IsGameOver (): + while iteration < MAX_ITERATIONS and not sup.IsGameOver (): iteration += 1 sup.Iterate () - if not verbose: continue + if not VERBOSE: continue print "Iteration %d:" % iteration for key, value in sup.GetStats ().iteritems(): print "%s: Population=%d, Newborns=%d, Deaths=%d" % (key, value[0], value[1], value[2]) diff --git a/src/uccProgComp.py b/src/uccProgComp.py index c5f22e0..9f256fd 100644 --- a/src/uccProgComp.py +++ b/src/uccProgComp.py @@ -10,22 +10,7 @@ import random, uuid random.seed () from rpsconst import * - -DEFAULT_HEALTH = 50 -REPRODUCE_HEALTH = 100 -DIE_HEALTH = 0 -MAX_AGE = 100 - -DEBUG = True - -# Game dynamics - these are not final: -# WINNER TRUTH ATTPoints, DEFPoints -pointsTable [Attacker] [False] = (2, -2) -pointsTable [Attacker] [True] = (2, -2) -pointsTable [Defender] [False] = (-2, 2) -pointsTable [Defender] [True] = (-2, 2) -pointsTable [Tie] [False] = (0, 0) -pointsTable [Tie] [True] = (1, 1) +from conf import * def Debug (f): def g (*args):