Browsed by
Category: Programming

Rapidly Exploring Random Tree

Rapidly Exploring Random Tree

Algorithm of the day: Rapidly exploring random trees (RRT) is an algorithm designed to efficiently search non-convex spaces by randomly building a space-filling tree. The tree is constructed incrementally from samples drawn randomly from the search space and is inherently biased to grow towards large unsearched areas of the problem. They easily handle problems with obstacles and differential constraints and have been widely used in autonomous robotic motion planning.

DirectX 12 learning videos

DirectX 12 learning videos

Traveling through hyperspace ain’t like dusting crops, boy! Without precise calculations we could fly right through a star or bounce too close to a supernova and that’d end your trip real quick, wouldn’t it?

Han Solo – Star Wars Episode IV: A New Hope

Moving to Vulcan and DirectX 12 isn’t like going from DX9 to DX11, or Opengl 3.0 to OpenGL 4.0. These new API’s add quite a bit of work that used to be done by the graphics driver. This gives devs more control, but it also makes things a lot more tricky.

Microsoft has generated a good set of videos to teach some of the unique and tricky parts of DirectX12 to those with some graphics background. These videos help teach a number of tricky topics and usages that aren’t immediately apparent by reading the docs.

Conservative rasterization:

Presentation modes in Windows 10

This video has terrible audio quality, but it does a great job covering the various flip modes and delays that they introduce:

Resource Barriers:

This is one of the big concepts that trips you up and causes a lot of confusion.

Software that lands you on the moon

Software that lands you on the moon

I had the rare treat to see an Apollo DSKY control pad used to control the lunar landing computer a few years back. I always wanted to know how it worked.

I can wonder no more, because Robert Wills introduces the amazing hardware and software that made up the Apollo Guidance Computer, walks you through the actual landing procedure step-by-step, and talks about the pioneering design principles that were used to make the landing software robust against any failure. He also explains the problems that occurred during the Apollo 11 landing, and shows you how the Apollo Guidance Computer played its part in saving the mission.

If you feel that isn’t cool enough – why not go download the software and look at the original printouts yourself?https://www.ibiblio.org/apollo/Luminary.html#Source_Code_and_Binary

If you want more information about the computer programming language, algorithms, and entire trip tour, watch this:

Finally, a early NASA technician managed to come across a pile of salvage that he recognized as old Apollo equipment. He bought the 2 tons of materials and in the following years, realized he had an actual Apollo guidance computer (likely used in the lab for testing/etc) and then got it working again!

Update:

He just recently did another talk on the topic with updated details

Ramanujan Machine and AI-enhanced automated research

Ramanujan Machine and AI-enhanced automated research

Mathematicians are a fascinating breed. They look at problems and new fields of study for discoveries and then plug away on a single problem or set of problems for amazing amounts of time. They do this by attacking the problems from every direction using every mathematical tool they have. They use intuition and experience to find patterns, similarities to other problems, and even brute force methods. The goal is to seek out patterns, make sense of those patterns by stating conjectures, and then prove those conjectures into theorems. This often takes mathematicians years or decades – if they ever solve it at all. If nothing else, mathematicians are a persistently curious lot.

The Ramanujan Machine

With all this potential tedium, is there a way to speed some of this up? Could one automate some of the work? AI algorithms are amazing at pattern matching, so what if we use machine learning to start the ball rolling? Enter the Ramanujan Machine – after the famous Indian mathematician that saw patterns where others did not (and had no less than 2 movies made about him). This kind of software may be transformative to how mathematics is done – and some are raising questions about what it means for the field.

The concern is that the Ramanujan Machine does much more than just pattern match. The machine consists of a set of algorithms that seek out conjectures, or mathematical conclusions that are likely true but have not been proved. Researchers have already used machine learning to turn conjectures into theorems on a limited basis — a process called automated theorem proving. The goal of the Ramanujan Machine is more ambitious. It tries to identify promising conjectures in the first place.

The algorithms in the Ramanujan Machine scan large numbers of potential equations in search of patterns that might indicate the existence of formulas to express them. The programs first scan a limited number of digits, perhaps five or 10, and then record any matches and expand upon those to see if the patterns repeat further. When a promising pattern appears, the conjecture is then available for an attempt at a proof.

