[GRASS-SVN] r54861 - grass-addons/grass7/raster/r.agent/libagent

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 3 02:36:00 PST 2013


Author: mic
Date: 2013-02-03 02:36:00 -0800 (Sun, 03 Feb 2013)
New Revision: 54861

Modified:
   grass-addons/grass7/raster/r.agent/libagent/world.py
Log:
discuss freedom on world class level

Modified: grass-addons/grass7/raster/r.agent/libagent/world.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/world.py	2013-02-03 10:19:12 UTC (rev 54860)
+++ grass-addons/grass7/raster/r.agent/libagent/world.py	2013-02-03 10:36:00 UTC (rev 54861)
@@ -17,8 +17,16 @@
 
 class World(object):
     """Generic World class as basis for more complex worlds."""
+    # walking constants
+    ## agents default ability to move
+    FREEDOM = 8
+    ## relative direction penalties
+    ### while walking straight we assume
+    STRAIGHT = 0
+    ### theoretical fix penalty value for diagonal walking
+    DIAGONAL = sqrt(2)-1
 
-    def __init__(self, agenttype=None, pg=None, freedom=8):
+    def __init__(self, agenttype=None, pg=None):
         """
         Create a World, a place with a playground, where agents meet
         @param type optional, the default agent type for this world
@@ -38,9 +46,6 @@
         # list of agents
         self.agents = []
         #self.artefacts = []
-        self.agentfreedom = freedom
-        # theoretical fix penalty value for diagonal walking
-        self.DIAGONAL = sqrt(2)-1
 
     def addlayertopg(self, layername):
         """
@@ -115,7 +120,7 @@
         @return list list of coordinates
         """
         if not freedom:
-            freedom = self.agentfreedom
+            freedom = World.FREEDOM
         return self.playground.getneighbourpositions(position, freedom)
 
     def kill(self, agent):



More information about the grass-commit mailing list