A Cellular Automata Sznajd Model



If you’re here for the presentation slides

The song in my mind while doing this was:

This post is inspired by a talk from Mirta Galesic which I had the chance to catch at the Symposium on the Science of Stories which was actually a very refreshing one, as it yelled multidiscipline right from the speakers bios.

Anyway, this particular talk was about communicating complex data to the public as it has been shown that people are often more receptive to narratives than to raw data (not everybody’s trained to understand statistics) but how we present this such narratives is crucial to make our statement spread. She stated that people in general don’t care about what scientist say in order to form an opinion but rather the likelihood of having one or another posture in a a certain topics is conditioned by the one from our closest friends. A particular example she gave was about vaccinations; no mather how many papers or interviews to scientist there are about how we should vaccinate, people won’t hear if they have made their minds into something, is just when the ones that sorround them differ when they’ll probably change their minds (sounds like a shame based opinion dynamics).

Then, to hear about that from her made me rethink a model that I had already played with but in networks… the Sznajd. This model is a econophysics one that (believe it or not 😜) is based on the Ising model. This Sznajd model is also known as the united we stand, divided we fall model, this is because it’s build on the premise that your opionion is based on the opinion of those who are really close to you.

1 site convincing

The most basic set of rules for this is the 1 site convincing, which is really simple. First imagine that you are on a regular square lattice sznajd or any type of topology of your like, but let’s go with the square lattice one for ease. Now we start the lattice with a random distribution of two opinion, so each one of the nodes can get opinion 1 with probability p or opinion 2 with probability 1-p. Then, we randomly choose a subset of nodes and make all their neighboors agree with it.


So if we fix some values, like p=0.5 and n=0.1 the number of randomly selected nodes, we could get a video like this one


2 site convincing

To make it more interesting (or realistic) we could say that there’s no way that I’m going to change my whole ideology based on what a random close friend of mine thinks, so what the 2 site convincing rules says is that in order to change your friends opinion you not only need to be selected but randomly select one of your friends, and then if this one friend agrees with you then you both get to make all your friends have the same opinion that you.

Changing opinions


Not changing opinions


Again, with the same fixed values we get


3 site convincing

The third and last one is similar to the 2 site convincing, but now you select 2 random friends and both have to agree with you so you can change your whole neighborhood opinion.

Changing opinions


Not changing opinions


Also not changing opinions


Again, with the same fixed values we get



Isn't that what we're all here for?

Just the 3 movies from above don’t tell us to much about the behavior of the overall system, so we need no map the probability p from 0 to 1, so I chose a 0.1 spaced interval to do that and ran everything 30 times and average the results.


From that figure we can see that the 1 site convincing is a linear function of the initial probability, but the 2 site convincing and the 3 site convincing are way more interesting, showing us that just like the Ising model this is a phase transition problem. From the looks of it it would be interesting to map (which I didn’t do) all the n sites convincing posibilities to see if there’s a threshold for this 2nd order phase transition to become a 1st order one.

But instead of going through that what I wanted to see was if it would be possible to replicate how do bots or influencers can affect the overall final average opinion.


I decided to go for 3 different types of bots which I called:

  • Stupid bots
  • Smart bots
  • Cambridge Analytica

So the stupid bots are really the easiest way of interfeer in the opinion which is randomly take a percentage of the population and make them believe in opinion 1 if they haven’t already.

The smart bots on the other hand only randomly select nodes from the population with opinion 2 to make them turn to opinion 1.

The Cambridge Analytica ones (I’m not saying that the operated this way, ‘though I think they kinda did) is a smarter way to select who to attack, and that is… those who are vulnerable with easily influenced friends. So I randomly selected from the nodes with a % of their friends and itself having opinion 1 and perform a 2 site convincing on them. This task is not very easy, as the area is greater than the perimeter… meaning that if you randomly select a node with all their friends with opinion 2 then nothing will happen, and it is a lot more likely for that to happen than to select one with 70% % and also a 2 site convincing will be very difficult to work with them.

Some movies where we can see the behaviour of each bot army type are shown below. As the previous ones, they’re initialized in a 200X200 grid with a of having opinion 1.




The movies are fun, but it’s more interesting to look at the statistics. These were generated in the same way as the previous.




Take away

This post is just a cartoon of how this kind of things happen, but do not put this in a broken bag (does that expression exists in english?). Meaning that we must be careful with whom we share and exchange opinions and also it is REALLY important to avoid sharing fake news, and one of the most important things in the whole world… RESPECT, not everybody has to agree with you. Disagreements don’t disrupt friendships, but the intolerance to them does.

Entre los individuos como entre las Naciones, el respeto al derecho ajeno es la paz.

Benito Juárez.