List Info

Thread: Help! How do I display what a turtle owns???




Help! How do I display what a turtle owns???
country flaguser name
United States
2008-03-12 04:25:13

Hey All! I have a program where a fisherman is collecting fish in a
lake. He catches different breeds of turtles and gains energy from
doing so. I want to plot his energy, but I can't figure out how to
";show" "display" or "count" things that turtles own. Any ideas? How
do I code for it. I've tried "energy of fisherman" and things like
that but it expects a reporter. Any help would be much appreciated!

__._,_.___
.

__,_._,___
Re: Help! How do I display what a turtle owns???
country flaguser name
United States
2008-03-12 08:52:21

Print expects a reporter, by which NetLogo means that Print expects to
be followed by anything that reports a value, in other words, an
expression.

print "hello" ;; print the string "hello"
print heading ;; print the turtle's heading (assumes a turtle is
running this line
print count turtles ;; print the total number of turtles

You can always *ask* the fisherman to print things, like a variable.
You can also add a plot to the view and plot values on it.

For example:

;; assumes breed [ fishermen fisherman ]
;; assumes fishermen-own [ energy ]
ask fishermen
[ print energy ;; prints value of energy in the command center ]
output-print energy ;; prints value of energy in the output control,
or command center
plot energy ;; adds a mark for the value of energy to the current
plot (error if no plot)
]

If you want the observer to plot the total value of all fishermen's energy:

plot sum [ energy ] of fishermen ;; version 4.x syntax
plot sum values-from fishermen [ energy ] ;; version 3.x syntax

;; to break it down...

plot ;;; place in the plot a mark for
sum ;; the sum of the list
[ energy ] ;; made of the values of the energy variable
of fishermen ;; from all the fishermen

Hope this helps!

~~James

On Wed, Mar 12, 2008 at 5:25 AM, amarlantes < amarlantes%40yahoo.com">amarlantesyahoo.com> wrote:
&gt; Hey All! I have a program where a fisherman is collecting fish in a
> lake. He catches different breeds of turtles and gains energy from
>; doing so. I want to plot his energy, but I can't figure out how to
> "show" "display" or "count" things that turtles own. Any ideas? How
> do I code for it. I've tried "energy of fisherman&quot; and things like
>; that but it expects a reporter. Any help would be much appreciated!
>

__._,_.___
.

__,_._,___
Re: Help! How do I display what a turtle owns???
country flaguser name
United States
2008-03-12 08:50:40

On Wed, Mar 12, 2008 at 9:25 AM, amarlantes < amarlantes%40yahoo.com">amarlantesyahoo.com> wrote:
&gt; I've tried "energy of fisherman&quot;

have you tried: "[energy] of fisherman&quot;?

__._,_.___
.

__,_._,___
Re: Help! How do I display what a turtle owns???
country flaguser name
United States
2008-03-12 08:48:48
On Mar 12, 2008, at 5:25 AM, amarlantes wrote:

> Hey All! I have a program where a fisherman is
collecting fish in a
>  lake. He catches different breeds of turtles and gains
energy from
>  doing so. I want to plot his energy, but I can't
figure out how to
>  "show" "display" or
"count" things that turtles own. Any ideas? How
>  do I code for it. I've tried "energy of
fisherman" and things like
>  that but it expects a reporter. Any help would be much
appreciated!

If you have

breed [ fishermen fisherman ]  fishermen-own [ energy ]

and you want to plot a fisherman's energy then you just add
a plot to 
the Interface and in the go procedure

plot [energy] of the-fisherman

where the-fisherman is a reference to the turtle who is
fishing. This 
assumes the observer is running the code. If you have the
fisherman 
running a procedure, you can just put

;by fisherman
plot energy

Be sure to read the section in the Programming Manual about
plotting, 
and see the plotting Code Example in the Models Library.

HTH,
Jim Lyons
  Approximate file size 1756 bytes
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )