[GRASS-SVN] r56300 - in grass-addons/grass7/raster/r.agent: libagent tests
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 18 07:09:54 PDT 2013
Author: mic
Date: 2013-05-18 07:09:54 -0700 (Sat, 18 May 2013)
New Revision: 56300
Modified:
grass-addons/grass7/raster/r.agent/libagent/anthill.py
grass-addons/grass7/raster/r.agent/tests/test_anthill.py
Log:
adding path and step marker
Modified: grass-addons/grass7/raster/r.agent/libagent/anthill.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/anthill.py 2013-05-18 14:00:30 UTC (rev 56299)
+++ grass-addons/grass7/raster/r.agent/libagent/anthill.py 2013-05-18 14:09:54 UTC (rev 56300)
@@ -123,7 +123,27 @@
@param position the position in question
@param intensity the value to be set
"""
- if not intensity:
- intensity = self.stepintensity
self.playground.setcellvalue(Anthill.RESULT, position, intensity)
+ def setsteppheromone(self, position):
+ """
+ Mark a certain position with the pheromone of step intensity
+ @param position the position in question
+ """
+ intensity = self.getpheromone(position) + self.stepintensity
+ if intensity < self.maxpheromone:
+ self.setpheromone(position, intensity)
+ else:
+ self.setpheromone(position, self.maxpheromone)
+
+ def setpathpheromone(self, position):
+ """
+ Mark a certain position with the pheromone of path intensity
+ @param position the position in question
+ """
+ intensity = self.getpheromone(position) + self.pathintensity
+ if intensity < self.maxpheromone:
+ self.setpheromone(position, intensity)
+ else:
+ self.setpheromone(position, self.maxpheromone)
+
Modified: grass-addons/grass7/raster/r.agent/tests/test_anthill.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests/test_anthill.py 2013-05-18 14:00:30 UTC (rev 56299)
+++ grass-addons/grass7/raster/r.agent/tests/test_anthill.py 2013-05-18 14:09:54 UTC (rev 56300)
@@ -65,6 +65,22 @@
self.assertEqual(4,
self.world.playground.layers[anthill.Anthill.RESULT][0][0])
+ def test_setsteppheromone(self):
+ self.world.setpheromone([0,0], 0)
+ self.assertNotEqual(self.world.stepintensity,
+ self.world.getpheromone([0,0]))
+ self.world.setsteppheromone([0,0])
+ self.assertEqual(self.world.stepintensity,
+ self.world.getpheromone([0,0]))
+
+ def test_setpathpheromone(self):
+ self.world.setpheromone([0,0], 0)
+ self.assertNotEqual(self.world.pathintensity,
+ self.world.getpheromone([0,0]))
+ self.world.setpathpheromone([0,0])
+ self.assertEqual(self.world.pathintensity,
+ self.world.getpheromone([0,0]))
+
def volatilize(self):
# gets tested in Playground, except for setting the values..
pass
More information about the grass-commit
mailing list