Group Abstract Group Abstract

Message Boards Message Boards

1
|
4.7K Views
|
8 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Is there an easy way for multiple turtles analog?

Posted 3 years ago
POSTED BY: Albert Gaechter
8 Replies

Sorry. I have tried surely cardioide[t,a] with Underscore, but in the Reply they are not displayed...

POSTED BY: Albert Gaechter

Thank You very much. Now it works. I have tried with cardioide[t,a], without success (why?, who knows). For me this discussion is terminated. I am satisfied. With kind regards!

POSTED BY: Albert Gaechter

Is there a possibility to define cardioide[t,a] := Table[...]

This is quite simple really, just change your definition from using cardioide[a_] := to cardioide[t_, a_] := and it should work exactly as you describe. Read through this tutorial for information on defining functions in the Wolfram Language.

Looking at your cardioide function, you would do well to remove the list braces inside your table command since the "position" method already returns a list of two coordinates. Something like

cardioide[turtle_, a_ ? NumericQ] := Table[
    turtle["forward",
        (8 / 3) * a * N[Cos[i / 3]] * 0.01745
    ];
    turtle["left", 1 * Degree];
    turtle["position"],
    {i, 0, 9.425, 0.01745}
];
t1 = newTurtle[{0, 0}, {0, 1}];
t2 = newTurtle[{-1, 0}, {0, 1}];
ListLinePlot[
    {cardioide[t1, 2], cardioide[t2, 2]},
    AspectRatio -> Automatic
]
POSTED BY: Jason Biggs
POSTED BY: Albert Gaechter

Thank You very much. This is indeed an approach. I will study this. The great deal of multiple turtles are "hunter prey problems" and superimposed movements.

POSTED BY: Albert Gaechter
POSTED BY: Jason Biggs

Thank You. Yes I know Association, but its not clear for me...Have you an example?

POSTED BY: Albert Gaechter
Posted 3 years ago

Take a look at Association.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard