Menu

[Solved]-Q4 Cellular Automata Algorithms Image Algorithmically Generated Cave Like Structure Use 2d Q37268991

Q.4. Cellular Automata algorithm:s The image below is of an algorithmically-generated cave-like structure, for use in a 2D co

Q.4. Cellular Automata algorithms The image below is of analgorithmically-generated cave-like structure, for use in a 2Dcomputer game. Each of the cells, laid out in a 60×30 grid, eitherhas a wall (denoted by ‘#’) or a floor (denoted by ‘.’).

The cellular automata algorithm which generated this output usesthe following steps:

• For each cell, randomly define it as: wall (45% chance) orfloor (55% chance)

• Perform the following procedure 4 times:

Calculate the number of wall neighbours of each cell, and defineeach cell which has at least 5 neighbouring wall cells, as a wallcell itself. Otherwise (i.e. if it has less than 5 wall neighbours)define it as a floor cell.

Your task is to write a Java class to implement this cellularautomata algorithm:

(i) The class should store the cave-like structure in suitablemember data [4]

(ii) The data should be randomly initialised according to the1st step of the algorithm indicated above. Hint: use Math.random()to generate a random float between 0 and 1 [4]

(iii) The 2nd step of the algorithm (which repeats 4 times)should be implemented. You should pay particular attention to arraybounds when examining a cell’s neighbours. [7]

(iv) The resulting data should be printed to the console, (usingSystem.out.println) as the ‘#’ and ‘.’ symbols, as shown below.

Q.4. Cellular Automata algorithm:s The image below is of an algorithmically-generated cave-like structure, for use in a 2D computer game. Each of the cells, laid out in a 60×30 grid, either has a wall (denoted by’#’) or a floor (denoted by ‘.’). The cellular automata algorithm which generated this output uses the following steps: For each cell, randomly define it as: wall (45% chance) orfloor (55% chance) Perform the following procedure 4 times o Calculate the number of wall neighbours of each cell, and define each cell which has at least 5 neighbouring wall cells, as a wall cell itself. Otherwise (i.e. if it has less than 5 wall neighbours) define it as a floor cell. Your task is to write a Java class to implement this cellular automata algorithm: (i)The class should store the cave-like structure in suitable member data (ii) The data should be randomly initialized according to the 1step of the [4] algorithm indicated above. Hint: use Math.random ) to generate a random float between 0 and 1 (iii) The 2d step of the algorithm (which repeats 4 times) should be implemented. [7] You should pay particular attention to array bounds when examining a cell’s neighbours. (iv) The resulting data should be printed to the console, (using [5] system. out. print1n) as the , and ”symbols, as shown below Show transcribed image text Q.4. Cellular Automata algorithm:s The image below is of an algorithmically-generated cave-like structure, for use in a 2D computer game. Each of the cells, laid out in a 60×30 grid, either has a wall (denoted by’#’) or a floor (denoted by ‘.’). The cellular automata algorithm which generated this output uses the following steps: For each cell, randomly define it as: wall (45% chance) orfloor (55% chance) Perform the following procedure 4 times o Calculate the number of wall neighbours of each cell, and define each cell which has at least 5 neighbouring wall cells, as a wall cell itself. Otherwise (i.e. if it has less than 5 wall neighbours) define it as a floor cell. Your task is to write a Java class to implement this cellular automata algorithm: (i)The class should store the cave-like structure in suitable member data (ii) The data should be randomly initialized according to the 1step of the [4] algorithm indicated above. Hint: use Math.random ) to generate a random float between 0 and 1 (iii) The 2d step of the algorithm (which repeats 4 times) should be implemented. [7] You should pay particular attention to array bounds when examining a cell’s neighbours. (iv) The resulting data should be printed to the console, (using [5] system. out. print1n) as the , and ”symbols, as shown below

Expert Answer


Answer to Q.4. Cellular Automata algorithms The image below is of an algorithmically-generated cave-like structure, for use in a 2… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *