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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 13 11:21:11 EST 2011


Author: mic
Date: 2011-11-13 08:21:10 -0800 (Sun, 13 Nov 2011)
New Revision: 49197

Added:
   grass-addons/grass7/raster/r.agent/libagent/agent.py
Log:
adding stubs for new version

Added: grass-addons/grass7/raster/r.agent/libagent/agent.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/agent.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.agent/libagent/agent.py	2011-11-13 16:21:10 UTC (rev 49197)
@@ -0,0 +1,43 @@
+############################################################################
+#
+# MODULE:       r.agent.*
+# AUTHOR(S):    michael lustenberger inofix.ch
+# PURPOSE:      library file for the r.agent.* suite
+# COPYRIGHT:    (C) 2011 by Michael Lustenberger and the GRASS Development Team
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+#############################################################################
+
+import world
+
+class Agent(object):
+    """Generic Agent class with limited capabilities, as a basis for
+       child classes."""
+    def __init__(self, timetolive, world, position=[]):
+        self.ttl = timetolive
+        self.world = world
+        self.position = position
+        self.knowscompass = False
+        self.freedom = 0
+    def setposition(self, position):
+        if position and position != []:
+            self.position[0] = position[0]
+            self.position[1] = position[1]
+    def getposition(self):
+        return self.position
+    def move(self, nrofsteps, direction):
+        pass
+    def age(self):
+        if self.ttl > 0:
+            self.ttl -= 1
+            return True
+        else:
+            self.snuffit()
+            return False
+    def snuffit(self):
+        """to die peacefully and without pain."""
+        self.world.kill(self)
+



More information about the grass-commit mailing list