Question: In C++: You will design, implement, and test a program that implements a simulation of Langtons Ant. For a brief explanation consider Wikipedia: https://en.wikipedia.org/wiki/Langton%27s_ant (Links

In C++: You will design, implement, and test a program that implements a simulation of Langtons Ant. For a brief explanation consider Wikipedia: https://en.wikipedia.org/wiki/Langton%27s_ant (Links to an external site.)Links to an external site.. Note that it can be considered as a cellular automaton. This means that you have an array or matrix of cells. Each turn or step, the value of each cell may change based upon a simple rule. For the Ant there are two simple rules. The rules are: In a white square, turn right 90o and change the square to black. In a black square, turn left 90o and change the square to white. You should use a blank character for a white space, and use the number sign # for the black space. And for the Ant? "@" works fine. (You can use other sign as long as it is easy to see.) Left ? Right? Those are relative directions! How are you going to keep track of the direction the Ant is facing? How will you remember what color the current cell occupied by the Ant is or was? You will create an Ant class to help organize, hold, and manipulate this information. Your program will prompt the user to enter the number of rows and columns for the 2D array. You should also prompt the user for the number of steps. If you want to limit the size of the board or number of steps, suggest values to the user. (You are suggested to choose a size that is no larger than the default width 80 when you are developing). Your program should display each step by printing out the whole board. Use functional decomposition to develop functions to validate the input. (You can make a validation class if you would like.) You should start by asking the user for the starting location of the Ant. For testing purposes, always start the Ant at the same location. Then try different locations. Remember that when you create the array dynamically, you need to de-allocate the space to avoid memory leaks. You can use valgrind to check for memory leaks. Then what if the ant meets a wall collision (i.e. ant attempts to step out of the bounds of the array)? Think about the corner case. For example, the ant makes it to the edge of the game board, and according to the rule, it needs to make a turn and end up getting out of the game board. It is your design decision, and make sure it is properly handled. Previously, students tried different actions, such as skip the step forward step, make another turn and then continue on, or wrap the board around so that the ant will appear on the other side, or turn the ant around and send it back onto the board. As long as it makes sense, you are fine. But do not terminate the game before it reaches the designated step. The array MUST be dynamically allocated, and you may not use any libraries aside from iostream. **I have read answers to this question on Chegg and elsewhere, but they do not dynamically allocate the array using user input, or they use libraries that are not allowed for this problem. The answer must be written in C++.

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!