Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
School of Computing and Information Systems
comp10002 Foundations of Algorithms
Semester 2, 2024
Assignment 2
Learning Outcomes
Background
In an elementary cellular automaton, cells are arranged in a one-dimensional array and each cell is in 0 or 1 state denoting on and off cells, respectively. An automaton of 31 cells, with cells at positions 0, 1, 12, 15, 18, and 29 on (counting from left to right starting from zero) and the other cells off, is shown below.
The neighborhood of a cell in an elementary cellular automaton comprises the cell itself and its two immediate neighbor cells. The update rule of an elementary automaton maps such possible neighborhoods of a cell to its states in the next time step. One such update rule is depicted below.
The top row lists all eight possible neighborhoods of a cell, with the cell in the middle being the cell of interest and the other two cells being its neighbors. For example, the 010 neighborhood denotes that the cell is on and both its immediate neighbors are off, whereas 110 is the neighborhood of an on cell with its left neighbor on and right neighbor off. The bottom row shows the state of the cell in the next time step for the corresponding neighborhoods. For instance, a cell with neighborhood 010 stays on (1) in the next step, while a cell with neighborhood 110 switches off (0) in the next step. A run of the first three computation steps of the example automaton using the example update rule is listed below; numbers at the start of each line denote time steps. 0:
The gray background highlights eight applications of the update rule on cells at different positions at different time steps. For example, the neighborhood of the cell at position 12 at t=0 (010) determines the state of this cell at t=1 (1). As another example, the neighborhood of the cell at position 24 at t=0 (000) determines that this cell stays off at t=1 (0). When determining the neighborhoods of the edge cells (first and last cells in the array), the array is “wrapped” around. Specifically, the cell after the last one is the first cell, and the cell before the first one is the last cell. Hence, the neighborhood of the last cell at t=0 (position 30) is 101 determining that the the cell at position 30 at t=1 is off. Once cell states at time t are determined, one can compute cell states at time t+1.
Cellular automata have many applications, including studies of complex behaviors in nature (rule 30), prime numbers (rule 90), traffic flows (rule 184), and computability (rule 110). Artem and Alistair need a tool to study new ways of solving computational problems using cellular automata. Your task is to implement this tool.
Input Data
The input will always follow the proposed format. You can make your program robust by handling inputs that deviate from this format. However, such extensions to the program are not expected and will not be tested.
Output
Stage 0 – Reading, Analyzing, and Printing Input Data (10/20 marks)
You should not make assumptions about the maximum number of cells requested from the input for the automaton your program should construct. Use dynamic memory and data structures of your choice, for example, arrays or linked lists, to store the history of states of the automaton.
Stage 1 – Execute Automaton (16/20 marks)
The output of Stage 1 should start with the corresponding header; see line 9 in the test0-out.txt file. The subsequent lines, lines 10 to 20 in the test0-out.txt file, print the automaton states in chronological order they were observed, starting with the initial state (t=0) to the last computed state (t=10). Again, use “*” and “.” characters to denote on and off cell states and the "%4d:" format specifier to format the output of time steps.
The output line that follows all the printed states should be the delimiter line of 37 “-” characters; see line 21 in the test0-out.txt output file. Next, your program should print the counts of on and off states of the requested cell using the "#ON=%d #OFF=%d CELL#%d START@%d\n" format specifier; see line 22 in the output.
You should not make assumptions neither about the maximum number of time steps that can be requested to evolve the automaton nor about the requested cell position or time step to start counting the cell states.
Stage 2 – Solve Practical Problem (20/20 marks)
In Stage 2, your program should apply the procedure of Fuks described above to solve the density classifica-tion problem for the state of the automaton computed for the last time step in Stage 1 (t=10 for the test0.txt input file). The output of Stage 2 should start with the corresponding header; see line 23 in the test0-out.txt file. In the subsequent lines, your program should print the evolution of the automaton using rules 184 and 232, with rules applied in the correct order for the correct number of time steps. Lines 24 to 60 in the test0-out.txt file print this output for the automaton resulting from Stage 1. Lines 24 and 42 inform about the changes in the update rule and the number of time steps the new rules are applied, while lines 25, 41, 43, and 60 are the delimiter lines of 37 “-” characters.
The subsequent line (line 61 in test0-out.txt) in the output should print the number of on and off states for the cell at position starting from the time step requested on line 6 in the test0.txt input file. Finally, after the delimiter line (line 62 in test0-out.txt), your program should print the automaton for which the density classification problem was solved (line 63) and the answer to the problem (line 64). As all the cells in the automaton at t=39 are off, there are more off cells than on cells in the automaton at t=10. Replace the “<” symbol in the result message (line 64) with “=” or “>”, as required by other inputs to your tool.
Stage 3 – Have Fun (no marks for fun as fun is your reward)
References
Pay Attention!
Two further test inputs and outputs are provided. The outputs generated by your program should be exactly the same as the sample outputs for the corresponding inputs. Use malloc and dynamic data structures of your choice to store automata, rules, etc. Before your program terminates, all the malloc’ed memory must be free’d.
Important...
Submissions made after the deadline will incur penalty marks at the rate of two marks per (part or all) working day. Students seeking extensions for medical or other “outside my control” reasons must lodge a request following the FEIT process linked from the LMS page once those circumstances arise. If you attend a GP or other health care service as a result of illness, be sure to obtain a letter from them that describes your illness and their recommendation for treatment. Suitable documentation should be attached to all extension requests.
You need to submit your program for assessment via Gradescope (Assignment 2). Submission is not possible through Grok. Multiple submissions may be made; only the last submission that you make before the deadline will be marked. If you make any late submission at all, your on-time submissions will be ignored, and if you have not been granted an extension, the late penalty will be applied.
As you can submit your program multiple times, test your program in the test environment early. The compilation in the Gradescope environment may differ from Grok and your laptop environment. Note that Gradescope may overload and even fail on the assignment due date when many students submit their programs, and if that does happen, it will not be a basis for extension requests. Plan to start early and to finish early!!
A rubric explaining the marking expectations is linked from the LMS. Marks will be available on the LMS approximately two weeks after submissions close, and feedback will be made available via Gradescope. Academic Honesty: You may discuss your work during your workshop, and with others in the class, but what gets typed into your program must be individual work, not copied from anyone else. So, do not give hard copy or soft copy of your work to anyone else; do not have any “accidents” that allow others to access your work; and do not ask others to give you their programs “just so that I can take a look and get some ideas, I won’t copy, honest”. The best way to help your friends in this regard is to say a very firm “no” if they ask to see your program, pointing out that your “no”, and their acceptance of that decision, are the only way to preserve your friendship. See https://academicintegrity.unimelb.edu.au for more information. Note also that solicitation of solutions via posts to online forums, whether or not there is payment involved, is also Academic Misconduct. In the past students have had their enrolment terminated for such behavior.
The assignment page contains a link to a program skeleton that includes an Authorship Declaration that you must “sign” and include at the top of your submitted program. Marks will be deducted (see the rubric) if you do not include the declaration, or do not sign it, or do not comply with its expectations. A sophisticated program that undertakes deep structural analysis of C code identifying regions of similarity will be run over all submissions. Students whose programs are identified as containing significant overlaps will have substantial mark penalties applied, or be referred to the Student Center for possible disciplinary action.
Nor should you post your code to any public location (github, codeshare.io, etc) while the assignment is active or prior to the release of the assignment marks.