olimasters / magnet-automaton

Visualised automaton-based simulation of a magnet
1 stars 0 forks source link

Updating slows down to a crawl for large magnets #21

Open olimasters opened 6 years ago

olimasters commented 6 years ago

This is probably due to two factors:

  1. The isStable method is very inefficient since it loops over the entire magnet.
  2. Updates are sampled randomly from the entire magnet instead of those cells which are due a flip. This becomes less and less likely to hit one which is due an update when large magnets are nearly stable.

The latter of the above two factors could be desirable in some cases, such as if anyone cares about the stats side of things. The former is never good.

olimasters commented 6 years ago

This should be fixed by storing 'unstableCells' as a class field. Implementation can be done through an array(or std::vector) of capacity equal to an upper bound on the number of possible unstable cells. Assigning George.