User Tools

Site Tools


notes:discrete:fall2021:projects:saf1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:discrete:fall2021:projects:saf1 [2021/10/06 23:42] – Added extra bits to conclusion for Bubble Sort section smalik3notes:discrete:fall2021:projects:saf1 [2021/10/07 03:13] (current) – [Display] ccolocci
Line 28: Line 28:
  
 ====Process==== ====Process====
 +
 +==Randomness in Lua==
 +
 +As with the projects before, `math.random()` can be used to generate random values for the array. It may also have a different purpose depending on how you approach this project. While there are many ways to show the algorithms... rinse and repeat, or do a brand new array... one can use `math.random()` to randomize which algorithm is used to sort the array upon each new initialized array.
  
 ==Bubble Sort== ==Bubble Sort==
Line 105: Line 109:
  
 ====Display==== ====Display====
 +
 +In order to meet project specifications, you must be sure to perform an animation of the sort. This is no difficult task. The simplest way to go about this is to simple use the print() function after every iteration of your sort. For example, regardless of what sort you are performing, they sort one number at a time. Intuitively, you should display the entire list after sorting the given number at that time. Because of this, you will want to make sure you are keeping track of your code, and are going to want to find where exactly each iteration of the sort is occuring. 
  
 ==A Note on the Print Function== ==A Note on the Print Function==
  
 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. 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.
 +
 +Alternatively, the rect() function serves as a nice geometrical alternative to print() for viewing of your lists as an assortment of rectangles. This is used in the format of rect( x, y, w, h, color), so if you were to loop through a list while shifting these rectangles' locations, it could serve to make a nice graphic to display the lists as they are being sorted.
  
 =====References===== =====References=====
Line 120: Line 128:
 https://en.wikipedia.org/wiki/Bubble_sort https://en.wikipedia.org/wiki/Bubble_sort
  
 +https://github.com/nesbox/TIC-80/wiki/palette
 =====Submission===== =====Submission=====
  
notes/discrete/fall2021/projects/saf1.1633563765.txt.gz · Last modified: 2021/10/06 23:42 by smalik3