1 of 31

1

Computational Social Psychology

Week 2: Creating your very first model

Jiin Jung, Ph.D.

Lehigh University

jiin.jung@lehigh.edu

2 of 31

Life (1958)

“La plume de ma tante

est sur le bureau de mon oncle”

3 of 31

4 of 31

Objectives

  • When you learn a new language, you start with super simple, often idiotic, not very useful, phrases.

  • The same principle can be applied to learning a new programming language.

  • Let’s make our ‘la plume de ma tante’ model - a super simple, quite idiotic, not very useful, model.

5 of 31

Open the code tab in NetLogo

6 of 31

Types the code below

7 of 31

Create “command buttons” in Interface

8 of 31

Create “command buttons” in Interface

9 of 31

“step” is go but for just one tick

10 of 31

Let’s run the model

  • All agents show exactly same actions.
  • They move forward by 1 and turn right by 10.

* If you can track agents actions, use “pen-down”

11 of 31

Let’s bring some randomness�This makes agents heterogeneous

Now agents randomly pick an integer between 0 to 9,

and turn right by that number

12 of 31

Let’s run again

  • Each agents shows different trajectories of actions.

13 of 31

You want to parameterize a population

  • What would you do if you want to have a different number for an initial population?

Create an interface element

to input a parameter value

14 of 31

You want to parameterize a population

  • What would you do if you want to have a different number for an initial population?

Replace 10 with a parameter label, “population”

15 of 31

Let’s run the model with 60 turtles

16 of 31

Let’s get agents interact with other agents�– This brings ‘sociality’ to agents

  1. Agents find friends within their reach.
    • Agents have imperfect local knowledge.

  1. If there is any other agents within their reach, they become more social.

17 of 31

Programming “social” agents

Agents find friend(s) at each iteration

Each turtle has its own friend(s).

🡪 This is called a turtle variable

Make turtles social – make friends

18 of 31

Let’s make agents' sociality visible to us

    • Agents size represents their sociality.

19 of 31

Programming “social” agents

If an agent has any friend(s), the agent gets bigger

20 of 31

Let’s run the model with 60 turtles

21 of 31

Program ‘Friends bring more friends’

  • More social agents come to have larger reaches when they find friends.

22 of 31

Let’s program “social agents become more social”

23 of 31

Sociality

  • Sociality increases very very fast.

24 of 31

Let’s plot how fast sociality increases?

  • Calculate the mean of turtles’ size

25 of 31

Let’s plot how fast sociality increases?

  • Calculate the mean of turtles’ size

26 of 31

Global variables

  • Global variables are outside of turtle’s view as opposed to turtle variables which are accessible only to self-agent.
  • You can make a global variables accessible to all agents if necessary.

27 of 31

Create a plot in interface tab

28 of 31

Plotting the frequency distribution of sociality

29 of 31

Notice the patterns of sociality increases

30 of 31

“La plume de ma tante” model

31 of 31

Resources

NetLogo User Manual. Version 7.0.0. (2025)

    • https://docs.netlogo.org/