Which datatype is fastest for cellular automata?

0 favourites
  • 3 posts
From the Asset Store
It provides information about the device's cellular and wifi connection, and whether the device has an internet connecti
  • I am thinking creating cellular automata in construct. Previously, I have tried using arrays and dictionaries to store cell data. I found that dictionaries worked better with comparisons when using the "has key" condition.

    My question is that should I try to use another datatype like Binary, CSV or JSON. I know that heavy algorithms like cellular automata should be done with code and not events, but unfortunately I don't know javascript syntax.

    I don't know much about big O notation, but if anyone knows the time complexity of comparisons in different datatypes in construct that would also be greatly appreciated.

    Thank you in advance!

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well since cellular automata usually works by looking at neighboring cells a 2d array seems like an easy choice. Guess you could use a dictionary but wouldn't you need to add an entry for each cell?

    Both arrays and dictionaries are rated O(1) for accessing data, which means with a key or index they can access the value with one lookup. So Big O notation doesn't help too much. Arrays are more memory efficient since it's just a list of values, whereas dictionaries store keys and values and there could be other dead space reserved depending how the dictionaries are implemented. But I imagine the speed difference is negligible, you'll hit other bottlenecks first.

    Personally I'd choose the one that looks cleaner.

    Arrat.at(x,y) vs Dictionary.get(x&","&y) but whatever you want to do.

    All those other data objects are just arrays and dictionaries.

    cvs and json are parse text data and then internally are just arrays, and a mix of arrays and dictionaries. Binary is just a 1d array of numbers.

  • Sorry for the late reply, but thank you for your help!

    I decided to use dictionaries and it turned quite messy since I added other information to like the color and life time of each cell but I got it to run quite fast with just events.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)