[Avida-cvs] [avida-svn] r457 - branches/developers/avida-edward/source/python/AvidaGui2

baerb@myxo.css.msu.edu baerb at myxo.css.msu.edu
Wed Feb 1 13:58:04 PST 2006


Author: baerb
Date: 2006-02-01 16:58:04 -0500 (Wed, 01 Feb 2006)
New Revision: 457

Modified:
   branches/developers/avida-edward/source/python/AvidaGui2/pyDefaultFiles.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
   branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py
   branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
Log:

Completed code to allow user to turn on and off which tasks are to be rewarded

Removed a couple of random print statements.

Changed pyDefaultFiles.py to be the same as the genesis file in the
default.workspace.

Added some more error checks in pyPetriConfigureCtrl.

Updated to-do list.



Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyDefaultFiles.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyDefaultFiles.py	2006-02-01 14:51:19 UTC (rev 456)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyDefaultFiles.py	2006-02-01 21:58:04 UTC (rev 457)
@@ -100,10 +100,10 @@
     lines = lines + ["genesis.default", "		  # 4 = Replace random from entire population (Mass Action)"]
     lines = lines + ["genesis.default", "		  # 5 = Replace oldest in entire population (like Tierra)"]
     lines = lines + ["genesis.default", "PREFER_EMPTY 1    # Are empty cells given preference in offspring placement?"]
-    lines = lines + ["genesis.default", "DEATH_METHOD 0    # 0 = Never die of old age."]
+    lines = lines + ["genesis.default", "DEATH_METHOD 2    # 0 = Never die of old age."]
     lines = lines + ["genesis.default", "		  # 1 = Die when inst executed = AGE_LIMIT (with deviation)"]
     lines = lines + ["genesis.default", "		  # 2 = Die when inst executed = length * AGE_LIMIT (+ dev.)"]
-    lines = lines + ["genesis.default", "AGE_LIMIT 5000    # Modifies DEATH_METHOD"]
+    lines = lines + ["genesis.default", "AGE_LIMIT 20      # Modifies DEATH_METHOD"]
     lines = lines + ["genesis.default", "AGE_DEVIATION 0   # Modified DEATH_METHOD"]
     lines = lines + ["genesis.default", "ALLOC_METHOD 0    # 0 = Allocated space is set to default instruction."]
     lines = lines + ["genesis.default", "                  # 1 = Set to section of dead genome (Necrophilia)"]

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2006-02-01 14:51:19 UTC (rev 456)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py	2006-02-01 21:58:04 UTC (rev 457)
@@ -210,7 +210,6 @@
             Restart_Only_Flag = True
             self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doEnablePetriDishSig"), ())
           elif quit_return == m_check_to_freeze.FreezeQuitFlag:
-            print "BDB: Freeze than Restart" 
             self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("doEnablePetriDishSig"), ())
             self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("freezeDishPhaseISig"), (True, False, ))
   

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2006-02-01 14:51:19 UTC (rev 456)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyPetriConfigureCtrl.py	2006-02-01 21:58:04 UTC (rev 457)
@@ -198,7 +198,10 @@
       start_creature = settings_dict["START_CREATURE" + str(i)]
       self.AncestorComboBox.insertItem(start_creature)
       i = i + 1
-    max_updates = int(settings_dict["MAX_UPDATES"])
+    if settings_dict.has_key("MAX_UPDATES") == True:
+      max_updates = int(settings_dict["MAX_UPDATES"])
+    else:
+      max_updates = -1
     self.StopAtSpinBox.setValue(max_updates)
     if max_updates < 0:
        self.StopManuallyRadioButton.setChecked(True)
@@ -206,8 +209,14 @@
     else:
        self.StopManuallyRadioButton.setChecked(False)
        self.StopAtRadioButton.setChecked(True)
