As part of this assignment, you will have to construct a dynamically-linked library libant.so which implements Langton’s ant, and a program ant that calls the library for all its key functionality.
- Your code should run on Linux. In particular, you should compile & test it on Mira.
- You may not use any external libraries aside from ncurses.
Your code should use the existing files and data structures already contained in the repository. You may add additional folder structure if you want, but it is not necessary. If you do ensure that the CI and Makefile continue to work or you will lose marks.
The repository already contains functionality for visualising the result using the ncurses library. In order to use it you need to link it at compile time using -lncurses.
All functions relating to visualisation are contained in visualiser.c and visualiser.h. For the generalisation you will need to add additional “colors” (may be represented as letters) to the visualiser.
- Pressing any key (except q) will advance the ant and pressing “q” will close the window.
Fill in the empty functions provided in langton.c. Make sure to use the data-structures provided in langton.h. Marks will be lost if you do not use the enums and structs as given.
Since you cannot use infinite memory, you will implement the ant on a finite rectangular grid (the “universe”). One approach is to give the grid the topology of a torus: the grid wraps around, so if you go one row higher than the top row, you reach the bottom row, and if you go to the column one row to the leftmost column, you reach the rightmost column etc. Modify the macro cell_at() to achieve this behaviour.
Hint: Before you get started familiarise yourself with the existing functions and data-structures provided, particularly the main loop of the program. Do not try to get the full functionality running in one go. Build it up carefully, checking that the test for each function passes before moving to the next.
For the advanced functionality you may need to extend the existing data-structures and add additional functions.
Once you have implemented the functionality turn it into a dynamically linked library. You will need to link it at the appropriate points in the Makefile. Modify main.c and test.c to call your new library.
The tests in test.c are run whenever you push to github by executing make test. Ensure that your Makefile contains a target test which compiles AND runs the tests. Each of the basic functions in langton.h are tested. We recommend (but don’t require) that you add additional tests to ensure correctness of your solution.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: email@example.com 微信:itcsdx