This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2021:projects:fom0 [2021/10/26 16:31] – He feels he deserves nice things jlangtry | notes:discrete:fall2021:projects:fom0 [2021/10/28 03:54] (current) – Added more details on how to understand 'contains' method smalik3 | ||
---|---|---|---|
Line 29: | Line 29: | ||
====Process==== | ====Process==== | ||
+ | |||
+ | ===A Note on the Binary Number System=== | ||
+ | The binary number system is much like the base-10 system we know and love, except there is one small difference; binary is base-2. Thus, the only individual digits available are 1's and 0's. For counting purposes, it is incremented by one on the right side, flipping the left bit once it surpasses 1. This is kind of hard to explain over words alone, so observe this example: | ||
+ | < | ||
+ | 0000 - 0 | ||
+ | 0001 - 1 | ||
+ | 0010 - 2 | ||
+ | 0011 - 3 | ||
+ | 0100 - 4 | ||
+ | 0101 - 5 | ||
+ | 0110 - 6 | ||
+ | 0111 - 7 | ||
+ | 1000 - 8 | ||
+ | 1001 - 9 | ||
+ | 1010 - 10 | ||
+ | 1011 - 11 | ||
+ | 1100 - 12 | ||
+ | 1101 - 13 | ||
+ | 1110 - 14 | ||
+ | 1111 - 15 | ||
+ | </ | ||
+ | From here, you may have noticed a pattern; one can calculate the number of individual base-10 numbers from the length of the respective binary number. For example, the above binary integer had 4 digits. 4^2, in base-10, is 16, and there are 16 respective base-10 integers in the example. So, for a minimum of 9 digits in this project, one can fit an equivalent 2^9 base-10 integers, or 0 - 511. | ||
===Successive Containment=== | ===Successive Containment=== | ||
Line 57: | Line 79: | ||
| | ||
Obviously, this should be scaled up for fom0 purposes, because we will be counting to higher numbers than 15. The logic however remains the same, we just start by subtracting higher numbers for higher places. | Obviously, this should be scaled up for fom0 purposes, because we will be counting to higher numbers than 15. The logic however remains the same, we just start by subtracting higher numbers for higher places. | ||
+ | |||
+ | One more thing to note, conditions like "Is 5 - 4 >= 0?" can be simplified to "Is 5 >= 4?". Both are accurate ways of looking at this method. The point of this method is to see whether a particular number contains another number. If you can subtract one number from another then that number must contain what is subtractable. If a number is greater than or equal to another number, then it must contain the number it is greater than or equal to. | ||
===Modulo Conversion=== | ===Modulo Conversion=== | ||
Line 142: | Line 166: | ||
Blazam! Now we have an ‘on’ state for the final bit, and therefore a known state for every bit in the number 13. For larger numbers like the ones we will see on fom0, we will scale this method up. | Blazam! Now we have an ‘on’ state for the final bit, and therefore a known state for every bit in the number 13. For larger numbers like the ones we will see on fom0, we will scale this method up. | ||
+ | |||
+ | In lua, we will need to take a look at the current bits of the number being converted to binary. A really easy way to do this is with the following syntax "if (number & 1)==1 then". This if statement checks if the furthest bit on the right of the current number being assessed is 1. We can then shift the bits of the current number being assessed to the right and repeat the if statement. | ||
====Display==== | ====Display==== | ||
Line 147: | Line 173: | ||
=====References===== | =====References===== | ||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | https:// | ||
+ | |||
+ | http:// | ||
=====Submission===== | =====Submission===== | ||
+ | |||
+ | To submit the game file, our " | ||
+ | |||
+ | //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: | ||
+ | Submitting DESIG project " | ||
+ | -> GAMENAME.tic(OK) | ||
+ | |||
+ | SUCCESSFULLY SUBMITTED | ||
+ | </ | ||
+ | |||
+ | NOTE: " | ||
+ | |||
I'll be looking for the following: | I'll be looking for the following: | ||