Question: Write a program called CA.java that simulates an Elementary Cellular Automaton. The user must be able to provide these two things: as arguments when executing

Write a program called CA.java that simulates an Elementary Cellular Automaton.

The user must be able to provide these two things: as arguments when executing the program from Console:

  1. the number of iterations (any integer n)
  2. the Rule Number (an integer from 0 to 255)

The program will initialize the grid to a width of n 2, with a single cell set to true/alive in the centre. It will then display the iterations of the automaton in console.

Example run command in Console: java CA 20 223 will create an automaton with grid width (20 2 =) 40, and will run for 20 iterations using Rule 223.

How to handle the update of the leftmost and rightmost cells: the easiest way is to ignore them and only update the cells from [1] to ['last'-1]. Or, if you prefer, you can pretend that there are cells at [-1] and ['last+1] that have state = 0. It's up to you. The Rule90 example code does it the first way.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!