Questions on attributes #99
Replies: 0 comments 2 replies
-
Dear,
I think that what you are looking for is the *get* operator.
see below an example:
*model* NewModel
*global* {
*init* {
*create* *people*;
*ask* *people* {
*write* *species*(*self*).*attributes*;
*loop* n *over*: *species*(*self*).*attributes* {
*write self get(n);*
}
}
}
}
*species* people *skills*: [*moving*] {}
Cheers
Benoit
Le mar. 7 sept. 2021 à 20:16, Aya-Badawy89 ***@***.***> a
écrit :
… Suppose we have this code:
species aya skills:[fipa] {
int x <- 4;
int y <- 5;
reflex {
write species(self).attributes;
}
}
How can I make the agent get the value of the attribute whose name is (x)?
I know of course that Gama does that automatically if I just write (x).
However, I wanted the agent to get the value using the string name of the
variable because it can help in communicating and argumenting. For example,
when an agent tells another agent an information about the variable whose
name is (x), the agent should be able to go to this variable by its name
and check it, then they can talk about it. So, is it possible to get values
of variables with their string names?
Thank you in advance
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/gama-platform/gama/discussions/3181>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL3WSUBANZZDNJPKBZ4PQTUAZJGLANCNFSM5DS5VWEQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Aya-Badawy89
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suppose we have this code:
How can I make the agent get the value of the attribute whose name is (x)?
I know of course that Gama does that automatically if I just write (x). However, I wanted the agent to get the value using the string name of the variable because it can help in communicating and argumenting. For example, when an agent tells another agent an information about the variable whose name is (x), the agent should be able to go to this variable by its name and check it, then they can talk about it. So, is it possible to get values of variables with their string names?
Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions