User Tools

Site Tools


notes:discrete:fall2021:projects:pnf0

This is an old revision of the document!


Corning Community College

CSCS2330 Discrete Structures

PROJECT: PRIME NUMBER FUN intro (PNF0)

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.

The algorithm you are to implement is the trial-by-division brute force (naive: NO optimizations)

Time how long it takes to execute (displaying elapsed time for the run at its conclusion; this is useful for comparisons).

Additionally, the entire class will be participating in documenting and filling out this project page. It is the responsibility of EACH class member to:

  • ask copious, clarifying questions (so you can better add content)
  • craft a coherent and organized document, with information located under pertinent headings
  • explain the fundamentals of the process, conceptual background, algorithmic approach, and you can even suggest particulars related to TIC-80 (certain functions that might prove useful- individual, unrelated snippets to do things like capturing time, or displaying text, etc.)
  • to get full credit, each individual that submits must perform no fewer than 4 changes to this document (as viewable from the wiki revision system). Failure to do so will result in documentation penalties being applied.

Background

TIC80

TIC80 works on a system of carts. The carts present on a system can be listed via a familiar call to `ls`, or, at a more involved level, the system folder which TIC80 uses to store its data can be accessed via the `folder` command in the TIC80 terminal. The code content of these cards after `load`ing them can be accessed by pressing [ESC] from the terminal, opening the included basic IDE equipped with a code, sprite, map, sfx, and music editor.

The code editor is relatively simple: 64KB are allotted for a script written in any of: Lua, JavaScript, Moonscript, Wren, Fennel, and Squirrel. External packages may also be used to allow for the usage of more languages. The first step in writing a basic program in TIC80 is to supply a series of comments (formatted in the choice language) which allow TIC80 to ascertain four pieces of metadata, as in:

-- title: PrintThing(TM)
-- author: Wedgie
-- desc: Print.. something.
-- script: lua

for Lua, or:

// title: PrintThing(TM)
..
// script: js

for JavaScript, and so on.

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 `clr()` 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. `clr` (Clear) simply clears the screen of all pixel data and resets to blank.

Priminality

Specifications

Process

As it is an intentionally minimally optimized (in a way, optimally suboptimal) method, going about this task will be relatively simple, relying on three major areas: user interaction/input, prime checking, and visual output. Chronologically, upon run, the program will execute essentially the following steps:

  1. Request input
    1. Store
  2. Pass input to prime checker
    1. Return True/False for Prime/Composite
  3. Use return value of prime checker to determine output
    1. If prime, positive output (e.g. rainbow/green/bright)
    2. If composite, negative/neutral output (e.g. monochrome/red/dull)

Prime Detection Algorithm

Display

References

notes/discrete/fall2021/projects/pnf0.1630160503.txt.gz · Last modified: 2021/08/28 14:21 by aholmes9