eyeball This site is a proud member of the geekring!
Check some other geeky websites here!

Previous site -- Random site -- Next site

This will be a web page with just things that interests me which is mostly programming.
Code is hosted at notabug.org/orbb
Feel free to contact me at orbb at cock.li



2021-01-03 A new year. But will I piddle it away like all the others? Most likely. I added something about the origin of the name of the Demiurge in Gnosticism, Ialdabaoth.
When writing Orbz 3D I got stuck on how to rotate objects in 3D. At first I was going to use an algebraic solution. Stated simply the problem was finding three variables, the x, y and z coordinates for the new 3D position after doing the rotation. As we know from basic algebra three unknowns requires us to have three equations in which the variables are used in order to find what their values are. The three things known about the rotated position was the dot product, cross product and the equation for the 2D plane in which it had to exist. Cross product being a vector and not a scalar value you also had to use it with a second vector to get another dot product.
Solving something like this is not terribly complicated. You can break it down into a couple of steps when doing it on paper. When doing it in a program however those steps had to be compressed into a single one and I thought it looked kind of ugly and it wasn't easy to explain what was happening. Instead I found a way to do it using geometry that was a lot more intuitive. I tend to favor geometrical solutions since when you have something visual it is much easier to reason about the solution and therefor remember how it works. It's one of the best areas of mathematics.

Other than that I've been implementing some more small changes to how I program. I found myself often using negative numbers to signal the absence of something. For example each orb in the program can have a parent associated with it, which is another orb who's actions like movement and rotation it can be made to mimic. A parent is then defined as just an integer that represents an array index at which that parent is located. So e.g. the orb at array index 5 might have a parent of 7. So these parent values for all orbs where stored in an int array and since they represented array indices they were only supposed to be positive - negative array indices are of course valid in C as an array is just a pointer but I've never seen this used and can't imagine it to be a good idea ever - so then the array can be of type unsigned int. However some orbs might not have a parent and what I usually do in these cases is use -1 to signal none. If the parent array then had -1 in one place you knew that that orb didn't have a parent.
This though if you think about it is a bit wasteful. You're giving up half the possible values that the array can hold. If an unsigned int can be between 0 and 65,535 then a signed int can only contain the numbers -32,767 and 32,767, and on the negative side you'll only ever use -1, all the others go unused. This might not matter in practice since the program won't ever approach 32 thousand orbs let alone 65 thousand but it still irked me that the parent[] array was now being used for two different purposes: Indicating whether an orb had a parent or not and also storing the value for that parent if it had one.
To make things more explicit and to me clearer I made a bool array called hasParent that is for indicating if an orb has a parent in the first place. The parent[] array can then be made of type unsigned int and each array now only does a single job.
Similarly there was also a function called find_orb() that took an "orb id" and returned an index to an array where that orb could be found. If it didn't find any orb with that id it returned -1. Again I thought this caused confusion since the return value of the function now essentially was variable. The nature of the return value is either a bool representing false if no orb is found and it returns -1 or if one is found it will return a positive integer representing both true and therefor being a bool while simultaneously also being an integer representing an array index. Sure, you can use a define or constant to label the value -1 to something like NONE but I felt this did not get rid of the inherent ugliness in having one number represent multiple things. Modifying the function to only return a bool to indicate found/not found and having it place the array index in a passed in pointer I thought was a neater solution.

2020-12-13 So this is what I've been working on:

Orbz test program

It's supposed to be a vaguely humanoid figure spinning around on two axes. In the last post I mentioned wanting to rework the graphics for the road rash game and while I thought this would be a simple thing to do it turned into a major digression, my artistic ability or lack thereof being the root cause.
I thought I could throw something together in Inkscape, quick and easy but even that proved too much of a challenge, taking too long and looking like crap.
So then I said OK what is the absolutely simplest art style I could make this in? And then I remembered this game:


Which for those who don't know is an old fighting game for the Sega Genesis where all the characters are made up of round sprites that are supposed to look like 3D spheres. The game play can charitably be described as mediocre and it was additionally hampered by having incredibly annoying soundtrack and sound effects.
PF Magic, the company that made it had a long history with this art style although they would branch out from just using spheres. Most of their success came from a series of pet simulation games similar to Tamagotchis called Petz, Dogz, Catz e.t.c. where you had a virtual cat or dog living on your desktop that you had to care for. All of them used the same art style where the pet could be rotated in 3D yet was still made up of flat sprites to save on processing which was at a premium when they started out in the Windows 3.1 days. Giving them a bit of a paper doll like appearance. PF Magic kept this up from Ballz in 1994 all the way to Facade in 2005.

