[Avida-cvs] [Avida2-svn] r95 -
branches/developers/kaben/source/python/AvidaGui2
kaben at myxo.css.msu.edu
kaben at myxo.css.msu.edu
Wed Mar 30 19:44:15 PST 2005
Author: kaben
Date: 2005-03-30 22:44:15 -0500 (Wed, 30 Mar 2005)
New Revision: 95
Modified:
branches/developers/kaben/source/python/AvidaGui2/pyPetriDishCtrl.py
Log:
* Made petri dish updates faster; gui is more responsive.
Modified: branches/developers/kaben/source/python/AvidaGui2/pyPetriDishCtrl.py
===================================================================
--- branches/developers/kaben/source/python/AvidaGui2/pyPetriDishCtrl.py 2005-03-30 19:51:28 UTC (rev 94)
+++ branches/developers/kaben/source/python/AvidaGui2/pyPetriDishCtrl.py 2005-03-31 03:44:15 UTC (rev 95)
@@ -64,14 +64,22 @@
self.m_avida = avida
if(old_avida):
self.disconnect(
- self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
+ old_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
self.avidaUpdatedSlot)
+ old_avida.removeGuiWorkFunctor(self)
del old_avida
if(self.m_avida):
self.connect(
self.m_avida.m_avida_thread_mdtr, PYSIGNAL("AvidaUpdatedSig"),
self.avidaUpdatedSlot)
+ print """
+XXX fixme: in pyPetriDishCtrl.py,
+pyPetriDishCtrl.setAvidaSlot(),
+most of the code in this function should only be performed when
+self.m_avida is not None.
+ at kgn
+"""
self.m_map_cell_w = 2
self.m_map_cell_h = 2
world_w = cConfig.GetWorldX()
@@ -97,11 +105,11 @@
# self.m_map_cell_h,
# self.m_canvas) for y in range(world_h)] for x in range(world_w)]
- temp_normalized_index_functor = lambda population_cell: 1
- temp_color_functor = lambda index: QColor(255, 255, 255)
- for cell_info_item in self.m_cell_info:
- cell_info_item.checkNormalizedIndexUsingFunctor(temp_normalized_index_functor, 0, 0)
- cell_info_item.updateColorUsingFunctor(temp_color_functor)
+ #temp_normalized_index_functor = lambda population_cell: 1
+ #temp_color_functor = lambda index: QColor(0, 0, 0)
+ #for cell_info_item in self.m_cell_info:
+ # cell_info_item.checkNormalizedIndexUsingFunctor(temp_normalized_index_functor, 0, 0)
+ # cell_info_item.updateColorUsingFunctor(temp_color_functor)
#for x in range(world_w):
# for y in range(world_h):
@@ -111,6 +119,15 @@
self.m_thread_work_cell_item_index = 0
+ self.m_cs_min_value = 0
+ self.m_cs_value_range = 0
+
+ self.m_changed_cell_items = self.m_cell_info[:]
+ while self.doSomeWork(self.m_avida): pass
+ self.avidaUpdatedSlot()
+
+ self.m_avida.addGuiWorkFunctor(self)
+
def mousePressEvent(self,e):
if e.button() != Qt.LeftButton:
return
@@ -237,12 +254,13 @@
dbl = population_cell.GetOrganism().GetPhenotype().GetFitness()
return dbl
- for x in range(10):
- if self.m_cell_info.count() < self.m_thread_work_cell_item_index:
+ for x in range(3600):
+ if len(self.m_cell_info) <= self.m_thread_work_cell_item_index:
self.m_thread_work_cell_item_index = 0
return False
else:
- if self.m_cell_info[self.m_thread_work_cell_item_index].checkNormalizedIndexUsingFunctor(
+ cell_info_item = self.m_cell_info[self.m_thread_work_cell_item_index]
+ if cell_info_item.checkNormalizedIndexUsingFunctor(
temp_normalized_index_functor,
self.m_cs_min_value,
self.m_cs_value_range
@@ -253,12 +271,6 @@
def avidaUpdatedSlot(self):
- def temp_normalized_index_functor(population_cell):
- dbl = 0.0
- if population_cell.IsOccupied():
- dbl = population_cell.GetOrganism().GetPhenotype().GetFitness()
- return dbl
-
def temp_color_functor(index):
def sigmoid(w, midpoint, steepness):
val = steepness*(w-midpoint)
@@ -268,46 +280,10 @@
s = sigmoid(1.0 - index, 0.1, 30.0) * 255.0
return QColor(h, s, v, QColor.Hsv)
-
- def temp_normalized_index_functor(population_cell):
- dbl = 0.0
- if population_cell.IsOccupied():
- dbl = population_cell.GetOrganism().GetPhenotype().GetFitness()
- return dbl
-
- def temp_color_functor(index):
- def sigmoid(w, midpoint, steepness):
- val = steepness*(w-midpoint)
- return exp(val)/(1+exp(val))
- h = (index*360.0 + 100.0) % 360.0
- v = sigmoid(index, 0.3, 10.0) * 255.0
- s = sigmoid(1.0 - index, 0.1, 30.0) * 255.0
- return QColor(h, s, v, QColor.Hsv)
-
self.calcColorScale()
-
- self.m_changed_cell_items = []
- for cell_info_item in self.m_cell_info:
- if cell_info_item.checkNormalizedIndexUsingFunctor(
- temp_normalized_index_functor,
- self.m_cs_min_value,
- self.m_cs_value_range
- ):
- self.m_changed_cell_items.append(cell_info_item)
-
for cell_info_item in self.m_changed_cell_items:
cell_info_item.updateColorUsingFunctor(temp_color_functor)
-
- #world_w = cConfig.GetWorldX()
- #world_h = cConfig.GetWorldY()
- #for x in range(world_w):
- # for y in range(world_h):
- # cell = self.m_avida.m_population.GetCell(x + world_w*y)
- # color = self.calcCellState(cell)
- # xm = (x + world_w/2) % world_w
- # ym = (y + world_h/2) % world_h
- # self.m_cell_info[xm][ym].setBrush(QBrush(color))
- # self.m_cell_info[xm][ym].setPen(QPen(color))
+ self.m_changed_cell_items = []
self.m_canvas.update()
def extractPopulationSlot(self):
More information about the Avida-cvs
mailing list