Comments (1)
Agent Function/CUDA Syntax
FLAMGPU agent functions are written using CUDA, which itself is a form of C++ (albeit lacking support for most of the standard library). The syntax required to write agent functions is likely to be cover a small subset of available C++ feature, common to other C style languages such as Java and C# like control flow operations, rather than needing to learn about technical features such as manual memory management and pointers.
If you're using the Python API and are unfamiliar with these languages, the difference between common statements is outlined below:
Variables
Python
foo = 5
foo += 2
bar = foo
CUDA
int foo = 5;
foo += 2;
int bar = foo;
Unlike python, CUDA requires variables types to be specified. The types supported by FLAMEGPU are:
Signed Integer | Unsigned Integer | Floating Point |
---|---|---|
int / int32_t |
unsigned int / uint32_t |
float |
long long / int64_t |
unsigned long long / int64_t |
double |
signed char / int8_t |
unsigned char / int8_t |
|
short / int16_t |
unsigned short / int16_t |
if-else statements
Python
if foo == 1:
bar = 5
elif foo == 2:
bar = 6
else:
foo = 1
bar = 7
CUDA
int bar;
if (foo == 1) {
bar = 5;
} else if (foo == 2) {
bar = 6;
} else {
foo = 1;
bar = 7;
}
CUDA uses curly brackets instead of indentation for scoping blocks. (The brackets aren't strictly required if there's only a single statement (;
) in the block.
for loops
Python
for i in range(10):
# do something
CUDA
for (int i = 0; i < 10; ++i) {
// do something
}
For loops have 3 parts, separated by semi colons; for(<variable definition>;<condition>;<post-iteration action>)
.
etc..
from flamegpu2-docs.
Related Issues (20)
- Critical title level warnings HOT 4
- Documentation landing page
- Sidebar link order
- Windows CMake guide, how to use non-default CUDA version HOT 2
- Add VSCode debugging example(s) HOT 1
- Github Actions node deprecation warnings
- Document cleanup() HOT 1
- JSON is no longer strictly valid JSON
- Message list persistence
- Improve documentation around how to use agent states
- Vis Agent State hiding HOT 1
- `newProperty` in Agent Variables documentation
- Array msg, how to get message index within array during iteration
- CI: purge `gh-pages` on each publication
- Beginner's feedback for improving documentation HOT 6
- Python agent sort code example wrong
- CMake: flamegpu_add_library
- AgentDescription::setSortPeriod(0) is not documented
- Improve coverage of agent state transitions.
- API Docs not currently built on docs website
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flamegpu2-docs.