User Tools

Site Tools


notes:discrete:fall2021:projects:pnf0

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:pnf0 [2021/09/01 05:43] – Added concluding thoughts and clarification to trail-by-division algorithm section smalik3notes:discrete:fall2021:projects:pnf0 [2021/09/05 12:05] (current) – [Submission] wedge
Line 7: Line 7:
  
 =====Objective===== =====Objective=====
 +
 Using the TIC-80 fantasy console simulator on your pi, implement a program that visually displays a range of values (lower and upper bounds adjustable by the user) that colorfully displays whether each value is a **prime** or **composite** value. Using the TIC-80 fantasy console simulator on your pi, implement a program that visually displays a range of values (lower and upper bounds adjustable by the user) that colorfully displays whether each value is a **prime** or **composite** value.
  
Line 43: Line 44:
 Once a language is selected, a developer will need to include a `TIC()` function. This is essentially the "main" function as many other programs would have, and is called automatically once the `run` command is issued on the cart 60 times per second. This can be relied on to provide synchronous 60fps display and physics or other necessary mechanics. Additionally, the `spr()`, `print()`, and `cls()` functions will prove essential. The `spr()` (Sprite) function is used to call upon sprites designed in the sprite editor and place them at some location on-screen. `print()` (Print) is more clear: this will print text directly to screen in the default font. It should be noted that the print function can also accept additional arguments for text position, size, and color. `cls` (Clear Screen) simply clears the screen of all pixel Once a language is selected, a developer will need to include a `TIC()` function. This is essentially the "main" function as many other programs would have, and is called automatically once the `run` command is issued on the cart 60 times per second. This can be relied on to provide synchronous 60fps display and physics or other necessary mechanics. Additionally, the `spr()`, `print()`, and `cls()` functions will prove essential. The `spr()` (Sprite) function is used to call upon sprites designed in the sprite editor and place them at some location on-screen. `print()` (Print) is more clear: this will print text directly to screen in the default font. It should be noted that the print function can also accept additional arguments for text position, size, and color. `cls` (Clear Screen) simply clears the screen of all pixel
 data and resets to blank. data and resets to blank.
 +
 ====Priminality==== ====Priminality====
 +
 =====Specifications===== =====Specifications=====
  
Line 57: Line 60:
     - If prime, positive output (e.g. rainbow/green/bright)     - If prime, positive output (e.g. rainbow/green/bright)
     - If composite, negative/neutral output (e.g. monochrome/red/dull)     - If composite, negative/neutral output (e.g. monochrome/red/dull)
 +
 +====Input====
 +
 ====Prime Detection Algorithm==== ====Prime Detection Algorithm====
  
Line 75: Line 81:
   * Lower bound: 2   * Lower bound: 2
   * Upper bound: <m>sqrt{n}</m>   * Upper bound: <m>sqrt{n}</m>
 +     * If taking unoptimized route, upper bound can just be //n - 1//.
  
 Both of these bounds may be confusing, let me explain... Both of these bounds may be confusing, let me explain...
Line 87: Line 94:
   * How can we test if a number divides cleanly by //n//?   * How can we test if a number divides cleanly by //n//?
      * Hint: remainder "%"      * Hint: remainder "%"
-  * How can we square root in our code for the upper bound?+  * How can we implement a square root in our code for the upper bound?
   * How do we deal with testing the numbers 0 and 1?   * How do we deal with testing the numbers 0 and 1?
 +
 ====Display==== ====Display====
  
 The `print` function can be used to print text on the screen, but it also returns the width of the text. For example, `local string=print("Hello, World!",0,0,12)` would not only print the text on the screen, but it would also give the local variable `string` a value equal to the width of "Hello, World!" in pixels. This is especially helpful if you want to display a sprite after a string, but you don't feel like counting out how much space you need manually. The `print` function can be used to print text on the screen, but it also returns the width of the text. For example, `local string=print("Hello, World!",0,0,12)` would not only print the text on the screen, but it would also give the local variable `string` a value equal to the width of "Hello, World!" in pixels. This is especially helpful if you want to display a sprite after a string, but you don't feel like counting out how much space you need manually.
 +
 +Additionally, text can be appended to `print` alongside variables without the need for two separate lines of code/statements using `..`. For example, if you wanted to print "Times iterated: " and then a number contained within a variable, instead of doing two `print`s for the text and variable individually, you could do `print("Times iterated: "..variable,0,0,12)'.
  
 The `time` function returns the current run-time of the program in milliseconds. This is useful in a variety of circumstances; having something happen at a specific timestamp, having things refresh at a certain interval, etc. For pnf0, specifically, expertly utilizing `print()` alongside `time()` would display the current run-time in seconds, which is a requirement. The `time` function returns the current run-time of the program in milliseconds. This is useful in a variety of circumstances; having something happen at a specific timestamp, having things refresh at a certain interval, etc. For pnf0, specifically, expertly utilizing `print()` alongside `time()` would display the current run-time in seconds, which is a requirement.
- 
  
 =====References===== =====References=====
  
 https://github.com/nesbox/TIC-80/wiki https://github.com/nesbox/TIC-80/wiki
 +
 +http://lua-users.org/wiki/MathLibraryTutorial
 +
 +=====Submission=====
 +To submit, provide your tic file using the **submit** tool on lab46.
 +
 +I'll be looking for the following:
 +
 +<code>
 +65:pnf0:final tally of results (65/65)
 +*:pnf0:no errors, program runs in TIC-80 [13/13]
 +*:pnf0:user can specify lower and upper bounds at runtime [13/13]
 +*:pnf0:specified algorithms are implemented and functional [13/13]
 +*:pnf0:timing information is displayed [13/13]
 +*:pnf0:project page contributions as per project specifications [13/13]
 +</code>
 +
 +Additionally:
 +  * Solutions not abiding by **SPIRIT** of project will be subject to a 25% overall deduction
 +  * Solutions not utilizing descriptive why and how **COMMENTS** will be subject to a 25% overall deduction
 +  * Solutions not utilizing **INDENTATION** to promote scope and clarity will be subject to a 25% overall deduction
 +  * Solutions lacking **ORGANIZATION** and are not easy to read (within 90 char width) are subject to a 25% overall deduction
notes/discrete/fall2021/projects/pnf0.1630475038.txt.gz · Last modified: 2021/09/01 05:43 by smalik3