Dirbs: A Return To Form

Zheng Ni Wong of
Butterfly Dragon II:What Different Eyes See
Computational Biologist inspired by
real life computer scientists and coders
When I first set out on my educational journey as a youngster to explore the world of computing, most hardware was incapable of detailed graphics let alone having the kind of horse power to run 3D geometry. Most graphics and simulations were run on the CPU (the Central Processing Unit ie the brains of a computer as most of you already know) and the majority of those CPUs were limited in their ability to perform calculations when compared to the power houses of computer to which we're privileged now adays.

Consider that in most average smartphones in the purses or pockets of their customers that there's the equivalent of a hundred thousand or even a million super computers from the 1950s. Considering that those very computers were used for purposes such as calculating serious math problems (number theory challenges such as Bernoulli numbers comes to mind), weather prediction for military applications and engineering stress testing of composite materials and you'll appreciate that of which the phone in your pocket is capable. A whole generation of engineers are still alive today whose work depended upon computers that are a millionth as powerful as a common smartphone.

Back then, programming was kind of a mysterious art with origins in the sciences and engineering, but also a sort of undefinable quality that can only be described with words like Art and Zen. Engineers will almost always argue that programming should focus solely upon the scientific aspects of its challenges, keeping focus on a set of clearly defined goals that make up the goal of any development project. Yet, within the world of programming, there exists a class of explorers who use design and coding as a tool to explore very mysterious sciences and the nuances of numbers. These first coders were very limited by the hardware around them, so they relied on designing efficient algorithms using the principles of science and engineering to maximize the potential speed of their code. After all, many of them weren't writing in easily readable languages like C/C++, Pascal (1970s) or even ForTran (circa 1957). C was years away (circa 1969) with C++ not arriving until 1985 thanks to Bjorne Stroustrup

These early coders worked in machine language, talking directly to the hardware in the most unreadable instructions, most of which were simply a series of binary digits that represented operation codes (CPU instructions) that would get the hardware to do something very simple, like store a value in memory or load a number onto a register, calculate a division upon that value and check the modulo (remainder) of that division in another register and proceed from there. Even stepping forward in the linear execution of a program required incrementing the program index, a pointer to the current line of execution for these instructions because not all instructions required the same ROM space and did not execute with the same CPU cycles like modern RISC (Reduced Instruction Set Computing) processors.

Even with that kind of fine grained control over every step of the computing process, these early coders and programmers were driven to push the hardware to its limits, exploiting what they knew about specific processors and the underlying hardware to get the best performance, leaving many hardware engineers amazed that their hardware had been pushed beyond its capabilities, as if the coders had somehow created something of a magical nature that stepped beyond the hardware's specifications alone, hence the art of coding was born.

Lady Ada Lovelace:
Alpha Programmer And Coder
Coding wasn't only in pursuit of speed and efficiency. It was an exploratory science and art form, originating from early engineers like Charles Babbage (the hardware designer of the Difference Engine) or Lady Ada Lovelace, who is considered to be the very first programmer and coder by those of us who are a part of this science cum artform cum magic.

Many factors resulted in the blossoming of coding into the phenomenon that it became. Math and science certainly had their role in it, with mathematicians like Benoit Mandelbrot who utilized computation and coding to visualize  the complex plane and imaginary numbers (numbers with a negative square root), coding really became the arena of mathematicians and philosophers but that really exploded with the development of simulation and the very first completely simulated worlds, video games.

Video games drove the market for programming and hardware by creating a consumer market for software and hardware. The very first video games involved simulated world, where the physics and every aspect of cause and effect were computed numerically. As indicated below:

Start Simulation

With Every Moment Of Time Delta

  • Take the mass of each pair of objects in simulation
  • Divide the product of their mass by the distance between them
  • Multiply that by the Gravitational Constant
  • Multiply the ratio of their mass times that value
  • Take that value and add it to velocity
  • Multiply velocity times Time Delta and add the result to position
  • For each object in the world if they overlap a collision has occurred with velocity times mass energy
  • Draw objects

That's basically how every simulation works and just about any video game simulation follows a similar approach. 

Start the simulation. Process what happens with every moment of time that passes including checking the input. Update the affected objects. Rinse and repeat.

Most software developed beyond the 1960s followed this approach to simulation including the game Space War, which is regarded as the first simulation game. Other simulations existed that followed other models where cause and effect did not operate the same way that they do in Space War. For instance, with text adventures, time did not pass until the end user did something in the world and such actions were taken by typing in text line, such as: LOOK EAST or PICKUP ROPE or GO UP. When the end user did such a thing, the simulation would progess one moment of time rather than a fractional time delta.

