Microscopic Multiply We want to simulate a small square surface of an area with micro-organisms (like bacteria) and how they spread every cycle of life (iteration) on this surface. This surface is 2-D, its size is nxn and each 1x1 space forms a block. Each can be empty or hold a micro-organism. Every cycle of life (iteration) the micro- organism can either leave the block (this block on the surface will become empty) or stay on the block. An empty surface can attract new micro-organisms or can stay empty. NOTE: When a microorganism leaves the surface, it just flies into the air and never returns. It does NOT move to any other block (this is to avoid confusion) The rules that govern whether a micro-organism stays on its block on the surface or leaves it and that govern whether an empty block on the surface attracts a new micro-organism is as follows: a. If a micro-organism is close to 4 or more micro-organisms it will leave the block making it empty. b- If a micro-organism on a given block is alone or close to only 1 micro-organism the micro-organism will leave the block making it empty. C- If a micro-organism is close to 2 or 3 micro-organisms it stays. d- An empty space with 3 and only 3 close micro-organisms attracts a new micro-organism and it stops being empty. Now a micro-organism is close to another micro-organism if it is within the 8-connect direction of it. The 8 directions are up, upper-right 7, right, lower-right , down, lower-left k, left t, upper-left. The following illustrations shows the close blocks to the block labelled 'C'. The blocks around the 'C' block are the 8-connect directions that you should check. 2 3 8 С ។ 7 6 5 An example of the surface, with 2 iterations and 'M' being a micro-organism and being an empty space and 'l' 'l' being a boundary (this example will be in 7x7, you are required to simulate anxn) is as follows: *We will also use the following colors to point your attention to the rule that applied on the block in its current iteration and made it change. The rules we are mentioning are the four mentioned above. The colors used will be: a = leaves, b = leaves, C = stays, d = attracts new one. Start iteration (0) iteration 1 iteration 2 →→→ 个个个 →→→ 不不不 →→→ [ --MMM--] [ --M-M--] [----M--] [----- [-------] [- [--M-M--] [--M-MM-] [---M---] [------- [-------] [-- [-- [----MM-] [--M-MM-] [---MM--] [------- [-------] [-- -] ナナ →→→ →→→ →→→ →→→ →→→ →→→
In this task you are required to simulate multiple cycles of life (iterations) as the example above with the rules stated before. Your input will be the number 'N' of iterations to draw (taken as input from the user) and the initial state of the surface (You can have it fixed somehow in the code but note that you might need dynamic arrays to re-allocate. Being fixed means that it will be fixed after compiling, but you can still edit the code to change how the initial state looks and recompile). You are required to calculate and get the state of the board for the next 'N' iterations/cycles of life, starting with the given initial state. For every iteration (including the initial one) you will draw how the surface will look. For this task you are required to write some helper functions to make the process easier, you can add more functions if you need to. You will have to figure out what parameters to pass to the functions and what to return. But a hint will be supplied for some of them. (Please note that a cycle is an iteration) The functions required will be: A function which should return the number of close micro-organisms in a given block. This function will need access to the surface, and the location of the block you want to know how many close micro-organisms it has. A function which should return whether in the next iteration, this block will be empty or have a micro- organism. This function will at-least need access to the block's state and its location. A function which should prepare the next state of the surface and return it. This function will require at- least the current surface. A function which will apply the new states from the next state surface to the current state surface. This function will be called in the latter part of the code. A function which will take the current surface states and print them in a way similar to the example shown above (choose distinguishable characters and make sure you can separate each iteration). The input number of iterations will typically be 12 or more iterations. Note that surface state means all the 2-D blocks on the surface. Also, the print in the example shows them side by side, BUT you are required to print each surface state separately as follows (do not draw the arrows, they are just for illustration). The dimension of the surface is n x n meaning nxn blocks/elements.
[--MMM--] [--M-M--] [----M--] [- [--M-M--] [--M-MM-] [---M---] [-------] [-- --MM-] [--M-MM-] [ ---M-- ]

Belal_3 commented: LOL ! are you a FCAI CU student ? +0

Recommended Answers

All 5 Replies

Can you edit this?

  1. Format it for readability.
  2. Ask a question. As it stands I can't find your questions.
commented: We want to simulate a small square surface of an area with micro-organisms (like bacteria) and how they spread every cycle of life (iteration) on thi +0

This is basically a variation on Conway's Game of Life, which is a pretty well-known cellular automata ruleset and a common student problem.

As RProffitt said, the post as it is isn't formatted in a way which help us to help you.

So, what have you tried so far?

commented: i can send a photo for the question +0

As others have pointed out, your discussion has issues you need to address.

  1. Fix your post as it's formatting and lack of questions mean others will guess badly what your questions are.
  2. While I did supply a link to RosettaCode, it's a fine site with many of the classic programming questions fully(?) coded in many languages but for a student to use such to copy and paste would result in a failing grade.
  3. Again, fix your post, ask the questions but no one here will write this for you as that would not help you learn how to code.

LOL ! are you a FCAI CU student ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.