Anyway, I figured if I could make the characters entirely out of spheres I might manage it. Also it's one of the few retro art styles that has not been done to death.
The obvious choice since it was going to simulate 3D was to use Blender and actual 3D spheres instead of sprites. I had used Blender previously to make the sprites for the road rash game but it was not a pleasant experience. Blender like seemingly all FOSS creative programs have an awful UI. Inkscape being the exception that proves the rule by having a great UI. I'd heard they'd revised the UI somewhat since I'd last used it but the new one proved to be no better than the old one and I wasn't making any progress. So I decided it would be easier to just write my own program than to learn Blender.
It took a while to get basic rendering working since I've never done a six degrees of freedom renderer before and didn't want to just copy some solution, I wanted to understand the whole process. Getting it working took a while but I'm pretty happy that I was able to do it with just basic trig and not any rotational matrices which I find difficult to understand.
During the process of writing it I came across a problem of how to sort when using Data Oriented Programming and I wrote a tutorial on how to get around it.
It'll be nice to write a GUI program again. It was kind of soothing to write SAPP since you have a much more constant amount of lines of code written per hour with a GUI program compared to something like doing algorithms where you might get a dozen lines a week and that's if things go your way.
In keeping with PF Magic's tradition of suffixing z to their titles I'm calling it Orbz 3D.

2020-11-10 Been doing a lot of thinking but don't have much to show for it as usual.
The problem had to do with splitting characters into local groups. With collision detection you can't just test every character for collisions against every other character in the game since this would be too wasteful. Instead you have to split them into groups of characters that are close to each other and only do collision detection and stuff for adjacent characters. Otherwise if there were a thousand characters in the game you'd have to run the collision algorithm a million times. The time complexity would I believe be O(n2).
With the road rash game this was simple since the game world is just a straight line so you could sort the drivers on a single coordinate and then test for some small distance forward and back from their position and if there's no collision there then there's no need to go farther away in the game world. However for a 2D map this is not so easy, there isn't just a single coordinate you can sort by but I still wanted a kind of linear list I could iterate through. This in order to avoid having to create some sort of tree structure which although surely a fine solution is a bit overkill and add too much complexity for what is supposed to be a small game.
I tried to come up with some clever solution and ended up looking into a lot of different direction with stuff like space filling curves which do somewhat preserve locality but not to a significant enough degree as to allow you to use them without some ancillary structure like trees. What I'll probably do is create a 2D array of linked lists which isn't exactly a pretty solution but should be easy to implement and is what I intended to do in the first place. So much for being clever.
Although I've come a fair bit along on the ray casting tutorial it's going to be a long one and take a while to finish.
I've also wanted to return to the road rash game. The reason I stopped was that doing the graphics became too time consuming with all the different frames needed for a single animation when trying to recreate the look from the original genesis title. There's three different major animation classes just for the different parts of the screen, if the player is to the left, to the right or at the center of the screen. Then most actions need left and right frames like for punching left and right and on top of that the bike can lean at different degrees all of which have to have their own animation frames. All this amounted to animations having to be stored in a complicated five dimensional array - dimensions being side of the screen, left or right direction, lean degree, action and frame - so you could easily step between different states and a whole heap of animation frames created.
I'd like to simplify all this even if it wont look quite as nice and in addition I want to refactor the code into the DOP stuff I wrote about in the previous post which is actually turning out better than I expected. In fact I'm now getting rid of every single loop in the code, for loops or otherwise and instead use recursion for everything. The thought being that if I remove enough syntax features and boil everything down to some primitivistic ur-language where it's only using primitive types, arrays and functions it would be even more straight forward to write code and also it wouldn't be so strongly tied to a single language like C and it's built in features. So it could more easily be converted in future if need be. Also it's kind of fun to write recursive functions. It's like solving a puzzle.
Anyway hopefully the next update will be more substantial.

2020-10-12 Wrote about my latest experiments in programming that take their start in Data Oriented Programming but then veer off in a different direction and possibly off a cliff.
Then there's a new section about the mark of Cain under religion and I joined the geekring.

2020-09-28 Wrote a page about Red Hat's influence on Linux and the decline of volunteerism.
I've been doing a large rewrite of the game I'm using for the tutorials. This was prompted by a new notion I've taken about how to structure programs and was partially influenced by the previously mentioned page about global variables. It has kept me preoccupied and I'm not sure if it'll work out or if I'll have to revert the whole thing.

2020-09-13 Added something about the Gospel of Thomas under religion and some thoughts about global variables.

Also I recently saw the movie The Counselor. Much panned and deservedly so it's still worth a watch if you like Cormac McCarthy. The plot is incomprehensible but I think that's mostly the director's fault. McCarthy can be a obtuse at times but not this hard to follow. Anyway the real reason to watch it is of course because of the dialog which in true McCarthy fashion borders on monolog. People wax philosophically in what isn't exactly natural speech but that's what McCarthy does really well and I was never bored during the movie.
Another movie written by McCarthy that's a lot better is Sunset Limited. It's about two people sitting in a room discussing life and death and spirituality for an hour and a half and it's pretty great. The basic plot is that Samuel L Jackson has prevented Tommy Lee Jones from throwing himself in front of a train and is trying to convince him not to attempt it a second time. Despite being nothing but a long dialog it still felt more energetic than The Counselor.

