RepastHPC  2.3.1
Turtle.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * Turtle.h
36  *
37  * Created on: Jul 15, 2010
38  * Author: nick
39  */
40 
41 #ifndef TURTLE_H_
42 #define TURTLE_H_
43 
44 #include "AbstractRelogoAgent.h"
45 #include "relogo.h"
46 #include "Observer.h"
47 #include "utility.h"
48 
49 namespace repast {
50 
51 namespace relogo {
52 
53 class RelogoLink;
54 class Patch;
55 
59 class Turtle: public AbstractRelogoAgent {
60 
61 public:
62 
63  using RelogoAgent::xCor;
64  using RelogoAgent::yCor;
65 
70  Turtle(repast::AgentId id, Observer* observer);
71  virtual ~Turtle() {
72  }
73 
74  // Doc from RelogoAgent.h
75  virtual void hatchCopy(RelogoAgent* parent){
76  Turtle* parentTurtle = (Turtle*)parent;
77  _heading = parentTurtle->heading();
78  }
79 
86  void xCor(double x);
87 
94  void yCor(double y);
95 
103  void setxy(double x, double y);
104 
110  virtual int pxCor() const;
111 
117  virtual int pyCor() const;
118 
125  void die();
126 
134  void createLinkWith(Turtle* turtle, const std::string& network = DEFAULT_UNDIR_NET);
135 
148  template<typename LinkCreator>
149  void createLinkWithLC(Turtle* turtle, LinkCreator& creator, const std::string& network = DEFAULT_UNDIR_NET);
150 
161  template<typename AgentType>
162  void createLinksWith(AgentSet<AgentType>& agents, const std::string& network = DEFAULT_UNDIR_NET);
163 
180  template<typename AgentType, typename LinkCreator>
181  void createLinksWithLC(AgentSet<AgentType>& agents, LinkCreator& creator, const std::string& network =
182  DEFAULT_UNDIR_NET);
183 
191  void createLinkFrom(Turtle* turtle, const std::string& network = DEFAULT_DIR_NET);
192 
204  template<typename LinkCreator>
205  void createLinkFromLC(Turtle* turtle, LinkCreator& linkCreator, const std::string& network = DEFAULT_DIR_NET);
206 
218  template<typename AgentType>
219  void createLinksFrom(AgentSet<AgentType>& agents, const std::string& network = DEFAULT_DIR_NET);
220 
234  template<typename AgentType, typename LinkCreator>
235  void createLinksFromLC(AgentSet<AgentType>& agents, LinkCreator& creator, const std::string& network =
236  DEFAULT_DIR_NET);
237 
248  template<typename AgentType>
249  void createLinksTo(AgentSet<AgentType>& agents, const std::string& network = DEFAULT_DIR_NET);
250 
264  template<typename AgentType, typename LinkCreator>
265  void
266  createLinksToLC(AgentSet<AgentType>& agents, LinkCreator& creator, const std::string& network = DEFAULT_DIR_NET);
267 
275  void createLinkTo(Turtle* turtle, const std::string& network = DEFAULT_DIR_NET);
276 
287  template<typename LinkCreator>
288  void createLinkToLC(Turtle* turtle, LinkCreator& linkCreator, const std::string& network = DEFAULT_DIR_NET);
289 
300  boost::shared_ptr<RelogoLink> inLinkFrom(Turtle* turtle, const std::string& name = DEFAULT_DIR_NET);
301 
312  boost::shared_ptr<RelogoLink> outLinkTo(Turtle* turtle, const std::string& name = DEFAULT_DIR_NET);
313 
322  boost::shared_ptr<RelogoLink> linkWith(Turtle* turtle, const std::string& name = DEFAULT_UNDIR_NET);
323 
335  bool linkNeighborQ(Turtle* turtle, const std::string& name = DEFAULT_UNDIR_NET);
336 
345  template<typename AgentType>
346  void linkNeighbors(AgentSet<AgentType>& out, const std::string& name = DEFAULT_UNDIR_NET);
347 
359  bool inLinkNeighborQ(Turtle* turtle, const std::string& name = DEFAULT_DIR_NET);
360 
369  template<typename AgentType>
370  void inLinkNeighbors(AgentSet<AgentType>& out, const std::string& name = DEFAULT_DIR_NET);
371 
383  bool outLinkNeighborQ(Turtle* turtle, const std::string& name = DEFAULT_DIR_NET);
384 
393  template<typename AgentType>
394  void outLinkNeighbors(AgentSet<AgentType>& out, const std::string& name = DEFAULT_DIR_NET);
395 
402  void moveTo(Turtle* turtle);
403 
409  void moveTo(Patch* patch);
410 
416  void move(double distance);
417 
423  void mv(double distance) {
424  move(distance);
425  }
426 
433  void jump(double distance) {
434  if (canMoveQ(distance))
435  forward(distance);
436  }
437 
443  void forward(double distance) {
444  move(distance);
445  }
446 
452  void backward(double distance) {
453  move(-distance);
454  }
455 
461  void fd(double distance) {
462  forward(distance);
463  }
464 
470  void bk(double distance) {
471  backward(-distance);
472  }
473 
492  template<typename PatchType, typename ValueGetter>
493  void downhill(ValueGetter& getter);
494 
512  template<typename PatchType, typename ValueGetter>
513  void downhill4(ValueGetter& getter);
514 
531  template<typename PatchType, typename ValueGetter>
532  void uphill(ValueGetter& getter);
533 
551  template<typename PatchType, typename ValueGetter>
552  void uphill4(ValueGetter& getter);
553 
561  double dx() const;
562 
570  double dy() const;
571 
579  bool canMoveQ(double distance) const;
580 
588  float towards(RelogoAgent* agent) const;
589 
598  float towardsxy(double x, double y) const;
599 
607  float towards(const Point<double>& location) const;
608 
616  double distance(Turtle* turtle) const;
617 
623  float heading() const {
624  return _heading;
625  }
626 
632  void heading(float heading);
633 
639  template<typename PatchType>
640  PatchType* patchHere() const;
641 
647  void face(Turtle* turtle);
648 
654  void face(Patch* patch);
655 
662  void facexy(double nx, double ny);
663 
670  void left(float degrees);
671 
678  void lt(float degrees);
679 
693  template<typename PatchType>
694  PatchType* patchLeftAndAhead(float angleInDegrees, double distance);
695 
709  template<typename PatchType>
710  PatchType* patchRightAndAhead(float angleInDegrees, double distance);
711 
712 private:
713  float _heading;
714  bool moved;
715 
716  // contains the "tied" turtles
717  typedef boost::unordered_set<Turtle*, AgentHashId<Turtle> > TiedSetType;
718  TiedSetType fixedLeaves, freeLeaves;
719 
720  /*
721  * Moves tied turtles vector diff between oldLocation and this
722  * turtles current location
723  */
724  void moveTiedTurtles(const Point<double>& oldLocation);
725  /*
726  * Moves a tied turtle as the result of this turtle changing its heading.
727  */
728  void moveTiedTurtle(Turtle* t, float angleTurned);
729 
730 };
731 
732 template<typename LinkCreator>
733 void Turtle::createLinkFromLC(Turtle* turtle, LinkCreator& linkCreator, const std::string& network) {
734  _observer->createLink(turtle, this, network, linkCreator);
735 }
736 
737 template<typename LinkCreator>
738 void Turtle::createLinkToLC(Turtle* turtle, LinkCreator& linkCreator, const std::string& network) {
739  _observer->createLink(this, turtle, network, linkCreator);
740 }
741 
742 template<typename LinkCreator>
743 void Turtle::createLinkWithLC(Turtle* turtle, LinkCreator& linkCreator, const std::string& network) {
744  _observer->createLink(this, turtle, network, linkCreator);
745 }
746 
747 template<typename AgentType>
748 void Turtle::createLinksWith(AgentSet<AgentType>& agents, const std::string& network) {
749  for (size_t i = 0, n = agents.size(); i < n; i++) {
750  _observer->createLink(this, agents[i], network);
751  }
752 }
753 
754 template<typename AgentType, typename LinkCreator>
755 void Turtle::createLinksWithLC(AgentSet<AgentType>& agents, LinkCreator& creator, const std::string& network) {
756  for (size_t i = 0, n = agents.size(); i < n; i++) {
757  _observer->createLink(this, agents[i], network, creator);
758  }
759 }
760 
761 template<typename AgentType>
762 void Turtle::createLinksFrom(AgentSet<AgentType>& agents, const std::string& network) {
763  for (size_t i = 0, n = agents.size(); i < n; i++) {
764  _observer->createLink(agents[i], this, network);
765  }
766 }
767 
768 template<typename AgentType, typename LinkCreator>
769 void Turtle::createLinksFromLC(AgentSet<AgentType>& agents, LinkCreator& creator, const std::string& network) {
770  for (size_t i = 0, n = agents.size(); i < n; i++) {
771  _observer->createLink(agents[i], this, network, creator);
772  }
773 }
774 
775 template<typename AgentType>
776 void Turtle::createLinksTo(AgentSet<AgentType>& agents, const std::string& network) {
777  for (size_t i = 0, n = agents.size(); i < n; i++) {
778  _observer->createLink(this, agents[i], network);
779  }
780 }
781 
782 template<typename AgentType, typename LinkCreator>
783 void Turtle::createLinksToLC(AgentSet<AgentType>& agents, LinkCreator& creator, const std::string& network) {
784  for (size_t i = 0, n = agents.size(); i < n; i++) {
785  _observer->createLink(this, agents[i], network, creator);
786  }
787 }
788 
789 template<typename AgentType>
790 void Turtle::linkNeighbors(AgentSet<AgentType>& out, const std::string& name) {
791  _observer->predecessors(this, name, out);
792 }
793 
794 template<typename AgentType>
795 void Turtle::inLinkNeighbors(AgentSet<AgentType>& out, const std::string& name) {
796  _observer->predecessors(this, name, out);
797 }
798 
799 template<typename AgentType>
800 void Turtle::outLinkNeighbors(AgentSet<AgentType>& out, const std::string& name) {
801  _observer->successors(this, name, out);
802 }
803 
804 template<typename PatchType>
805 PatchType* Turtle::patchHere() const {
806  return _observer->patchAt<PatchType> (doubleCoordToInt(_location[0]), doubleCoordToInt(_location[1]));
807 }
808 
809 template<typename PatchType, typename ValueGetter>
810 void Turtle::uphill(ValueGetter& getter) {
811  PatchType* myPatch = patchHere<PatchType> ();
812  moveTo(myPatch);
813  // ".template" is needed to tell the compiler that "<" is
814  // a template and not a less than.
815  AgentSet<PatchType> patches = (*myPatch).template neighbors<PatchType> ();
816  PatchType* max = patches.maxOneOf(getter);
817  if (getter(max) > getter(myPatch)) {
818  face(max);
819  moveTo(max);
820  }
821 }
822 
823 template<typename PatchType, typename ValueGetter>
824 void Turtle::uphill4(ValueGetter& getter) {
825  PatchType* myPatch = patchHere<PatchType> ();
826  moveTo(myPatch);
827  // ".template" is needed to tell the compiler that "<" is
828  // a template and not a less than.
829  AgentSet<PatchType> patches = (*myPatch).template neighbors4<PatchType> ();
830  PatchType* max = patches.maxOneOf(getter);
831  if (getter(max) > getter(myPatch)) {
832  face(max);
833  moveTo(max);
834  }
835 }
836 
837 template<typename PatchType, typename ValueGetter>
838 void Turtle::downhill(ValueGetter& getter) {
839  PatchType* myPatch = patchHere<PatchType> ();
840  moveTo(myPatch);
841  // ".template" is needed to tell the compiler that "<" is
842  // a template and not a less than.
843  AgentSet<PatchType> patches = (*myPatch).template neighbors<PatchType> ();
844  PatchType* min = patches.minOneOf(getter);
845  if (getter(min) < getter(myPatch)) {
846  face(min);
847  moveTo(min);
848  }
849 }
850 
851 template<typename PatchType, typename ValueGetter>
852 void Turtle::downhill4(ValueGetter& getter) {
853  PatchType* myPatch = patchHere<PatchType> ();
854  moveTo(myPatch);
855  // ".template" is needed to tell the compiler that "<" is
856  // a template and not a less than.
857  AgentSet<PatchType> patches = (*myPatch).template neighbors4<PatchType> ();
858  PatchType* min = patches.minOneOf(getter);
859  if (getter(min) < getter(myPatch)) {
860  face(min);
861  moveTo(min);
862  }
863 }
864 
865 template<typename PatchType>
866 PatchType* Turtle::patchLeftAndAhead(float angleInDegrees, double distance) {
867  float heading = fmodf(_heading - angleInDegrees, 360);
868  if (heading < 0)
869  heading += 360;
870  std::vector<double> disp = calcDisplacementFromHeadingDistance(heading, distance);
871  return static_cast<PatchType*> (_observer->patchAt(_location, disp[0], disp[1]));
872 }
873 
874 template<typename PatchType>
875 PatchType* Turtle::patchRightAndAhead(float angleInDegrees, double distance) {
876  float heading = fmodf(angleInDegrees + _heading, 360);
877  if (heading < 0)
878  heading += 360;
879  std::vector<double> disp = calcDisplacementFromHeadingDistance(heading, distance);
880  return static_cast<PatchType*> (_observer->patchAt(_location, disp[0], disp[1]));
881 }
882 
883 }
884 }
885 
886 #endif /* TURTLE_H_ */
repast::relogo::Turtle::inLinkFrom
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
repast::relogo::RelogoAgent::yCor
double yCor() const
Gets the y coordinate of the agent's location.
Definition: RelogoAgent.cpp:53
repast::relogo::Turtle::backward
void backward(double distance)
Moves this turtle backward the specified distance.
Definition: Turtle.h:452
repast::relogo::Turtle::createLinkTo
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
repast::relogo::Turtle::move
void move(double distance)
Moves this turtle the specified distance along the current heading.
Definition: Turtle.cpp:144
repast::relogo::Turtle::createLinksFromLC
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
repast::relogo::Turtle::patchLeftAndAhead
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
repast::relogo::Turtle::createLinksToLC
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
repast::relogo::Turtle::uphill4
void uphill4(ValueGetter &getter)
Moves this turtle to the patch with highest value as retrieved via the ValueGetter.
Definition: Turtle.h:824
repast::relogo::Turtle::towardsxy
float towardsxy(double x, double y) const
Gets the heading from this turtle to the specified location.
Definition: Turtle.cpp:205
repast::relogo::Turtle::face
void face(Turtle *turtle)
Sets the turtles heading to face towards the specified turtle.
Definition: Turtle.cpp:222
repast::relogo::Observer::successors
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
repast::relogo::Observer::createLink
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
repast::relogo::RelogoAgent
Base agent for Relogo.
Definition: RelogoAgent.h:60
repast::relogo::Observer::predecessors
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
repast::relogo::Turtle::facexy
void facexy(double nx, double ny)
Sets the turtles heading to face the specified coordinates.
Definition: Turtle.cpp:234
repast::relogo::AbstractRelogoAgent
Abstract base class for turtles and patches.
Definition: AbstractRelogoAgent.h:55
repast::relogo::Turtle::setxy
void setxy(double x, double y)
Sets the x and y coordinate of the Turtle's location.
Definition: Turtle.cpp:71
repast::AgentId
Agent identity information.
Definition: AgentId.h:60
repast::relogo::Turtle::mv
void mv(double distance)
Moves this turtle the specified distance along the current heading.
Definition: Turtle.h:423
repast::relogo::AgentSet
Specialized indexable collection class for agents.
Definition: AgentSet.h:82
repast::relogo::AgentSet::minOneOf
T * minOneOf(const ValueGetter &getter)
Gets the set member that has the minimum value of the number returned by ValueGetter.
Definition: AgentSet.h:460
repast::relogo::Turtle::linkNeighbors
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
repast::relogo::Turtle::createLinksTo
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
repast::relogo::Turtle::patchRightAndAhead
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
repast::relogo::Turtle::canMoveQ
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
repast::relogo::Turtle::createLinkWithLC
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
repast::relogo::Turtle::bk
void bk(double distance)
Moves this turtle backward the specified distance.
Definition: Turtle.h:470
repast::relogo::Turtle::linkWith
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
repast::relogo::Turtle::forward
void forward(double distance)
Moves this turtle forward the specified distance.
Definition: Turtle.h:443
repast::relogo::Turtle::jump
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
repast::relogo::Turtle::towards
float towards(RelogoAgent *agent) const
Gets the heading from this turtle to the specified RelogoAgent (turtle or patch).
Definition: Turtle.cpp:201
repast::relogo::Turtle::moveTo
void moveTo(Turtle *turtle)
Moves this turtle to the location of the specified turtle.
Definition: Turtle.cpp:136
repast::relogo::Turtle::uphill
void uphill(ValueGetter &getter)
Moves this turtle to the patch with highest value as retrieved via the ValueGetter.
Definition: Turtle.h:810
repast::relogo::Turtle::inLinkNeighbors
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
repast::relogo::Turtle::outLinkNeighbors
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
repast::relogo::Turtle::outLinkTo
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
repast::relogo::Observer::patchAt
PatchType * patchAt(int x, int y)
Gets the patch at the specified coordinates.
Definition: Observer.h:793
repast::relogo::RelogoAgent::location
Point< double > location() const
Gets the location of this RelogoAgent.
Definition: RelogoAgent.h:111
repast::relogo::Turtle::distance
double distance(Turtle *turtle) const
Gets the distance from this turtle to the specified turtle.
Definition: Turtle.cpp:209
repast::relogo::Turtle::fd
void fd(double distance)
Moves this turtle forward the specified distance.
Definition: Turtle.h:461
repast::relogo::Turtle::createLinksFrom
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
repast::relogo::Turtle::createLinkFrom
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
repast::relogo::Turtle::lt
void lt(float degrees)
Turns the turtle left by the specified number of degrees.
Definition: Turtle.cpp:244
repast::relogo::Turtle::createLinkFromLC
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
repast::relogo::Turtle::die
void die()
Removes this turtle from the world.
Definition: Turtle.cpp:67
repast::relogo::RelogoAgent::hatchCopy
virtual void hatchCopy()
If this ReLogo agent is 'hatched', makes an appropriate copy, setting instance variables as appropria...
Definition: RelogoAgent.h:119
repast::relogo::Turtle::left
void left(float degrees)
Turns the turtle left by the specified number of degrees.
Definition: Turtle.cpp:240
repast::relogo::Turtle::pyCor
virtual int pyCor() const
Gets the Patch x coordinate of this Turtle.
Definition: Turtle.cpp:278
repast::relogo::Turtle::downhill4
void downhill4(ValueGetter &getter)
Moves this turtle to the patch with lowest value as retrieved via the ValueGetter.
Definition: Turtle.h:852
repast::relogo::Turtle::dx
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
repast::relogo::Turtle::pxCor
virtual int pxCor() const
Gets the Patch x coordinate of this Turtle.
Definition: Turtle.cpp:274
repast::relogo::RelogoAgent::xCor
double xCor() const
Gets the x coordinate of the agent's location.
Definition: RelogoAgent.cpp:49
repast::relogo::Turtle::inLinkNeighborQ
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
repast::relogo::AgentSet::size
size_t size() const
Gets the size of this AgentSet.
Definition: AgentSet.h:192
repast::relogo::Turtle::downhill
void downhill(ValueGetter &getter)
Moves this turtle to a neighboring patch with lowest value as retrieved via the ValueGetter.
Definition: Turtle.h:838
repast::relogo::Turtle::Turtle
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
repast::relogo::Turtle::createLinkWith
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
repast::relogo::Turtle::linkNeighborQ
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
repast::relogo::Turtle::createLinksWithLC
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
repast::relogo::Observer
Implementation of a logo Observer.
Definition: Observer.h:110
repast::Point< double >
repast::relogo::Turtle::outLinkNeighborQ
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
repast::relogo::Patch
A logo patch.
Definition: Patch.h:58
repast::relogo::Turtle
Relogo Turtle implementation.
Definition: Turtle.h:59
repast::relogo::Turtle::dy
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
repast::relogo::Turtle::heading
float heading() const
Gets this Turtle's current heading.
Definition: Turtle.h:623
repast::relogo::Turtle::createLinkToLC
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
repast::relogo::Turtle::createLinksWith
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
repast::relogo::Turtle::patchHere
PatchType * patchHere() const
Gets the patch under this turtle.
Definition: Turtle.h:805
repast::relogo::AgentSet::maxOneOf
T * maxOneOf(const ValueGetter &getter)
Gets the set member that has the maximum value of the number returned by ValueGetter.
Definition: AgentSet.h:487