44 #include "AbstractRelogoAgent.h"
77 _heading = parentTurtle->
heading();
103 void setxy(
double x,
double y);
110 virtual int pxCor()
const;
117 virtual int pyCor()
const;
148 template<
typename LinkCreator>
149 void createLinkWithLC(
Turtle* turtle, LinkCreator& creator,
const std::string& network = DEFAULT_UNDIR_NET);
161 template<
typename AgentType>
180 template<
typename AgentType,
typename LinkCreator>
204 template<
typename LinkCreator>
205 void createLinkFromLC(
Turtle* turtle, LinkCreator& linkCreator,
const std::string& network = DEFAULT_DIR_NET);
218 template<
typename AgentType>
234 template<
typename AgentType,
typename LinkCreator>
248 template<
typename AgentType>
264 template<
typename AgentType,
typename LinkCreator>
287 template<
typename LinkCreator>
288 void createLinkToLC(
Turtle* turtle, LinkCreator& linkCreator,
const std::string& network = DEFAULT_DIR_NET);
300 boost::shared_ptr<RelogoLink>
inLinkFrom(
Turtle* turtle,
const std::string& name = DEFAULT_DIR_NET);
312 boost::shared_ptr<RelogoLink>
outLinkTo(
Turtle* turtle,
const std::string& name = DEFAULT_DIR_NET);
322 boost::shared_ptr<RelogoLink>
linkWith(
Turtle* turtle,
const std::string& name = DEFAULT_UNDIR_NET);
345 template<
typename AgentType>
369 template<
typename AgentType>
393 template<
typename AgentType>
492 template<
typename PatchType,
typename ValueGetter>
512 template<
typename PatchType,
typename ValueGetter>
531 template<
typename PatchType,
typename ValueGetter>
532 void uphill(ValueGetter& getter);
551 template<
typename PatchType,
typename ValueGetter>
552 void uphill4(ValueGetter& getter);
598 float towardsxy(
double x,
double y)
const;
639 template<
typename PatchType>
662 void facexy(
double nx,
double ny);
670 void left(
float degrees);
678 void lt(
float degrees);
693 template<
typename PatchType>
709 template<
typename PatchType>
717 typedef boost::unordered_set<Turtle*, AgentHashId<Turtle> > TiedSetType;
718 TiedSetType fixedLeaves, freeLeaves;
728 void moveTiedTurtle(
Turtle* t,
float angleTurned);
732 template<
typename LinkCreator>
734 _observer->
createLink(turtle,
this, network, linkCreator);
737 template<
typename LinkCreator>
739 _observer->
createLink(
this, turtle, network, linkCreator);
742 template<
typename LinkCreator>
744 _observer->
createLink(
this, turtle, network, linkCreator);
747 template<
typename AgentType>
749 for (
size_t i = 0, n = agents.
size(); i < n; i++) {
750 _observer->
createLink(
this, agents[i], network);
754 template<
typename AgentType,
typename LinkCreator>
756 for (
size_t i = 0, n = agents.
size(); i < n; i++) {
757 _observer->
createLink(
this, agents[i], network, creator);
761 template<
typename AgentType>
763 for (
size_t i = 0, n = agents.
size(); i < n; i++) {
764 _observer->
createLink(agents[i],
this, network);
768 template<
typename AgentType,
typename LinkCreator>
770 for (
size_t i = 0, n = agents.
size(); i < n; i++) {
771 _observer->
createLink(agents[i],
this, network, creator);
775 template<
typename AgentType>
777 for (
size_t i = 0, n = agents.
size(); i < n; i++) {
778 _observer->
createLink(
this, agents[i], network);
782 template<
typename AgentType,
typename LinkCreator>
784 for (
size_t i = 0, n = agents.
size(); i < n; i++) {
785 _observer->
createLink(
this, agents[i], network, creator);
789 template<
typename AgentType>
794 template<
typename AgentType>
799 template<
typename AgentType>
804 template<
typename PatchType>
806 return _observer->
patchAt<PatchType> (doubleCoordToInt(_location[0]), doubleCoordToInt(_location[1]));
809 template<
typename PatchType,
typename ValueGetter>
811 PatchType* myPatch = patchHere<PatchType> ();
816 PatchType* max = patches.
maxOneOf(getter);
817 if (getter(max) > getter(myPatch)) {
823 template<
typename PatchType,
typename ValueGetter>
825 PatchType* myPatch = patchHere<PatchType> ();
830 PatchType* max = patches.
maxOneOf(getter);
831 if (getter(max) > getter(myPatch)) {
837 template<
typename PatchType,
typename ValueGetter>
839 PatchType* myPatch = patchHere<PatchType> ();
844 PatchType* min = patches.
minOneOf(getter);
845 if (getter(min) < getter(myPatch)) {
851 template<
typename PatchType,
typename ValueGetter>
853 PatchType* myPatch = patchHere<PatchType> ();
858 PatchType* min = patches.
minOneOf(getter);
859 if (getter(min) < getter(myPatch)) {
865 template<
typename PatchType>
867 float heading = fmodf(_heading - angleInDegrees, 360);
870 std::vector<double> disp = calcDisplacementFromHeadingDistance(
heading,
distance);
871 return static_cast<PatchType*
> (_observer->
patchAt(_location, disp[0], disp[1]));
874 template<
typename PatchType>
876 float heading = fmodf(angleInDegrees + _heading, 360);
879 std::vector<double> disp = calcDisplacementFromHeadingDistance(
heading,
distance);
880 return static_cast<PatchType*
> (_observer->
patchAt(_location, disp[0], disp[1]));
boost::shared_ptr< RelogoLink > inLinkFrom(Turtle *turtle, const std::string &name=DEFAULT_DIR_NET)
Gets the link from the specified turtle to this one in the specified network which defaults to the de...
Definition: Turtle.cpp:294
double yCor() const
Gets the y coordinate of the agent's location.
Definition: RelogoAgent.cpp:53
void backward(double distance)
Moves this turtle backward the specified distance.
Definition: Turtle.h:452
void createLinkTo(Turtle *turtle, const std::string &network=DEFAULT_DIR_NET)
Creates a link from this Turtle to the specified turtle in the named network which defaults to the de...
Definition: Turtle.cpp:290
void move(double distance)
Moves this turtle the specified distance along the current heading.
Definition: Turtle.cpp:144
void createLinksFromLC(AgentSet< AgentType > &agents, LinkCreator &creator, const std::string &network=DEFAULT_DIR_NET)
Creates links to this turtle from all the agents in the agentset using the link creator and in the na...
Definition: Turtle.h:769
PatchType * patchLeftAndAhead(float angleInDegrees, double distance)
Gets the patch that is the specified distance from this turtle, at the specified angle (turning left)...
Definition: Turtle.h:866
void createLinksToLC(AgentSet< AgentType > &agents, LinkCreator &creator, const std::string &network=DEFAULT_DIR_NET)
Creates links from this turtle to all the agents in the agentset using the link creator and in the na...
Definition: Turtle.h:783
void uphill4(ValueGetter &getter)
Moves this turtle to the patch with highest value as retrieved via the ValueGetter.
Definition: Turtle.h:824
float towardsxy(double x, double y) const
Gets the heading from this turtle to the specified location.
Definition: Turtle.cpp:205
void face(Turtle *turtle)
Sets the turtles heading to face towards the specified turtle.
Definition: Turtle.cpp:222
void successors(RelogoAgent *agent, const std::string &networkName, AgentSet< AgentType > &out)
Gets the network successors of the specified agent in the specified network and puts the result into ...
Definition: Observer.h:766
void createLink(RelogoAgent *source, RelogoAgent *target, const std::string &networkName)
Creates a link between the source and target agents in the named network.
Definition: Observer.cpp:261
Base agent for Relogo.
Definition: RelogoAgent.h:60
void predecessors(RelogoAgent *agent, const std::string &networkName, AgentSet< AgentType > &out)
Gets the network predecessors of the specified agent in the specified network and puts the result int...
Definition: Observer.h:754
void facexy(double nx, double ny)
Sets the turtles heading to face the specified coordinates.
Definition: Turtle.cpp:234
Abstract base class for turtles and patches.
Definition: AbstractRelogoAgent.h:55
void setxy(double x, double y)
Sets the x and y coordinate of the Turtle's location.
Definition: Turtle.cpp:71
Agent identity information.
Definition: AgentId.h:60
void mv(double distance)
Moves this turtle the specified distance along the current heading.
Definition: Turtle.h:423
Specialized indexable collection class for agents.
Definition: AgentSet.h:82
T * minOneOf(const ValueGetter &getter)
Gets the set member that has the minimum value of the number returned by ValueGetter.
Definition: AgentSet.h:460
void linkNeighbors(AgentSet< AgentType > &out, const std::string &name=DEFAULT_UNDIR_NET)
Gets all the network neighbors of this turtle in the named network and puts them in the specified Age...
Definition: Turtle.h:790
void createLinksTo(AgentSet< AgentType > &agents, const std::string &network=DEFAULT_DIR_NET)
Creates links from this turtle to all the agents in the agentset in the named network.
Definition: Turtle.h:776
PatchType * patchRightAndAhead(float angleInDegrees, double distance)
Gets the patch that is the specified distance from this turtle, in the specified degrees (turning rig...
Definition: Turtle.h:875
bool canMoveQ(double distance) const
Gets whether or not this turtle can move the specified distance along its current heading given the c...
Definition: Turtle.cpp:123
void createLinkWithLC(Turtle *turtle, LinkCreator &creator, const std::string &network=DEFAULT_UNDIR_NET)
Creates a link between this turtle and the specified turtle in the specified undirected network,...
Definition: Turtle.h:743
void bk(double distance)
Moves this turtle backward the specified distance.
Definition: Turtle.h:470
boost::shared_ptr< RelogoLink > linkWith(Turtle *turtle, const std::string &name=DEFAULT_UNDIR_NET)
Gets the link between this turtle and the specified on in the named undirected network.
Definition: Turtle.cpp:302
void forward(double distance)
Moves this turtle forward the specified distance.
Definition: Turtle.h:443
void jump(double distance)
Moves this turtle forward the specified distance, if and only if that would not take this turtle outs...
Definition: Turtle.h:433
float towards(RelogoAgent *agent) const
Gets the heading from this turtle to the specified RelogoAgent (turtle or patch).
Definition: Turtle.cpp:201
void moveTo(Turtle *turtle)
Moves this turtle to the location of the specified turtle.
Definition: Turtle.cpp:136
void uphill(ValueGetter &getter)
Moves this turtle to the patch with highest value as retrieved via the ValueGetter.
Definition: Turtle.h:810
void inLinkNeighbors(AgentSet< AgentType > &out, const std::string &name=DEFAULT_DIR_NET)
Gets all the network predecessors of this turtle in the named network and puts them in the specified ...
Definition: Turtle.h:795
void outLinkNeighbors(AgentSet< AgentType > &out, const std::string &name=DEFAULT_DIR_NET)
Gets all the network successors of this turtle in the named network and puts them in the specified ar...
Definition: Turtle.h:800
boost::shared_ptr< RelogoLink > outLinkTo(Turtle *turtle, const std::string &name=DEFAULT_DIR_NET)
Gets the link from the this turtle to the specified turtle in the specified network which defaults to...
Definition: Turtle.cpp:298
PatchType * patchAt(int x, int y)
Gets the patch at the specified coordinates.
Definition: Observer.h:793
Point< double > location() const
Gets the location of this RelogoAgent.
Definition: RelogoAgent.h:111
double distance(Turtle *turtle) const
Gets the distance from this turtle to the specified turtle.
Definition: Turtle.cpp:209
void fd(double distance)
Moves this turtle forward the specified distance.
Definition: Turtle.h:461
void createLinksFrom(AgentSet< AgentType > &agents, const std::string &network=DEFAULT_DIR_NET)
Creates links to this turtle from all the agents in the agentset in the named network.
Definition: Turtle.h:762
void createLinkFrom(Turtle *turtle, const std::string &network=DEFAULT_DIR_NET)
Creates a link to this Turtle from the specified turtle in the named network which defaults to the de...
Definition: Turtle.cpp:282
void lt(float degrees)
Turns the turtle left by the specified number of degrees.
Definition: Turtle.cpp:244
void createLinkFromLC(Turtle *turtle, LinkCreator &linkCreator, const std::string &network=DEFAULT_DIR_NET)
Creates a link to this Turtle from the specified turtle in the named network which defaults to the de...
Definition: Turtle.h:733
void die()
Removes this turtle from the world.
Definition: Turtle.cpp:67
virtual void hatchCopy()
If this ReLogo agent is 'hatched', makes an appropriate copy, setting instance variables as appropria...
Definition: RelogoAgent.h:119
void left(float degrees)
Turns the turtle left by the specified number of degrees.
Definition: Turtle.cpp:240
virtual int pyCor() const
Gets the Patch x coordinate of this Turtle.
Definition: Turtle.cpp:278
void downhill4(ValueGetter &getter)
Moves this turtle to the patch with lowest value as retrieved via the ValueGetter.
Definition: Turtle.h:852
double dx() const
Gets the distance traveled along the x dimension if the turtle were to take one step forward along it...
Definition: Turtle.cpp:214
virtual int pxCor() const
Gets the Patch x coordinate of this Turtle.
Definition: Turtle.cpp:274
double xCor() const
Gets the x coordinate of the agent's location.
Definition: RelogoAgent.cpp:49
bool inLinkNeighborQ(Turtle *turtle, const std::string &name=DEFAULT_DIR_NET)
Gets whether or not there is an edge into this turtle from the specified turtle, in the specified net...
Definition: Turtle.cpp:313
size_t size() const
Gets the size of this AgentSet.
Definition: AgentSet.h:192
void downhill(ValueGetter &getter)
Moves this turtle to a neighboring patch with lowest value as retrieved via the ValueGetter.
Definition: Turtle.h:838
Turtle(repast::AgentId id, Observer *observer)
Creates a Turtle that will have the specified id, and be managed by the specified Observer.
Definition: Turtle.cpp:55
void createLinkWith(Turtle *turtle, const std::string &network=DEFAULT_UNDIR_NET)
Creates a link between this turtle and the specified turtle in the specified undirected network.
Definition: Turtle.cpp:286
bool linkNeighborQ(Turtle *turtle, const std::string &name=DEFAULT_UNDIR_NET)
Gets whether or not this turtle is linked to the specified turtle, in the specified network.
Definition: Turtle.cpp:306
void createLinksWithLC(AgentSet< AgentType > &agents, LinkCreator &creator, const std::string &network=DEFAULT_UNDIR_NET)
Creates links between this turtle and all the agents in the agentset using the link creator and in th...
Definition: Turtle.h:755
Implementation of a logo Observer.
Definition: Observer.h:110
bool outLinkNeighborQ(Turtle *turtle, const std::string &name=DEFAULT_DIR_NET)
Gets whether or not there is an edge from this turtle to the specified turtle, in the specified netwo...
Definition: Turtle.cpp:317
A logo patch.
Definition: Patch.h:58
Relogo Turtle implementation.
Definition: Turtle.h:59
double dy() const
Gets the distance traveled along the y dimension if the turtle were to take one step forward along it...
Definition: Turtle.cpp:218
float heading() const
Gets this Turtle's current heading.
Definition: Turtle.h:623
void createLinkToLC(Turtle *turtle, LinkCreator &linkCreator, const std::string &network=DEFAULT_DIR_NET)
Creates a link from this Turtle to the specified turtle in the named network which defaults to the de...
Definition: Turtle.h:738
void createLinksWith(AgentSet< AgentType > &agents, const std::string &network=DEFAULT_UNDIR_NET)
Creates links between this turtle and all the agents in the AgentSet in the named network.
Definition: Turtle.h:748
PatchType * patchHere() const
Gets the patch under this turtle.
Definition: Turtle.h:805
T * maxOneOf(const ValueGetter &getter)
Gets the set member that has the maximum value of the number returned by ValueGetter.
Definition: AgentSet.h:487