Each of these two methods of simulation became the foundation for different varieties of simulation software and video games. All simulations and open world games, such as flight simulators, first person shooters and open world games stem from the Space War model while all turn based strategy, role playing games and real time simulation games stem from text adventures.

It wasn't entirely apparent at first how video games would actually forge a path where they were considered reflections of their more scientific counterparts but companies like Maxis with titles like Sim City, Sim Ant and Sim Earth proved that even scientific simulations had a market in the world, especially in education. It was simulations like these that really led to a revolution in thinking when it comes to what eventually will become Computational Biology.

Where Maxis brought the concept to video games, an effects artist named Craig Reynolds brought it to life in the form of film.

You see, Craig was a digital effects specialist working on a top secret project for Warner Brothers on a scene that required a group of digital actors to behave as a flock. This flock would have to be capable of acting and following direction which was the realm of animation. The problem with animation was that it took time and money to perform and was very difficult to integrate changes of direction in a shot. Craig needed something entirely new that would allow them the flexibility to make changes in the performances of the digital actors without spending large amounts of time animating each of them by hand in a computer (costly at the time) so he developed an algorithm called the Boids algorithm.

The original algorithm defined a series of behaviours, each of which created different goals and paired them with a weighted value of the scalability of that goal. Each of the goals were then summed and scaled by their factor and added to the movement for each of the digital actors. Each of these goals also had their own parameters so that giving each digital actor its own set of parameters resulted in a very different performance from the other digital actors in the flock.

The final shot with the digital actors is only a short one, but it changed both digital effects and opened up the doors to different fields, including computational biology. The film was 1989 version of Batman starring Michael Keaton and the digital actors were bats and then in Batman Returns, digital penguins. Craig Reynolds site can be found here as can his original paper on the subject.

So that brings me to Dirbs, the project name I gave to my own algorithm while working on a similar concept to the boids algorithm, though Dirbs uses different methods but achieves similar results. Dirbs much like Boids is a play on the word "bird", where Boids refer to Birds with a decidely East Coast American accent, Dirbs is simply Birds with the B and the D (Butterfly Dragon) swapped to become Dirbs.

This demo is very simple and for me, its a return to form because I haven't done a scrolling text demo since the early days of graphics demos back in the late 1980s.

I used a highly advanced graphics tool for the demo called Gamemaker Studio 2, though there is still a lot of hand coding in there as well. The language is compiled so its a real programming language but with a lot of bells and whistles for managing sprites. Frankly, I'm glad that I didn't have to write the font and sprite handling code myself from scratch because that would have added another month of development and testing time to the whole project.

I also used Embarcadero Delphi a bit for this demo. I've been a C and Pascal coder for most of my life, with a little bit of assembly thrown in for good measure. I swear by Delphi as one of the most powerful development tools for Windows and now for just about every other platform thanks to a variety of compiler targets from everything to Mac and iOS to Android and Linux. Its great for rapid prototyping or creating full dynamic multi-tier client/server applications.

I actually had to take the entire scrolling text for the demo and produce an array with each letter of the text message in its own array element for example:

ScrollyText[0] = "H"
ScrollyText[1] = "E"
ScrollyText[2] = "L"
ScrollyText[3] = "L"
ScrollyText[1] = "O"
ScrollyText[2] = " "
ScrollyText[3] = "W"
ScrollyText[3] = "O"
ScrollyText[3] = "R"
ScrollyText[3] = "L"
ScrollyText[3] = "D"

So I wrote a program (in Delphi) that I could just type a paragraph or two of text into a text editor and it would take that and turn it into code for me. I just pasted the output code into the scripts in Gamemaker Studio 2 and wrote the Dirbs algorithm and the code for animating the text along the path of a sine wave, then drew and animated the sprites and then wrote the rest of the code to put it all together. The whole process probably took close to 30 hours in total, all while I was still learning how to use the interface. 

The great thing with Gamemaker Studio 2 is that it takes a lot of the footwork you'd otherwise spend time writing a management system for your sprite engine or writing Windows code to handle your game loop and measure your timing

