This is an old revision of the document!
Corning Community College
CSCS2330 Discrete Structures
Using the TIC-80 fantasy console simulator on your pi, implement a program that performs a sorting of a randomized list of values, both displaying an animation of the sort, along with timing and keeping track of the approximate number of steps needed to accomplish the task for variable numbers of non-animated runtimes.
The sorting algorithms I'd like for you to produce is that of:
You may want to look up the specifics on these algorithms to understand what their approach is, then to implement it.
Additionally, the entire class will be participating in documenting and filling out this project page. It is the responsibility of EACH class member to:
Bubble Sort, sometimes called Sinking Sort, is a simple sorting algorithm that “repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.” For example, a sort of the array {5, 7, 3, 9, 2} would go as follows:
{5 7 3 9 2} -> {5 7 3 9 2} {5 7 3 9 2} -> {5 3 7 9 2} {5 3 7 9 2} -> {5 3 7 9 2} {5 3 7 9 2} -> {5 3 7 2 9} {5 3 7 2 9} -> {3 5 7 2 9} {3 5 7 2 9} -> {3 5 7 2 9} {3 5 7 2 9} -> {3 5 2 7 9} {3 5 2 7 9} -> {3 5 2 7 9} {3 5 2 7 9} -> {3 5 2 7 9} {3 5 2 7 9} -> {3 2 5 7 9} {3 2 5 7 9} -> {3 2 5 7 9} {3 2 5 7 9} -> {3 2 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9} {2 3 5 7 9} -> {2 3 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9} {3 2 5 7 9} -> {2 3 5 7 9}
You will notice that, in this specific example, the algorithm had to sweep through 5 times in order to reach the final result. You will also notice that the complete sorting was finished after pass 4, but the algorithm did a 5th one as well. This is because the algorithm has to do one whole pass without doing a swap in order for it to be considered a successful sort.
print() is a very versatile tool; there are so many things to play around with and so many different arguments to take advantage of. For example, these are the arguments for print(): text [x=0 y=0] [color=12] [fixed=false] [scale=1] [smallfont=false]. The first three are pretty self-explanatory, but the latter are where things get interesting. The 'fixed' argument is referring to whether or not you desire a fixed letter width within your printed text. As the TIC80 Wiki puts it, “When set to true, the fixed width option ensures that each character will be printed in a 'box' of the same size, so the character 'i' will occupy the same width as the character 'w' for example.” Continuing, the 'scale' argument determines what scale you want your text on. As a esult, a scale bigger than 1 will produce similarly bigger text. But, you may ask, what happens if I want *smaller* text? Well that is where the 'smallfont' argument comes in. If set to true, the text font will be set to a smaller, fixed one. This is useful for displaying a large list of sorted and/or unsorted values in one row of text, rather than resorting to wrapping.
I'll be looking for the following:
78:saf1:final tally of results (78/78) *:saf1:no errors, program runs without issue in TIC-80 [13/13] *:saf1:specified algorithms are implemented and functional [39/39] *:saf1:metrics, timing of process is implemented, functional, shown [13/13] *:saf1:project page contributions as per project specifications [13/13]
Additionally: