GithubHelp home page GithubHelp logo

Message Wrapping about docs HOT 5 CLOSED

flamegpu avatar flamegpu commented on August 16, 2024 1
Message Wrapping

from docs.

Comments (5)

Robadob avatar Robadob commented on August 16, 2024

from docs.

ptheywood avatar ptheywood commented on August 16, 2024

I have an example of a 4 x 4 x 4 world, with 16 discrete and 16 continuous agents.

The agents are arranged in a grid on the 0 Z plane, at (0,0), (0, 1), etc.

With radius 1 discrete messaging, all agents read 8 discrete messages - it must wrap (and ignores itself).
With spatially partitioned messaging with a radius 1, all agents read 9 messages, including those at the edge.
With spatially partitioned messaging with a radius 4 (i.e 1 bin), all agents read 144 messages (16 * 9).

All agents are in bounds, although I have not checked bin counts manually.

from docs.

Robadob avatar Robadob commented on August 16, 2024

Check whether the generated code matches that I posted above. If it hasn't been changed, it's not technically wrapping or clamping, it's a mish mash inbetween and should be declared undefined behaviour.

Proper wrapping would require use of the modulo operator. And as the C modulo operator doesn't act as a continuous function across 0 (it instead mirrors), you would need to then do further arithmetic of GridDim - (partitionDim%GridDim) if partitionDim began as <0 (iirc).

from docs.

ptheywood avatar ptheywood commented on August 16, 2024

The generated code is the same as above.

For the reading of messages in spatially partitoned messaging where only the moores neighbourhood is considered this is correctly wrapping.
Writing out of the environment bounds is clamped to the bin, but writing out of bounds is effectively undefined behaviour - it shouldn't really be happening.

Discrete messages are wrapped via

#define sWRAP(x,m) (((x)<m)?(((x)<0)?(m+(x)):(x)):(m-(x))) /**<signed integer wrap (no modulus) for negatives where 2m > |x| > m */

Which looks like it should be fine for all sensible radii values. Not sensible values (ie. a radius larger than the environment) is effectively an invalid configuration and is undefined / should be not allowed realistically.

from docs.

ptheywood avatar ptheywood commented on August 16, 2024

Spatially Partitioned Messaging

  • Document that spatial partitioning must result in environments of > 3 bins in the X and Y dimensions or an error will occur
    • In this case the user should just use brute-force messaging
  • Document that spatially partitioned messages wrap in the X,Y dimensions to form a torus
  • Document that outputting a spatially partitioned message outside of the environment bounds is undefined behaviour.
    • This is currently clamped but this should not be relied upon.

Discrete Partitioned Messages

  • Document that radii should be less than or equal to floor((width - 1) / 2) - to avoid reading the same message multiple times, where width is the sqrt(bufferSize)
  • Document that messages wrap in the X Y dimensions, forming a torus.
  • Document that outputting a message with X Y dimensions out of range is undefined behaviour.

from 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.