-    self.WorldSizeSlider.setValue(int(settings_dict["WORLD-X"]))
-    seed = int(settings_dict["RANDOM_SEED"])
+    if settings_dict.has_key("WORLD-X") == True:
+      self.WorldSizeSlider.setValue(int(settings_dict["WORLD-X"]))
+    else:
+      self.WorldSizeSlider.setValue(30)
+    if settings_dict.has_key("RANDOM_SEED") == True:
+      seed = int(settings_dict["RANDOM_SEED"])
+    else:
+      seed = 0
     self.RandomSpinBox.setValue(seed)
     if seed == 0:
        self.RadomGeneratedRadioButton.setChecked(True)
@@ -215,52 +224,64 @@
     else:
        self.RadomGeneratedRadioButton.setChecked(False)
        self.RandomFixedRadioButton.setChecked(True)
-    copy_mutation_percent = float(settings_dict["COPY_MUT_PROB"]) * 100;
+    if settings_dict.has_key("COPY_MUT_PROB") == True:
+      copy_mutation_percent = float(settings_dict["COPY_MUT_PROB"]) * 100;
+    else:
+      copy_mutation_percent = 0.01
     if copy_mutation_percent > 0.00000001:
       self.MutationSlider.setValue(int(math.log10(copy_mutation_percent) * 100))
     else:
       self.MutationSlider.setValue(-300)
-    if int(settings_dict["BIRTH_METHOD"]) in [0, 1, 2, 3]:
+    if (settings_dict.has_key("BIRTH_METHOD") and 
+        int(settings_dict["BIRTH_METHOD"])) in [0, 1, 2, 3]:
        self.LocalBirthRadioButton.setChecked(True)
        self.MassActionRadioButton.setChecked(False)
     else:
        self.LocalBirthRadioButton.setChecked(False)
        self.MassActionRadioButton.setChecked(True)
 
-    print "BDB REWARD_NOT = |" + settings_dict["REWARD_NOT"] + "|"
-    if settings_dict["REWARD_NOT"] == "YES":
+    if (settings_dict.has_key("REWARD_NOT") and 
+        settings_dict["REWARD_NOT"] == "YES"):
       self.NotCheckBox.setChecked(True)
     else:
       self.NotCheckBox.setChecked(False)
-    if settings_dict["REWARD_NAND"] == "YES":
+    if (settings_dict.has_key("REWARD_NAND") and 
+        settings_dict["REWARD_NAND"] == "YES"):
       self.NandCheckBox.setChecked(True)
     else:
       self.NandCheckBox.setChecked(False)
-    if settings_dict["REWARD_AND"] == "YES":
+    if (settings_dict.has_key("REWARD_AND") and 
+        settings_dict["REWARD_AND"] == "YES"):
       self.AndCheckBox.setChecked(True)
     else:
       self.AndCheckBox.setChecked(False)
-    if settings_dict["REWARD_ORN"] == "YES":
+    if (settings_dict.has_key("REWARD_ORN") and 
+        settings_dict["REWARD_ORN"] == "YES"):
       self.OrnCheckBox.setChecked(True)
     else:
       self.OrnCheckBox.setChecked(False)
-    if settings_dict["REWARD_OR"] == "YES":
+    if (settings_dict.has_key("REWARD_OR") and 
+        settings_dict["REWARD_OR"] == "YES"):
       self.OrCheckBox.setChecked(True)
     else:
       self.OrCheckBox.setChecked(False)
-    if settings_dict["REWARD_ANDN"] == "YES":
+    if (settings_dict.has_key("REWARD_ANDN") and 
+        settings_dict["REWARD_ANDN"] == "YES"):
       self.AndnCheckBox.setChecked(True)
     else:
       self.AndnCheckBox.setChecked(False)
-    if settings_dict["REWARD_NOR"] == "YES":
+    if (settings_dict.has_key("REWARD_NOR") and 
+        settings_dict["REWARD_NOR"] == "YES"):
       self.NorCheckBox.setChecked(True)
     else:
       self.NorCheckBox.setChecked(False)
-    if settings_dict["REWARD_XOR"] == "YES":
+    if (settings_dict.has_key("REWARD_XOR") and 
+        settings_dict["REWARD_XOR"] == "YES"):
       self.XorCheckBox.setChecked(True)
     else:
       self.XorCheckBox.setChecked(False)