So far, the Ramanujan Machine has generated more than 100 intriguing conjectures so far – and several dozen have been proved. 

Epistemological questions

The question for the field is now: what does this tool mean for us.

I have already written about the problem of scientific discovery and Epistomology. Machines can now pattern match and come up with equations and descriptions that can describe physical realities, but at what point can we say that we ‘know’ something?

If a machine observes a system and spits out an answer/mathematical description, we often do not know how it arrived at that answer. Can we really say we ‘know’ a thing and are accurately describing it? Without understanding the interplay of the underlying principles that got us to that answer, it might only hold for that set of inputs.

Some would argue, that’s how we’ve always done science. Despite our best efforts, science pushes ever forward and sometimes refutes past theories. We have seen this most dramatically in medical discoveries and regularly in the fields of cosmology and quantum mechanics. However, in mathematics, this is not so. Proven theorems have held for millennium.

So where does this leave us

Honestly, I think software like the Ramanujan machine is the next logical step in mathematics and pure sciences. Just like the calculator became a tool that helped transform math 100 years ago, AI enhanced pattern matching is a next logical tool in the toolbox. Instead of relying on intuition and years of grunt work, it’s unbiased and methodical approach could help us see patterns we have missed, and do it massively faster. After all, correctly formulated mathematical proofs are proofs no matter what the source was.

While it likely cannot replace a well-trained expert, it certainly could help augment their efforts. Speeding up our rate of discoveries by orders of magnitude sounds like a very solid contribution to me.

Try out the machine here: https://www.ramanujanmachine.com/

Read more here: https://www.livescience.com/ramanujan-machine-created.html

See more here: https://www.livescience.com/ramanujan-machine-created.html?jwsource=cl

Or even download the code here: https://github.com/ShaharGottlieb/MasseyRamanujan/

Creating The Oregon Trail

Creating The Oregon Trail

Image for post

In 1984 I was given the assignment to help create a completely new version of The Oregon Trail. The text-based version of the game had already been around for more than a decade — but in all that time the game had never been substantially modified, much less redesigned from the ground up. But that was about to change. MECC, the publisher of the game, was ready to replace the aging product with something completely new, and I was selected to be the team leader and lead designer for the project.

Learn how R. Philip Bouchard lead the creation of The Oregon Trail we know today, but also the hunting minigame was made. Fascinating stuff.

https://medium.com/the-philipendium/designing-the-hunting-game-for-the-oregon-trail-257924bdc6ae

Godbolt Compiler Explorer

Godbolt Compiler Explorer

Ever want to see what assembly code your compiler is really generating?

There are a few reasons to want to know this. Firstly is correctness. Sometimes obscure bugs can crop up when you switch from one compiler to another, from one set of optimization settings to another, from debug to release, or even from one compiler version to another.

The second is optimization. What addressing mode(s) are being used, are there data hazards that are slowing things, are simd instructions being used? Game and high performance compute companies still spend time pulling every cycle they can out of a routine.

It used to be you had to compile and then pull the executable into a debugger and examine the code. Now, there’s an online tool that can quickly do the same. Enter the Godbolt compiler explorer.

It allows you to type in C/C++ code, select from a whole host of compilers, enter custom compiler flags, then show you the generated output.

In the case above, I wanted to verify C/C++ short-circuit comparison behavior of a variable against NULL and then dereference in the same conditional. If the compare against NULL doesn’t execute and exit before the dereference, a NULL pointer exception/segfault will result. According to C/C++ rules, there should be an early out after the comparison against NULL – and sure enough – on line 8 and 9 we see the test and exit.

Anyway – it’s a neat online tool you might give a try to learn more about the assembly your C/C++ code turns into.

Beating splosh-kaboom minigame in Legend of Zelda: Wind Waker

Beating splosh-kaboom minigame in Legend of Zelda: Wind Waker

It took them about 10 years to build this speed running tool, but here it is. How it helps you win is even more fascinating than the minigame itself. Random number generators on consoles are notoriously simple and have been exploited for some time – but this takes it to a whole new level.

It’s a beautiful example of how a computer scientist would break down and solve a problem. It’s also a perfect example of why cryptographically secure random number generators are essential to computer security.

I think I might use this question in future interviews…