Group Abstract Group Abstract

Message Boards Message Boards

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

Is there an easy way for multiple turtles analog?

Posted 4 years ago

I am interested in intrinsic geometry. For this reason I work with multiple turtles (turtle geometry). In JULIA this is easy with mutable struct: enter image description here

So it's possible to have t1=Turtle(0,...(1,0,0)) or t2=Turtle(1.0,...,(1,1,0)) etc. Mathematica is not ideal for OOP(!?). Is there an easy way for multiple turtles analog struct? A single turtle is no problem... Thank You.

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
POSTED BY: Albert Gaechter
POSTED BY: Jason Biggs

Hi I have still a problem with this approach. I can define a cardioide for example:

t = newTurtle[{0, 0}, {0, 1}];
cardioide[a_] := Table[
   {t["forward", 8/3*a*N[Cos[i/3]]*0.01745]; t["left", 1 Degree]; 
    t["position"]}, {i, 0, 9.425, 0.01745}];
ListLinePlot[cardioide[2], AspectRatio -> Automatic]
![cardioide][1]

With t2 = newTurtle[{0, 0}, {1, 0}]; and a new definition for cardioide[a_] a new cardioide can be drawn. But this is not the meaning of multiple turtles (or OOP). The goal is: define once, use multiple time. Is there a possibility to define cardioide[t,a] := Table[...] and use this definition with cardioide[t1,2] or cardioide[t2,1.5]? In Julia I have function forward(t::Turtle,d) with forward(t1,50) or forward(t2,-20). Kind regards!

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 4 years ago
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