编程辅导 C C++ Java Python MIPS Processing 网络家教 在线辅导

编程家教 远程写代码 Debug 讲解答疑 课后答疑 不是中介,本人直接答疑

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

Develop a Java program that implements a 2D cellular automaton to produce 12 different crystal growth patterns (defined by Wolfram in A New Kind of Science, p. 373). The update rule for all of these CAs changes a cell from white to black if the number of neighboring black cells is equal to one of the numbers shown in parentheses beside the options given below. The initial number of adjacent black cells (aligned in a row) on a white background is given by the number shown in square brackets. These cells are located in the center of the CA.

     1.  (2)     [2]

     2.  (1,2)   [1]

     3.  (1,3)   [1]

     4.  (3,4)   [3]

     5.  (1,5)   [1]

     6.  (1,3,5) [1]

     7.  (3,6)   [5]

     8.  (2,4,6) [2]

     9.  (3,5,6) [7]

     10. (3,7)   [5]

     11. (2,5,7) [2]

     12. (3,5,7) [13]

Your program should allow the user to specify the CA dimensions and scale factor for cell size (but provide defaults), select the desired option from a menu that looks like that shown above, then generate the CA in a graphics window one time step per user press of the ENTER key or perform N updates if the user enters a positive integer. (Do not erase the window at each generation. Just update the CA and show the results.) An entry of 0 exits to the menu. Pressing ENTER at the menu level with no menu item selected exits the program.

 

You may find the following code to be helpful: ImageDisplay.java. All of the class variables are public, so you merely need to create an instance of the class, then map your CA to the class image array. The good news about using this class is that it will automatically create cells of any size you wish based on a user defined scale factor. However, make sure that you allow for enough room for the fully developed CA (for each case) to fit in the window (and on the screen). A CA that cannot be fully displayed cannot be graded (at least not highly)! UseKeyboardInputClass for all input (being sure to use the best methods for relevant input and providing defaults (displayed) for each input).

相关推荐