Organizing a bit for future work/exercises

code
math
systems
Optimization
Decisions
ABM
Information
complexity
Author

Nico

Published

August 24, 2025

Collecting thoughts and code for future project

I have dedicated a bit of my spare time to the RLCS package creation. And it’s still very much ongoing. But as I give myself until end of 2025 to have a first “shared” version of the package, well, I am looking into future work. Something to keep my head busy for 2026, if you will.

New GitHub Repo

Just because I am slowly getting used to sharing my code more and more (in spite of the shame it supposes sometimes, my code being… Well, far from perfect), I thought I’d help myself by setting up a new project early on to collect some ideas.

And so this repo was born earlier today.

On the issue of generating animations

One thing I still struggle with is generating animations in 2D that are visually pleasant and particulary, that are not slow. (Yes, this is related to the above, as I want to be able to “show” agent-based modelling simulations.)

Using RStudio Viewer and image() to follow the evolution of the cellular automata in past exercises has often required, for niceness, for me to edit a video screenshot and accelerate it.

Also, using image(), this is the fastest way I’ve found during my tests:

## From past exercise with Schelling Seggregation Model, I had this:
tf <- function(m) t(m)[, nrow(m):1]
imageM <- function(m, grid = max(dim(m)) <= 25, asp = (nrow(m)-1)/(ncol(m)-1), ...) {
  image(tf(m), asp=asp, axes = FALSE, useRaster=TRUE, ...)
}

t_start <- Sys.time()
for(i in 1:10) {
  imageM(world[[i]])
  Sys.sleep(.2) ## Renders, but runtime goes to 2.22secs for 100*100px.
  ## Not awful, but not great.
}
Sys.time() - t_start

However I try… I just can’t seem to get past the 10 FPS mark, (i.e. reduce the Sys.sleep() there) whatever I do, and that’s only for pre-computed matrices, of reasonable size.

However, if you use the animation package like I did at the end of the code here, for instance:

## Not in RStudio/so post-processing visualization, but can be made fast:
library(animation)
# Create the animation
saveHTML({ ## This one also offers speed controls...
  for (i in 1:100) { ## Careful, it generates one PNG per matrix, and JS/CSS/HTML stuff...
    image(world[[i]], axes=FALSE, useRaster = TRUE, col = grey.colors(256))
    ani.options(interval = 0.02) ## Key to actual visual speed here
  }
},
htmlfile = "random_points.html",
ani.width = 500,
ani.height = 500)

Well, the results are nicer.

Applying this approach to a past exercise on Fire Spread simulation, you get to this result here:

(It’s actually a cut-down version with low resolution as the original capture of it was 26MB big…)

Conclusions

I should really be working on finishing the RLCS project, but I am looking into future work instead, just to keep myself entertained really.