Question
Using C++ design, implement, and test a program that implements a simulation of Langtons Ant. Note that it can be considered as a cellular automaton.
Using C++ design, implement, and test a program that implements a simulation of Langtons Ant. 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: 1. In a white square, turn right 90o and change the square to black. 2. In a black square, turn left 90o and change the square to white. Use a blank character for a white space. You can use the number sign (#) for black. And for the Ant? An asterisk (*). 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. 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. Suggest values to the user. Your program should display each step. Use functional decomposition to develop functions to validate the input. What parameters and criteria do these functions need? You should start by asking the user for the starting location of the Ant. You should add the option for the user to have a random starting location. For testing purposes, always start the Ant at the same location. Then try different locations. You should start saving utility functions for future programs you write.
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