[GRASS-SVN] r56308 - in grass-addons/grass7/raster/r.agent: libagent tests

svn_grass at osgeo.org svn_grass at osgeo.org
Sun May 19 02:30:10 PDT 2013


Author: mic
Date: 2013-05-19 02:30:10 -0700 (Sun, 19 May 2013)
New Revision: 56308

Modified:
   grass-addons/grass7/raster/r.agent/libagent/anthill.py
   grass-addons/grass7/raster/r.agent/libagent/grassland.py
   grass-addons/grass7/raster/r.agent/tests/test_anthill.py
Log:
add shortcut method

Modified: grass-addons/grass7/raster/r.agent/libagent/anthill.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/anthill.py	2013-05-19 09:18:13 UTC (rev 56307)
+++ grass-addons/grass7/raster/r.agent/libagent/anthill.py	2013-05-19 09:30:10 UTC (rev 56308)
@@ -147,3 +147,11 @@
         else:
             self.setpheromone(position, self.maxpheromone)
 
+    def getpenalty(self, position):
+        """
+        Return the penalty value at a certain position
+        @param position the position in question
+        @return the value of interest
+        """
+        return self.playground.getcellvalue(Anthill.COST, position)
+

Modified: grass-addons/grass7/raster/r.agent/libagent/grassland.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/grassland.py	2013-05-19 09:18:13 UTC (rev 56307)
+++ grass-addons/grass7/raster/r.agent/libagent/grassland.py	2013-05-19 09:30:10 UTC (rev 56308)
@@ -114,7 +114,6 @@
                         ( self.region["n"] - p[0] ) / self.region["nsres"] ))
                     p[1] = int(round(
                         ( p[1] - self.region["w"] ) / self.region["ewres"] ))
-                    grass.info(str(p[0]) + " " + str(p[1]))
                     vectors.append(p)
                     self.layers[layername][p[0]][p[1]] = value
         return vectors

Modified: grass-addons/grass7/raster/r.agent/tests/test_anthill.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests/test_anthill.py	2013-05-19 09:18:13 UTC (rev 56307)
+++ grass-addons/grass7/raster/r.agent/tests/test_anthill.py	2013-05-19 09:30:10 UTC (rev 56308)
@@ -81,6 +81,12 @@
         self.assertEqual(self.world.pathintensity,
                                 self.world.getpheromone([0,0]))
 
+    def test_getpenalty(self):                               
+        self.assertNotEqual(9,                                 
+            self.world.playground.layers[anthill.Anthill.COST][0][0])
+        self.world.playground.layers[anthill.Anthill.COST][0][0] = 9
+        self.assertEqual(9, self.world.getpenalty([0,0]))
+
     def volatilize(self):
         # gets tested in Playground, except for setting the values..
         pass



More information about the grass-commit mailing list