arc_angel

Agent Analyst tutorial book- syntax error?

Discussion created by arc_angel on Sep 14, 2013
Latest reply on Sep 22, 2014 by Nelsonucv
I am working through the Agent Analyst tutorials found here: http://resources.arcgis.com/en/help/agent-analyst/pdf/AgentAnalyst.pdf


I have imported the model created for the exercise (found here- http://resources.arcgis.com/en/help/agent-analyst/)

So far as I can tell, I have typed in the code as specified in the tutorial:
#NEW CODE
#define a neighbourhood of 7000 m for the cougar, based on cougar location, and create polygon of neighbourhood
factory = self.the_geom.getFactory()
builder = GeometryBuilder(factory)
builder.addCoordinate(coordinate.x + 7000, coordinate.y)
builder.addCoordinate(coordinate.x + 7000, coordinate.y + 7000)
builder.addCoordinate(coordinate.x - 7000, coordinate.y + 7000)
builder.addCoordinate(coordinate.x - 7000, coordinate.y)
ring = builder.createPolygon()

#check to see if any other cougars are in this neighbourhood polygon and move accordingly
for otherCougar as Cougar in self.model.cougars:
  if (not otherCougar.equals(self) and ring.contains(otherCougar.the_geom)):
    #move towards that other cougar quickly
    print otherCougar.name, "within range of" , self.name
    otherCoordinate = otherCougar.the_geom.coordinate
    xDiff = coordinate.x - otherCoordinate.x
    yDiff = coordinate.y - otherCoordinate.y
    #jump half the distance to the other cougar
    coordinate.x = coordinate.x + (xDiff/2)
    coordinate.y = coordinate.y + (yDiff/2)
    break


However, when I run this code I get  this error:

Block: default_package.Cougar.move, line: 30
Syntax Error:
  for otherCougar as Cougar in self.model.cougars:
                                                   ^

As this is the last exercise using this model I have nothing to check mine against, so I really don't know what the problem is.
I'm wondering if it has something to do with the 'otherCougar' . I don't see anything in the tutorial telling me to create this object, or how to do so,  but it seems strange to me that suddenly it's there.

Thanks!

Outcomes