Conway's Game of Life with rule switching

Conway's Game of Life with rule switching preview image

1 collaborator

Tags

cellular automata 

Tagged by Jaroslaw Miszczak almost 2 years ago

game of life 

Tagged by Jaroslaw Miszczak almost 2 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.3.0 • Viewed 507 times • Downloaded 33 times • Run 0 times
Download the 'Conway's Game of Life with rule switching' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model implements a version of Game of Life cellular 2D automaton extended with the ability to alter the rules utilized by the cell during the evolution. Simple versions of random and deterministic mechanisms of rules selection are implemented. In both case, at each step, the cell can be updated according to one of the rules - the standard one and the alternative one. The standard rule is identical to the rule for dying due to overpopulation (Any live cell with four or more live neighbors dies, because of the overpopulation). The alternative rule for threshold r is: Any live cell with r of more live neighbors dies, because of the overpopulation.

Additionally, one can switch between synchronous and asynchronous state updating policy. In the synchronous update policy, corresponding to the standard version of GoL, the state of the lattice is updated globally at the end of each simulation step. In the asynchronous policy, the state of each agent is calculated and updated immediately. Thus, each simulation steps consists of the calculation of next state of the cell, and the update of the cell state. The order of cells is chosen randomly

HOW IT WORKS

Game of Live is a 2D cellular automaton. Black color marks living cells, white cells are dead. In the basic version of the game - synchronous stat updating and single evolution rule - cells can become live or dead according to threshold on the number of living cells in their neighborhood.

The following parameters of the model are available through the controls:

  • world-size - size of the lattice used to run the simulation;
  • init-life - percentage of living cells at the beginning of the simulation;
  • synchronous - toggle between synchronous and asynchronous updating policy;
  • deterministic - toggle between deterministic and random rule selection mechanism;
  • deterministic-period - the number of iteration between the utilization of the alternative rule in the deterministic rule switching mechanism;
  • rule-switch-prob - set the probability of utilizing an alternative rule in the random rule switching mechanism;
  • second-threshold - threshold used in the second (alternative) rule used in the game;

HOW TO USE IT

After setting the required parameters, use Setup world button to initialize the simulation. To run the model ones, use Play life button. Loop button runs the game in a loop, and Play 50 times runs 50 simulation cycles.

THINGS TO NOTICE

The formation of patterns and the stability of the evolution depends on the selection of parameters.

Some popular formation could occur in the case of synchronous or asynchronous updating. It is possible to switch between synchronous and asynchronous updating during the game to observe the changes in the behavior.

Similarly, in the case of random mechanism for selecting rules, it is possible to change the probability of switching between the base rule and the alternative rule.

THINGS TO TRY

The most important element to try is to modify the threshold for dying due to the underpopulation.

EXTENDING THE MODEL

Currently, all patches are updated during each step. To explore the transition between synchronous and asynchronous policy, only a fraction of the cell should update its state synchronously. This could be achieved by introducing a new parameter defining the probability of synchronous updating.

RELATED MODELS

Conway’s Game of Life, http://www.modelingcommons.org/browse/one_model/6948

CREDITS AND REFERENCES

Conway's Game of Life, https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life Asynchronous cellular automaton, https://en.wikipedia.org/wiki/Asynchronous_cellular_automaton

A model of the Game of Life with asynchronous updating was introduced in H.J. Blok, B. Bergersen, "Synchronous versus asynchronous updating in the “game of Life”", Phys. Rev. E 59, 3876 (1999), https://doi.org/10.1103/PhysRevE.59.3876

1D cellular automata with random updating due to the noise were studied in

Louis, P.-Y., & Nardi, F. R. (Eds.). (2018). Probabilistic Cellular Automata (Vol. 27). Springer International Publishing. https://doi.org/10.1007/978-3-319-65558-1

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

patches-own [
  next-pcolor ;; the next state is calculated using current pcolor
]

;; clear the board and create some life

to setup
  clear-all
  reset-ticks

  ;; make the world with custom size
  resize-world 0 (world-size - 1) 0 (world-size - 1)

  ;; heuristic scaling of the patch size
  set-patch-size floor ( 50 / (sqrt world-size) )

  ;; use next-pcolor to initialize pcolor
  ask patches [
    ifelse random 100 < init-life [
      set next-pcolor black
    ][
      set next-pcolor white
    ]
    set pcolor next-pcolor
  ]
end 

;;
;; main function
;;

to go

  ifelse synchronous [
    ask patches [
      simulate-life
    ]
    ask patches [
      update-state
    ]
  ][
    ask patches [
      simulate-life
      update-state
    ]
  ]

  tick
end 

;;
;; calculate the updating rule
;;

to  simulate-life
  ifelse deterministic [ ;; deterministic rule switching
    ifelse ticks mod deterministic-period = 0 [
      update-rule-modified
    ][ ;; ticks mod deterministic-period \= 0
      update-rule-std
    ]
  ][ ;; random rule switching
    ifelse random-float 1 > rule-switch-prob [
      update-rule-std
    ][
      update-rule-modified
    ]
  ]
end 

;;
;; standard update rule for the Game of Life
;;

to update-rule-std
  let x (count neighbors with [ pcolor = black] )

  ifelse pcolor = black [
    ifelse x < 2 or x >= 4 [ ;; x>=4 (weak inequality) - standard rule
      set next-pcolor white ;; ie. die
    ][
      set next-pcolor black ;; ie. stay alive
    ]
  ][ ;; pcolor = white
    if x >= 3 and x < 4 [ ;; modified rule if second-threshold != 4
          set next-pcolor black ;; ie. birth
    ]
  ]
end 

;;
;; update rule with the altered treshold for the overpopulation
;;

to update-rule-modified
  let x (count neighbors with [ pcolor = black] )

  ifelse pcolor = black [
    ifelse x < 2 or x >= second-threshold [ ;; modified rule if second-threshold != 4
      set next-pcolor white ;; ie. die
    ][
      set next-pcolor black ;; ie. stay alive
    ]
  ][ ;; pcolor = white
    if x >= 3 and x < second-threshold [ ;; modified rule if second-threshold != 4
          set next-pcolor black ;; ie. birth
    ]
  ]
end 

;;
;; update the state
;;

to update-state
  set pcolor next-pcolor
end 

;;
;; reporters
;;

;;
;; fraction of living cells
;;

to-report %living
  report 100 * ( count patches with [ pcolor = black] ) / ( count patches )
end 

There is only one version of this model, created almost 3 years ago by Jaroslaw Miszczak.

Attached files

File Type Description Last updated
Conway's Game of Life with rule switching.png preview Preview for 'Conway's Game of Life with rule switching' almost 3 years ago, by Jaroslaw Miszczak Download

This model does not have any ancestors.

This model does not have any descendants.