2020-08-30 Raycaster is mostly done. Rendering floors and ceiling proved to be quite tricky and it took a while to find an approach that worked well. The tutorial is going to be a long one though and take a while to write.

I've been inspired to get back to an old interest of mine which is religious history from browsing web-site-ring's site and his Bible verse of the day that he puts up. This will be quite different from the other content here but I hope someone likes it. Anyway I've started a page where I put up academic papers about religion that I find worth reading.

I just upgraded from Ubuntu 16.04 to 20.04 and was pleasantly surprised that gcc and gdb error messages are now a lot more detailed. When you try and pass an incorrect argument you get a print out of the function and a large colored arrow pointing the argument that didn’t match. GCC even tries to guess which function you might have meant when you mistype something so color me impressed. This is what I like about using LTS releases, you upgrade every four years and notice the little quality of life improvements that have been added over the years.

To balance this came the disappointment of installing Open Arena. Some of you might know that the name Orbb is from Quake 3, a game I really like but is sadly mediocre at, and I thought why not try the FOSS version, how bad could it be? Really bad it turns out. Within seconds of starting a map I hear this female moaning sound I soon realize I’m being shot at by two anime girls.
Some depraved individual apparently decided to switch the cyber/horror theme of Q3 for anime…
They also managed to mess up the FOV, appearing to simply stretch the the original 4:3 aspect ratio to 16:9 without any sort of perspective correction so it’s pretty unplayable. There are options in the settings to change the resolution and aspect ratio but nothing happens when you click them...
This was worse than FreeDoom which is saying a lot.

2020-08-09 Raycaster is going well although I'm estivating a bit because of the warm weather so it'll take a while longer. In other non-news I just finished James Stephens' Crock of Gold which was pretty good if a bit long winded at times. One passage stood out to me as being prescient for something written over a hundred years ago. It's about the expansion of reason which has come to dominate modern society even though much of what is called reason and science nowadays is at best just grossly misapplied statistics.
"One of the great troubles of life is that Reason has taken charge of the administration of Justice, and by mere identification it has achieved the crown and sceptre of its master. But the imperceptible usurpation was recorded, and discriminating minds understand the chasm which still divides the pretender Law from the exiled King. In a like manner, and with feigned humility, the Cold Demon advanced to serve Religion, and by guile and violence usurped her throne; but the pure in heart still fly from the spectre Theology to dance in ecstasy before the starry and eternal goddess. Statecraft, also, that tender Shepherd of the Flocks, has been despoiled of his crook and bell, and wanders in unknown desolation while, beneath the banner of Politics, Reason sits howling over an intellectual chaos."
Another good quote is about a donkey:
"While there was a road he walked on it: when he might come to a cross road he would turn to the right: when a man said "whoh" he would stop: when he said "hike" he would go backwards, and when he said "yep" he would go on again. That was life, and if one questioned it, one was hit with a stick, or a boot, or a lump of rock: if one continued walking nothing happened, and that was happiness."

2020-07-26: Wrote a tutorial on how to get a bunch of units to handle collisions with each other when moving as a group / flocking. It's not the optimal solution when it comes to pathing one unit around another and you'll have to babysit them occasionally but it's done in very little code and that's one of my main concerns. I've not tested it extensively because honestly I got a bit tired of this problem and wanted to shove it out the door. Likely this has to be modified later like the collision algorithm was when I've used it more but I feel that the basic idea is sound.
Next I want to make a raycaster engine.

2020-07-09: Wrote a bit about SDKs while procrastinating on the group AI tutorial.

2020-06-23: Added an ASCII paint program under projects.

2020-06-08: Updated the collision tutorial. It became necessary after doing a demo with a lot of units bumping into each other and finding a bunch of flaws with it. It now supports proper handling for intersecting squares as well as relative motion. The main part of it is also broken out into it's own function and it has less indentation levels compared to previously so it should be easier to read even if it is a bit longer.
The pathfinding tutorial still uses the old code but I'll get around to updating it soon. The principle remains exactly the same so it won't really affect the tutorial.
Next I want to write a group behavior tutorial now that I've got most of it working but I'm also doing another small GUI program that might sidetrack me.
The site has also passed 1,000 views on neocities which is nice.

2020-05-31: A day late a buck short, as usual. I had a new collision algo that worked but it was too complicated so I scrapped it. Now I got a new one that seems OK and the code is done but I haven't had the time to rewrite the tutorial. Maybe I shouldn't commit to new time tables but it'll probably be done this week.
I did write something about the perennial subject of Linux on the desktop under ramblings. There isn't really a clear line of thought in it but it was something that had been on my mind.

2020-05-10: Added a page about my brief encounter with PLC and visual programming under ramblings. I'm doing a rewrite of the collision detection page that should be done in a week or two.

2020-04-12: Added a book recommendation program under projects.

2020-03-22: Fixed bug in pathfinding tutorial. Collision avoidance should not fire inside the desired convex set.