Question
USSING CPP The Plan We are going to implement our own cellular automaton. Imagine that there is an ant placed on a 2D grid. The
USSING CPP
The Plan
We are going to implement our own cellular automaton. Imagine that there is an ant placed on a 2D grid. The ant can face in any of the four cardinal directions, but begins facing north. The cells of the grid have two state: black and white. Initially, all the cells are white. The ant moves according to the following rules:
1. At a white square, turn 90? right, flip the color of the square, move forward one square.
2. At a black square, turn 90? left, flip the color of the square, move forward one square.
The Fourth Task (20 marks)
We will now simulate multiple steps. Write a program that takes in the grid size and the initial position of the ant, and displays the grid after each time step.
7.1 Input
The first line of input is an integer T , the number of steps to simulate. The next line consists of two integers r and c, separated by a single space. These are the number of rows and columns of the grid. Every cell is initially white. The next line consists of two integers m and n, separated by a single space, specifying the row and column location of the ant (recall that the ant starts facing north).
7.2 Output
Output the initial board representation, and then the board after every step taken. The represen- tations should be the same as they are in The First Task. Each board output should be separated by a single blank line.
Sample Input
2
5 5
2 2
Sample Output
00000
00000
00000
00000
00000
00000
00000
00100
00000
00000
00000
00000
00110
00000
00000
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started