Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:30:41+00:00 2026-05-24T04:30:41+00:00

How can I have random movements in my Cellular automaton model? For example, if

  • 0

How can I have random movements in my Cellular automaton model? For example, if the elements in a cell is much more than two or more neighboring cells I’d like to randomly choose a few neighbors to give some elements. I tried all the codes that came to my mind but my problem is that in Mathematica I have to be sure that the same time an element is living from a cell and is going to another. I thought of doing it using conditions but I am not sure how. Can anyone please help me?

Edit: the code I used so far

My actual code is very complicated so I will try to tell you what I have done with a simpler cellular automaton. I wanted to succeed movements in a Moore neighbourhood. Every cell in my cellular automaton has more than one individual (or none). I want to make random movements between my cells. I couldn’t do this, so I tried the following code and in my cellular automaton I used it like you can see below.

w[i_, j_] := 
  If[(i - 4) > j, -1, If[(i - 4) == j, 0, If[(j - 4) > i, 1, 0]]];


dogs[p, p1, p2,p3,p4,p5,p6,p7,p8]:=newp &[
  newp = w[p, p1] + w[p, p2] + w[p, p3] + w[p, p4] + w[p, p5] + 
    w[p, p6] + w[p, p7] + w[p, p8]]

This code is doing movements, but is not exactly what I want because if a cell has 0 individuals in it and its neighbours all 5, then at the end it has 8 and its neighbours 4 but I don’t want that because I don’t want the cell with the less individuals in it to have more than its neighbours at the end. I want all of them to have close values in them and still have movements. I don’t know how to do that in Mathematica.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:30:43+00:00Added an answer on May 24, 2026 at 4:30 am

    A cellular automaton is not particularly complicated, so my first point of advice is to figure out exactly what you want. Then, I recommend you separate the classical transition rules from the “random” aspect you’re introducing.

    For instance, here is my implementation of Conway’s Game of Life:

     (* We abbreviate 'nbhd' for neighborhood *)
     getNbhd[A_, i_, j_] := A[[i - 1 ;; i + 1, j - 1 ;; j + 1]];
    
     evaluateCell[A_, i_, j_] :=
       Module[{nbhd, cell = A[[i, j]], numNeighbors},
    
        (* no man's land edge strategy *)
        If[i == 1 || j == 1 || i == Length[A] || j == Length[A[[1]]],
           Return[0]];
    
        nbhd = getNbhd[A, i, j];
        numNeighbors = Apply[Plus, Flatten[nbhd]];
    
        If[cell == 1 && (numNeighbors - 1 < 2 || numNeighbors - 1 > 3),
          Return[0]];
        If[cell == 0 && numNeighbors == 3, Return[1]];
         Return[cell];
      ];
    
     evaluateAll[A_] := Table[evaluateCell[A, i, j],
        {i, 1, Length[A]}, {j, 1, Length[A[[1]]]}];
    

    After performing evaluateAll, you can search through the matrix for “lonely” cells and move them as you please.

    For additional information about how the code works, and to see examples of the code in action, see my blog post on Conway’s Life. It includes a Mathematica notebook with the full implementation and plenty of examples.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I search for in table_a table_b table_c , which have a random
I want to generate random colours which can be attractive in pie charts.I have
I have a directory with about 2000 files. How can I select a random
You can have different naming convention for class members, static objects, global objects, and
Routines can have parameters, that's no news. You can define as many parameters as
Shaders can have lots of different uniform names + attributes. How can I make
I have a program that can have a lot of parameters (we have over
I have a class Person which can have several Homes, each one with one
I have a variable in code that can have file path or url as
I have a phone number field that can have lots of different characters such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.