-    if settings_dict["REWARD_EQU"] == "YES":
+    if (settings_dict.has_key("REWARD_EQU") and 
+        settings_dict["REWARD_EQU"] == "YES"):
       self.EquCheckBox.setChecked(True)
     else:
       self.EquCheckBox.setChecked(False)

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2006-02-01 14:51:19 UTC (rev 456)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pySessionCtrl.py	2006-02-01 21:58:04 UTC (rev 457)
@@ -139,7 +139,6 @@
     return self
 
   def restartPopulationSlot(self): 
-    print "BDB restartPopulationSlot Called"
     self.sessionInitialized = False
     self.m_should_update = False
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py	2006-02-01 14:51:19 UTC (rev 456)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWriteGenesisEvent.py	2006-02-01 21:58:04 UTC (rev 457)
@@ -2,7 +2,8 @@
 
 import shutil, string, pyInstructionSet, os.path
 
-# Class to write the working genesis and event files
+# Class to write the working genesis, event and environment files based on 
+# the contents of settings dictionary
 
 class pyWriteGenesisEvent:
 
@@ -56,16 +57,19 @@
     self.modifyEventFile(cells_dict, organisms_dict, 
       os.path.join(tmp_in_dir, "events.cfg"), tmp_out_dir)
     
-    shutil.copyfile(os.path.join(workspace_dir, "environment.default"), os.path.join(tmp_in_dir, "environment.cfg"))
     shutil.copyfile(os.path.join(workspace_dir, "inst_set.default"), os.path.join(tmp_in_dir, "inst_set.default"))
 
     settings_dict["EVENT_FILE"] = os.path.join(tmp_in_dir, "events.cfg")
     settings_dict["ENVIRONMENT_FILE"] = os.path.join(tmp_in_dir, "environment.cfg")
+    self.writeEnvironmentFile(workspace_dir, settings_dict)
     settings_dict["INST_SET"] = os.path.join(tmp_in_dir, "inst_set.default")
     # settings_dict["START_CREATURE"] = os.path.join(tmp_in_dir, settings_dict["START_CREATURE"])
+    self.writeGenesisFile(workspace_dir, tmp_in_dir, settings_dict)
     
-    # Read the default genesis file, if there is a equivilent line in the 
-    # dictionary replace it the new values, otherwise just copy the line
+  # Read the default genesis file, if there is a equivilent line in the 
+  # dictionary replace it the new values, otherwise just copy the line
+
+  def writeGenesisFile(self, workspace_dir, tmp_in_dir, settings_dict):
   
     orig_genesis_file = open(os.path.join(workspace_dir, "genesis.default"))
     lines = orig_genesis_file.readlines()
@@ -92,6 +96,55 @@
          out_genesis_file.write(line)
     out_genesis_file.close()
     
+   
+  # Read the default environment file, if there is a reward in the
+  # dictionary for a given resource print out that line in working env. file
+
+  def writeEnvironmentFile(self, workspace_dir, settings_dict):
+ 
+    orig_environment_file = open(os.path.join(workspace_dir, "environment.default"))
+    lines = orig_environment_file.readlines()
+    orig_environment_file.close()
+    out_environment_file = open(settings_dict["ENVIRONMENT_FILE"], "w")
+    for line in lines:
+      comment_start = line.find("#")
+      if comment_start > -1:
+        if comment_start == 0:
+          clean_line = ""
+        else:
+          clean_line = line[:comment_start]
+      else:
+        clean_line = line;
+      clean_line = clean_line.strip()
+      if len(clean_line) > 0:
+        split_out = string.split(clean_line)
+        command_name = split_out[0].upper()
+
+        # if it is a reaction line check further (otherwise print the line)
+
+        if command_name == "REACTION":
+          resource_name = split_out[1].upper()
+          resource_key = "REWARD_" + resource_name
+
+          # If the there is a reward key for this resource check further
+          # (otherwise print the line)
+ 
+          if settings_dict.has_key(resource_key) == True:
+
+            # If the value of the reward key is true print it out as is 
+            # (otherwise print out as a comment)
+
+            if settings_dict[resource_key] == "YES":
+              out_environment_file.write(line)
+            else:
+              out_environment_file.write("# " + line)
+          else:
+            out_environment_file.write(line)
+        else:
+          out_environment_file.write(line)
+
+    out_environment_file.close()
+
   def modifyEventFile(self, cells_dict, organisms_dict, event_file_name, 
     tmp_out_dir = None):
 

