User Tools

Site Tools


notes:discrete:fall2021:projects:pnf2

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:pnf2 [2021/09/16 01:49] – Added sub-category for 'Sieve of Eratosthenes' algorithm smalik3notes:discrete:fall2021:projects:pnf2 [2021/09/16 02:26] (current) – Fixed minor typos and formatting of page smalik3
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 21: Line 22:
  
 =====Background===== =====Background=====
 +
 The Sieve of Eratosthenes was discovered by Eratosthenes who was born in 276 B.C. This Makes this method over 2200 years old. The algorithm is not too complex, and relatively easy to understand. It works by determined a list of prime numbers from 2, to a given number. It works by checking weather or not numbers within the given range have been marked as composite yet. For example, if you wanted to determine what numbers are prime up to 100, you would start at 2. Because 2 is at the beginning of the range, it has not been marked as composite and therefore is prime. But now we must say that all multiples of 2, up to 100, are composite(4,6,8,etc.). Now we would move on to the next number in the range, which is obviously 3. 3 has not been marked which means it is prime. Now again, we must say that all multiples of 3 are composite(6,9,12,etc.). We now move on to 4, but 4 has already been marked as composite, so we don't need to do anything. We can just move on to 5, which is unmarked. We now mark it as being prime, and again all multiples of 5 are composite(10,15,20,etc.). This process repeats until we have reached the end of the given range(100). The Sieve of Eratosthenes was discovered by Eratosthenes who was born in 276 B.C. This Makes this method over 2200 years old. The algorithm is not too complex, and relatively easy to understand. It works by determined a list of prime numbers from 2, to a given number. It works by checking weather or not numbers within the given range have been marked as composite yet. For example, if you wanted to determine what numbers are prime up to 100, you would start at 2. Because 2 is at the beginning of the range, it has not been marked as composite and therefore is prime. But now we must say that all multiples of 2, up to 100, are composite(4,6,8,etc.). Now we would move on to the next number in the range, which is obviously 3. 3 has not been marked which means it is prime. Now again, we must say that all multiples of 3 are composite(6,9,12,etc.). We now move on to 4, but 4 has already been marked as composite, so we don't need to do anything. We can just move on to 5, which is unmarked. We now mark it as being prime, and again all multiples of 5 are composite(10,15,20,etc.). This process repeats until we have reached the end of the given range(100).
 +
 ====TIC80==== ====TIC80====
  
 =====Specifications===== =====Specifications=====
- 
  
 ====Prime Detection Algorithm==== ====Prime Detection Algorithm====
Line 36: Line 38:
   * Factorable by only two natural/counting numbers: itself and 1.   * Factorable by only two natural/counting numbers: itself and 1.
  
-With your knowledge of programming and the rules of prime numbers, you should be able to make a detection algorithm now!  There are different computational methods for figuring out the primality of a number, we will take a look at one of the simplest ones first (more may be added in the future to this page).+With your knowledge of programming and the rules of prime numbers, you should be able to make a detection algorithm now! There are different computational methods for figuring out the primality of a number, we will take a look at one algorithm which is a bit more difficult to understand.
  
 ===Sieve of Eratosthenes=== ===Sieve of Eratosthenes===
Line 48: Line 50:
 ====Implementation==== ====Implementation====
  
-Since the Sieve of Eratosthenes relies on what is effectively an array of Booleans, the process of implementation must begin roughly there. An array must be initialized of size N-2, where N is the upper bound of the user-selected range. This array will effectively be one of potentially prime numbers ranging from 2 to N. As calculations begin, this array must be walked effectively in increments of the currently selected prime (so, when starting at prime 2, walk in increments of 2) and set each selected index to FALSE or whatever not-prime should be represented as. That walking process must occur every time an un-marked-as-not-prime is encountered, as every time that happens, the selected number is prime and its multiples must be noted. This idea may be vaguely imagined as a for loop where the do-every-time action is not something like `i++`, but instead `i+=currentNumber`.+Since the Sieve of Eratosthenes relies on what is effectively an array of Booleans, the process of implementation must begin roughly there. An array must be initialized of size N-2, where N is the upper bound of the user-selected range. This array will effectively be one of potentially prime numbers ranging from 2 to N. As calculations begin, this array must be walked effectively in increments of the currently selected prime (so, when starting at prime 2, walk in increments of 2) and set each selected index to FALSE or whatever not-prime should be represented as. That walking process must occur every time an un-marked-as-not-prime is encountered, as every time that happens, the selected number is prime and its multiples must be noted. This idea may be vaguely imagined as a for loop where the do-every-time action is not something like `i++`, but instead `i += currentNumber`. 
 ====Display==== ====Display====
  
Line 59: Line 62:
  
 https://www.lua.org/pil/contents.html https://www.lua.org/pil/contents.html
 +
 =====Submission===== =====Submission=====
 +
 +In order to submit the game file, our "tic" file, the file must be added to your lab46 somehow. This can be achieved through FTP software, such as FileZilla, or more easily by putting the file onto your Pi then pushing to your repo and pulling from lab46.
 +
 +//Of course, if you are using the TIC-80 application on your Pi then the file will exist there when saved.//
 +
 +To submit this project using the **submit** tool, run the following command at your lab46 prompt:
 +
 +<cli>
 +lab46:~/src/SEMESTER/DESIG/pnfX$ submit DESIG pnfX GAMENAME.tic
 +Submitting DESIG project "pnfX":
 +    -> GAMENAME.tic(OK)
 +
 +SUCCESSFULLY SUBMITTED
 +</cli>
 +
 +NOTE: "GAMENAME" here is the name of your game. Please do not literally submit a tic file named "GAMENAME", come up with a creative name for your game.
 +
 I'll be looking for the following: I'll be looking for the following:
  
notes/discrete/fall2021/projects/pnf2.1631756943.txt.gz · Last modified: 2021/09/16 01:49 by smalik3