For anyone looking to get into graphics and game coding, or to get into the mystical art and science of being a coder, this is a very good place to start. It allows you to work with art assets and access them in code very quickly and easily not to mention you can choose between hand coding everything or using a graphical interface without even having to write code. It even allows you to write and integrate GLSL shaders very easily into your code and apply them to sprites or DirectX surfaces. You can even download a 30 day trial and test it out yourself.

The music is another piece I wrote a few years ago called Digital Senses (Plucked Counterpoint). I played all the parts for the music by my MIDI keyboard (Keyrig 49) and without loops. The drums were a combination of sampled loops and a drum machine VST for which I wrote several patterns. The whole thing was produced on Magix Music Maker in about nine tracks. The vocal part is actually the Text To Speech engine reciting poetry I wrote for the piece, reciting it as an AI. Not my most musically intricate piece from a music theory standpoint, but suitable for this project nonetheless.

Technically its feasible to do the same kind of demo with Unity and Unreal Engine 4 (or the new Unreal Engine 5 if you'd prefer). Adding in 3D makes the process a bit more complicated as far as the math is concerned, but using standard vector functions like the Cross Product and the Dot Product can help immensely, especially with the navigation code. 

The thing with most creatures operating as a flock in a gravity bound environment is that navigating typically happens on a plane rather than a volume. Birds rarely arrange themselves vertically, instead aligning themselves horizontally on a plane that is perpendicular to the direction of gravity. Fish however, seem to arrange themselves in volumes. This is most likely occurring as a solution to the least energy problem of navigation as a school or flock. In water, it makes sense given different mass and density of the fish versus the energy requirements for movement and the pressure differences from one depth to another. With birds, the energy problem would produce flocking patterns that exploit the geometry arrangement of the flock versus the energy expenditure difference required during flight. If it is somehow less energy cost for birds to fly in a flock, then the evolution of that formation will occur naturally.

I suspect that flocking behaviours in simulation produce numerical anomalies that actually relate to efficiency and energy expenditure. If energy isn't a factor, then flock formation is revealing something about the algorithm and the numbers themselves. Almost like a hidden pattern in fractals can be found by repeatedly multiplying two coordinates on the imaginary plane, discarding the result if it grows over a certain threshold.

Not to mention that both Unity and Unreal Engine have or are developing their own digital actor management systems, that integrate everything from flocking and school behaviours (for birds and fish) to crowd simulations including stacking and queueing. All of these features are also integrated with A* path finding and other navigation systems meaning that you can combine path finding goals with crowd behaviour and flocking mechanics. 

This is the stuff that computational biology will be made of in the future, especially where it integrates with evolving and adaptive behaviour. I've been working on my own system for evolution and adaption based upon a priority system weighing between needs and wants, where the behaviour tends to produce the least energy expenditure for the goal. If something needs to eat, it will evolve in such a way that it costs the least amount of energy given its dietary requirements. Even the concept of dietary requirements evolve with this system I'm working on. I'll be using it in a future demo, possibly with the same content as this demo, which you may download for free for here.

DirbsRelease.exe Installer for Windows XP, Vista, 7/8/8.1/10 x86/x64

MD5 Hash: EDA795CEC234D355E57701D2A5152C68

There will be some new content for Butterfly Dragon and A Lady's Prerogative soon. However, I still need some time to recover from the abuse and harassment to which I've been subjected by the stalkers I've described here so many times. It was actually no different today and all through my writing this post I was verbally harassed by both my neighbours and quite a few people outside of my building. Many also tried to steal this project (Dirbs) and to give it to the credit of a resident in my building despite the fact that I don't know or involve myself in the lives of my neighbours. Many (not all) tend to be verbally harassing and part of a cult that spies on people's computers and steals their work while claiming the credit for it. I've indicated that I've reported this activity to the Federal Police, but there really needs to be a formal investigation on a palpable scale and not just for my benefit. The stalking cult seem to be a very blood centric racist cult symbolized by the colour blue. 

As I've stated, I'm a white guy whose love interest is Mandarin Chinese and this cult are very much opposed to such relationships for certain (not all) people. I seem to be one of those people for whom they oppose such a relationship and try to force onto the side of a specific religion and specific blood. Likely Jehovah's Witnesses or something of that nature. I do support LGBTQ2 rights and marriage but I'm heterosexual myself and my love interest is a woman.

I'm actually an Atheist that leans towards Buddhism and Taoism. I live in Toronto, Ontario, Canada in 200 Sherbourne Street in apartment 701.

I'm Brian Joseph Johns and this is https://www.shhhhdigital.ca