You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/3-behaviour-definition/1-defining-agent-functions.rst
+35-45Lines changed: 35 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,14 @@ method is the only method supported for the python version of FLAMEGPU2.
16
16
Defining an Agent Function
17
17
--------------------------
18
18
19
-
An agent function is defined using the ``FLAMEGPU_AGENT_FUNCTION`` macro. This takes three arguments: a unique name identifying the function, an input
20
-
message communication strategy, and an output message communication strategy. We will discuss messages in more detail later, so for now don't worry about the second and third paramters.
19
+
Agent Functions can be specified as C++ functions, built at compile time when using the C++ interface, or they can be specified as Run-Time Compiled (RTC) functions when using the C++ interface, or the Python interface.
20
+
21
+
An agent function is defined using the ``FLAMEGPU_AGENT_FUNCTION`` macro.
22
+
This takes three arguments: a unique name identifying the function, an input message communication strategy, and an output message communication strategy.
23
+
We will discuss messages in more detail later, so for now don't worry about the second and third parameters.
24
+
25
+
For Non-RTC functions, when using the C++ interface, the ``FLAMEGPU_AGENT_FUNCTION`` macro can be used to declare and define the agent function, which can then be associated with the ``flamegpu::AgentDescription`` object using the ``newFunction`` method.
21
26
22
-
In C++, these definitions should appear before your main function. In python, they should be specified in string literals, with the containing variable'state
23
-
name matching the unique function identifier:
24
27
25
28
.. tabs::
26
29
@@ -32,65 +35,52 @@ name matching the unique function identifier:
32
35
}
33
36
34
37
int main() {
35
-
... // Rest of code
38
+
// ...
36
39
37
-
.. code-tab:: python
40
+
// Attach a function called agent_fn1, defined by the symbol agent_fn1 to the AgentDescription object agent.
If you are using the python interface, you can only use runtime-compiled agent functions and this was presented in
66
-
the previous section, so you can *TODO: skip to the next section*
67
-
68
-
The previously described method for defining an agent function results in the function being compiled at compile time.
69
-
If you know that you want to define your agent behaviours at runtime, you can instead use this method. Otherwise, you can
70
-
*TODO: skip to the next section*
71
-
72
-
To define a runtime-compiled agent function, the function source should be stored in a string:
46
+
When using the Run-Time Compiled (RTC) functions, optionally in the C++ interface or required by the Python interface, the function must be defined in a string and associated with the AgentDescription using the ``newRTCFunction`` method.
73
47
74
48
.. tabs::
75
49
76
50
.. code-tab:: cpp
77
51
78
-
// Define an agent function called agent_fn1 which will be compiled at runtime
79
52
const char* agent_fn1_source = R"###(
53
+
// Define an agent function called agent_fn1 - specified ahead of main function
0 commit comments