In order to experiment with the Picotron v10 Gui library, I made this simple 4 op (more like 6 op) calculator! Just copy and paste the following code into a blank Picotron project and press ctrl+r!
gui = Gui() set_window(79,73) buttons = {} state = 0 a = 0.0 b = 0.0 op = nil buffer = "" function _init() for i=1,9,3 do for j=0,2 do add(buttons, gui:attach_button({label=tostr(i+j),x=j*16,y=(abs(i-9)/3)*14+8,bgcol=0x0d01,fgcol=0x070d,tap=function()add_buf(i+j)end})) end end add(buttons, gui:attach_button({label="0",x=0,y=59,bgcol=0x0d01,fgcol=0x070d,tap=function()add_buf(0)end})) add(buttons, gui:attach_button({label=".",x=16,y=59,bgcol=0x0d01,fgcol=0x070d,tap=function()add_buf(".")end})) add(buttons, gui:attach_button({label="=",x=32,y=59,bgcol=0x0902,fgcol=0x0209,tap=function()eval()end})) add(buttons, gui:attach_button({label="+",x=48,y=17,bgcol=0x0b03,fgcol=0x030b,tap=function()set_op("+")end})) [ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=130565#p) |
Logarithm Benchmark
Logarithm algorithms
wiki method
stats
tokens:46
description
the wiki method uses an interesting property of logarithms to compute a value. specifically:
log(A * B) = log(A) + log(B)
by using a look up table for all the logarithms (base 10 of course) of the first 9 digits (1-9) we can use the following code to compute logarithms:
log10_table = { 0, 0.3, 0.475, 0.6, 0.7, 0.775, 0.8375, 0.9, 0.95, 1 } function log10(n) if (n < 1) return nil local t = 0 while n > 10 do n /= 10 t += 1 end return log10_table[flr(n)] + t end |
what this algorithm actually does is repeatedly divide by 10 and add the number of times it does this to a counter. Essentially we are assuming the number n can be expressed as m * 10 *10 *10... and we are simply removing these tens. then re-adding them in at the end.
Goats, Cars n' Doors!
So...
the situation being proposed is: there are 3 doors, behind 2 of them are goats the other has a new car. you (trying to get the car) pick a door, the host stops you and opens a different door. behind that door is a goat. they then ask you "do you switch your answer".
the question: what are the odds of getting that car if you switch vs. not switching.
the problem: everyone i've asked has said its a 50% chance either way, but the answer is actually 2/3 if you switch. why? I have no idea but I built a simulation so you can answer that yourself!

ITS... a typewriter
so I made this after spending an unhealthy amount of time in google docs.
Enjoy spending your time typing in this program, it really has no practical use.
CONTROLS
⬅️/⬆️/➡️/⬇️: move the 'cursor'
🅾️: type the symbol
the green arrow is \n or newline
the red arrow is backspace
the yellow... thing is space bar
and the colored squares switch what characters are available (like upper and lower case)
There is a total of 4 character palettes, I encourage you guys to see if you can expand the palettes even more. it also supports special characters found using CHR().
Also if you find any bugs, I encourage you report them!

.png)
BUTTERPAN [v1.0.0]
STORY
Its Butterpan! Join butter boy on his slippery adventure. try not to melt while gathering all the coins and gems! But watch out! Sometimes the pan gets really hot or someone drops a crab into the pan! See how high of a score you can get!
CONTROLS
arrow keys to move
[o] button to dash
[x] button to shoot hot butter
the meter on the right is how much butter you have left, if it drops to zero you lose.
Extras
this is my first pico-8 cartridge! I could use some feed back on the game and its game play. Have fun! (my personal best score is something like 5000 points)