Modified: branches/developers/avida-edward/source/python/AvidaGui2/to-do_list
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/to-do_list	2006-02-01 14:51:19 UTC (rev 456)
+++ branches/developers/avida-edward/source/python/AvidaGui2/to-do_list	2006-02-01 21:58:04 UTC (rev 457)
@@ -4,21 +4,15 @@
 
 Priority High
 
-16-Jan-06 Get file system finished -- Brian -- High Priority
+16-Jan-06 Get file system finished
 
-16-Jan-06 Initial location of workspace box (ie before user can run program they must chose (or create) a workspace). -- Brian -- High Priority
+16-Jan-06 Initial location of workspace box (ie before user can run program they must chose (or create) a workspace).
 
 
 Priority Medium
 
-16-Jan-06 Change header of config screen to warn users they can not change it when program is running. -- Brian -- Medium Priority
+16-Jan-06 Freeze button on bottom of main screen.
 
-16-Jan-06 Freeze button on bottom of main screen. -- Brian -- Medium Priority
-
-23-Jan-06 Remove die of old age option -- Brian -- Medium Priority
-
-23-Jan-06 Add ability to have resource control -- Brian -- Medium Priority
-
 Priority Low
 
 -Under the sliders with ranges put a few values in grey that tell you the range min and max 
@@ -33,13 +27,11 @@
 
 -change the word "repopulate" to "start new experiment"
 
-16-Jan-06 Default mutation rate to 0.5? -- Brian -- Low priority (easy to change)
+16-Jan-06 Fix problem where start in menu bar not linked to start button 
 
-16-Jan-06 Fix problem where start in menu bar not linked to start button -- Brian -- Low priority
+16-Jan-06 Non-Fix length Genomes? 
 
-16-Jan-06 Non-Fix length Genomes? -- Brian -- Low priority
 
-
 ************Jeff*******************
 
 Priority High
@@ -62,7 +54,8 @@
 ************Kaben******************
 
 Priority High-
--first step is that if python is installed, Avida-Ed can be downloaded and run(1/30/05)
+23-Jan-06 Get program to run on all Macs
+-first step for Windows is that if python is installed, Avida-Ed can be downloaded and run(1/30/05)
 -make gradient say "rescaling" when it rescales
 -run things throught the test cpus (so we can accurately paint loaded dishes and so the graphs have good data from the get go)
 -investigation of printing petri dish (1/26/06)
@@ -78,7 +71,6 @@
 
 
 
-23-Jan-06 Get program to run on all Macs -- Kaben -- High Priority
 
 ************Josh*******************
 
@@ -93,7 +85,14 @@
 = DONE = DONE = DONE = DONE = DONE = DONE = DONE = DONE = DONE = DONE = DONE =
 ==============================================================================
 
-16-Jan-06 Set up Angel account. -- Brian -- Medium Priority -- Finished 18-Jan-06
+************Brian******************
 
+16-Jan-06 Set up Angel account. -- Finished 18-Jan-06
 
+23-Jan-06 Remove die of old age option -- Finished 1-Feb-06
 
+16-Jan-06 Change header of config screen to warn users they can not change it when program is running. -- Finished 1-Feb-06
+
+23-Jan-06 Add ability to have resource control -- Finished 1-Feb-06
+
+16-Jan-06 Default mutation rate to 0.5? (easy to change) -- Finished 1-Feb-06




More information about the Avida-cvs mailing list