Soupster [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=92447 create_diff missing? [Solved] <p><del>Hello. I was playing around with pods, and I noticed that create_diff isn't defined. here's the code (I'm 99% sure I didn't do something really stupid):</del></p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>local a = {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;} local b = {&quot;a&quot;, &quot;c&quot;, &quot;d&quot;} local pa = pod(a) print(pa) local pb = pod(b) print(pb) local pd = create_diff(pa, pb) print(pd)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p><del><a href="https://www.lexaloffle.com/bbs/?uid=1"> @zep</a> was the function removed? it's in <a href="https://www.lexaloffle.com/dl/docs/picotron_pod.html#POD_Diffs">https://www.lexaloffle.com/dl/docs/picotron_pod.html#POD_Diffs</a>, but maybe that's outdated.</del></p> <p>EDIT: Never mind, it's called create_delta!</p> https://www.lexaloffle.com/bbs/?tid=142053 https://www.lexaloffle.com/bbs/?tid=142053 Tue, 30 Apr 2024 19:31:05 UTC Conway's Game of Life <p> <table><tr><td> <a href="/bbs/?pid=147143#p"> <img src="/bbs/thumbs/pico64_cgol-2.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=147143#p"> Conway's Game of Life </a><br><br> by <a href="/bbs/?uid=92447"> Soupster</a> <br><br><br> <a href="/bbs/?pid=147143#p"> [Click to Play]</a> </td></tr></table> </p> <p>Here is Conway's Game of Life in Picotron, using the colour tables as a fast way to count all the pixels at once.<br /> This version does not work in the web player, because input is not detected (<a href="https://www.lexaloffle.com/bbs/?uid=1"> @zep</a> pls fix!)</p> <p>Controls:<br /> Up: Increase simulation speed<br /> Down: Decrease simulation speed<br /> Space: Pause<br /> F: Step one frame<br /> C: Clear screen<br /> R: Randomise screen<br /> L-Click: Draw pixels<br /> R-Click: Erase Pixels<br /> L: Toggle large cursor</p> <p>Basic code:<br /> <div><div><input type="button" value=" Show " onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = ' Hide '; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = ' Show '; }"></div><div><div style="display: none;"></p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function _init() frame = 0 -- Set up userdata so we can draw the screen to itself -- by using memcpy() to a memmapped region of memory. -- The userdata is now the contents of the previous frame, -- and it is now possible to modify the current frame. -- We can also call spr() with userdata -- to draw the previous frame to the current one screen = userdata(&quot;u8&quot;, 480, 270) memmap(0x30000, screen) end function set_col_table(new, current, col) poke(0x8000 + 64*new + current, col) end function _draw() frame += 1 if frame == 1 then -- Randomise the screen for the first frame. for y=0,269 do for x=0,479 do if (rnd() &lt; 0.2) pset(x, y, 7) end end -- Copy the current screen to the buffer, just for the first frame memcpy(0x30000, 0x10000, 0x20000) end --if (frame % 32 &gt; 0) return cls() -- White cells drawn onto colour 0 will set the colour to 1, white onto 1 will be 2 -- and so on. This counts the number of neighbouring cells very quickly for i=0, 7 do set_col_table(7, i, i+1) end -- Draw the screen 8 times in a ring, for each neighbour. The colour tables -- do the counting for y=-1,1 do for x=-1,1 do if (x!=0 or y!=0) spr(screen, x, y) end end -- Set up colour tables to turn the &quot;counted&quot; screen into the next frame -- Set every colour to black except for drawing black onto 3 (brought back alive) -- and 2 or 3 neighbours for alive (stay alive) for i=0, 9 do set_col_table(0, i, 0) set_col_table(7, i, 0) end set_col_table(0, 3, 7) set_col_table(7, 2, 7) set_col_table(7, 3, 7) -- Draw the screen to the &quot;counted&quot; version, with the rules set above spr(screen, 0, 0) -- Reset the draw state to make sure we have a predictable next frame reset() -- Copy the screen to the buffer for the next frame, -- before we pollute it with the FPS counter memcpy(0x30000, 0x10000, 0x20000) -- FPS counter if key(&quot;x&quot;) then rectfill(0, 0, 44, 8, 0) print(&quot;FPS: &quot;..stat(7), 1, 1, 8) end end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p></div></div></div></p> https://www.lexaloffle.com/bbs/?tid=141892 https://www.lexaloffle.com/bbs/?tid=141892 Mon, 22 Apr 2024 21:15:35 UTC