Giter Club home page Giter Club logo

Comments (1)

Robadob avatar Robadob commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.