Skip to content

Commit

Permalink
r.agent: fix import py modules from libagent lib (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmszi committed Jul 25, 2020
1 parent 6ca318a commit 45b6970
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
9 changes: 4 additions & 5 deletions grass7/raster/r.agent/libagent/ant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
for details.
"""

from random import uniform #, choice, randint
import agent
import error
#from grass.script import core as grass
from random import uniform

from libagent import agent

# for Python 3 compatibility
try:
xrange
except NameError:
xrange = range


class Ant(agent.Agent):
"""
Implementation of an Ant like Agent for an Anthill, a kind of World
Expand Down Expand Up @@ -229,4 +229,3 @@ def work(self):
return True
else:
self.walk()

11 changes: 4 additions & 7 deletions grass7/raster/r.agent/libagent/anthill.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
for details.
"""

import error, world, ant

#from grass.script import core as grass
from sys import maxsize
from math import sqrt
from math import exp
from random import randint
from sys import maxsize

from libagent import ant, world


class Anthill(world.World):
"""
Expand Down Expand Up @@ -176,4 +174,3 @@ def getsitevalue(self, position):
@return the value of interest
"""
return self.playground.getcellvalue(Anthill.SITE, position)

5 changes: 3 additions & 2 deletions grass7/raster/r.agent/libagent/grassland.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
for details.
"""

import error, playground
import grass.script as grass
from grass.script import array as garray

from libagent import error, playground


class Grassland(playground.Playground):
"""
A GrassLand is a Playground and the interface to GRASS.
Expand Down Expand Up @@ -146,4 +148,3 @@ def decaycellvalues(self, layername, halflife, minimum=0):
mask = garray.numpy.ones_like(self.layers[layername]) - 1 + minimum
self.layers[layername] = \
garray.numpy.maximum(self.layers[layername], mask)

8 changes: 6 additions & 2 deletions grass7/raster/r.agent/libagent/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@
for details.
"""

import numpy, error, random
import random
from math import sqrt

from libagent import error

import numpy


class Playground(object):
"""
A Playground is a major component of a World, defining and organizing
Expand Down Expand Up @@ -275,4 +280,3 @@ def decaycellvalues(self, layername, halflife, minimum=0):
self.layers[layername][i][j] = v
else:
self.layers[layername][i][j] = minimum

8 changes: 3 additions & 5 deletions grass7/raster/r.agent/libagent/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
for details.
"""

import error
import playground
import agent

from math import sqrt

from libagent import agent, error, playground


class World(object):
"""
Generic World class as basis for more complex worlds.
Expand Down Expand Up @@ -138,4 +137,3 @@ def kill(self, agent):
@param agent to be terminated
"""
self.agents.remove(agent)

0 comments on commit 45b6970

Please sign in to comment.