After a good few months I finally got around to fixing the janky movement of the snake in my snake game in my kernel-level app (it's technically not a kernel).
It finally actually feels nice to play the game now! It used to feel unresponsive, because when you pressed an arrow key you wouldn't get any feedback until the frame completed and the snake moved. So then I made it so that if you pressed an arrow key (other than the one directly opposite to where the snake is facing) the snake would move immediately. However, I had no way to extend the frame when this happened, meaning that the next automatic movement would occur sooner than expected, which made the game more responsive, but a lot more... janky and yucky feeling. So now I finally rewrote the frame logic, and it works!
I think this is probably the nicest proof I've done yet; I'm quite proud of it. Of course talking to the other participants afterwards I realised I was unnecessarily wordy at parts, and maybe there wasn't quite a need for the amount of rigour I went into... Still, this was probably my worst test so far and I wasn't making progress with the other questions, so spending time on making this one pretty helped give me something to do.
Of course, the first draft isn't quite as nice...
But then the memo is literally two sentences... And shows that I didn't need to go into the whole wordy explanation of how moves are duplicated, and I just could've numbered the cells instead...
I'm at the South African training and selection camp for IMC, and at breakfast this morning I got my results from yesterday morning's four hour test...
I've never been happier to get less than 50% on a test! 😁
For context, there's five ten-mark questions on each paper, with the last three of beginner being the same as the first three of advanced; for day two I only did the advanced paper since I got 20/50 the previous day which apparently means I should be in the advanced stream.
I recently saw an interesting series of blogs and a pdf on writing compilers which I want to spend some time with sometime soon. Not today though, I have a statistics test in three hours and calculus tomorrow morning... A rather big calculus test at that...
Inspired by this Matt Parker video, some bad python code to approximate pi:
from random import random
from math import ceil, gcd, sqrt
upper = 1<<32
count = 1<<24
p = sum(gcd(ceil(random()*upper),ceil(random()*upper))==1 for _ in range(count))/count
print(f"{p=} pi={sqrt(6/p)}")
At Maths Club we took turns approximating pi using toothpicks.
I got ten toothpicks crossing a line, out of thirty-two I threw down, giving me an approximation of pi = 3.2; the closest I could have approximated pi with thirty-two toothpicks :D
I really like my corridor this year; it's a lot quieter and more chill than where I was last year, and I roughly know most of the guys here and get along with them.
And I've got return values working! Well, all except floats and pointers, which should be pretty trivial, and structures, which I don't know how difficult it'll be. But I can query the width of a Raylib window!
In the above example, I had rl-call defined as (defn rl-call (name ret () args) (call !ffi-call (cons (!ffi-sym raylib name) (cons ret args)))).
Finally I have working ffi in rholisp! Well, almost working. Return types other than void isn't implemented, and support for floats, doubles, and pointers are not implemented either, but I have enough to open and close a window using Raylib!
I've been working a few hours a day to get a foreign function interface implemented for rholisp, and at last I have something which can load a library, find a symbol in said library, and parse (at least in theory) the arguments and return type for the function. All that remains is to call it!
> (!ffi-load "libm.so.6")
(clib 94310737492496)
> (def libm _)
()
> (!ffi-sym libm "sin")
(csym 139683202493344)
> (def sin _)
()
> (!ffi-call sin ' i64 ' i64 1024) ; yes, this is incorrect, but floats will trigger an assertion for now, so I'm just going to pretend it takes and returns integers
Calling function 0x7f0a87aa6ba0 with 1 arguments...
()
> (!ffi-unload libm)
()
>
Above is some output demonstrating a seemingly working implementation
Finally got a working command-line interface for interacting with dynamically loaded libraries! Inspired by a tsoding video I watched a few months ago.
And finally I have a preliminary working implementation of blips! We'll see if and how much I use this...
Honestly, I might just use it quite a bit, but just update the website every second or third day.
...and now I wanna make an rss feed for this. That'd be fun. But who's gonna subscribe to essentially just the one dude's tweets? Idk. Probably nobody's gonna subscribe to my blog either, so I might as well