May 27, 2011

The Religion Problem: Perspectives

I view religion as a symptom of humanity's inability to operate as a rational agent. This statement will usually validate itself by being misinterpreted as an attack on religion, despite the statement itself simply stating that religion is irrational, not that it is a bad thing. Furthermore, we don't know if irrationality is inherently bad or worse than rationality, although humanity in general seems to prefer thinking of itself as rational despite repeatedly acting in completely irrational ways, usually without knowing it.

Almost everyone nowadays has grown up with the advice that everyone is special. Most kids figured out around junior high that if everyone is special, no one is special, and some get all depressed over it (like I did). This is logically inconsistent if one examines people in terms of their unique perspectives. Every person on earth has a wholly unique outlook on life, and this is why a crowd of people will often have at least one person who can quickly and intuitively answer a question that stumps the rest of them. Their unique perspective allows them to arrive at a conclusion much faster and more accurately than the others, and so it is this perspective that makes everyone unique. This is also why perspectives are valuable: the more diverse a collection of perspectives, the more likely that one of them will figure out the solution to a given problem. This is especially important to society at large, because society by definition must confront an endless stream of problems from every imaginable background, including some backgrounds we don't have names for yet.

The value of unique perspectives is exemplified by the Geth, a fictional race in the world of Mass Effect. Even though they were willing to destroy the Heretics for choosing a path that made it impossible for co-existence, they were reluctant to simply rewrite them so they would see their point of view because this resulted in a loss of perspective. In addition, the Geth opposed using borrowed technology because it would blind them to alternative paths. These different perspectives and possible solutions are what the Geth see as valuable. Even a perspective that is clearly wrong could potentially be valuable - the only time a perspective's destruction can be justified is if the perspective calls for the destruction of other perspectives, which makes it incompatible with society.

On the other hand, teenage hormones also kick in during Junior High, solidifying the desire to fit in with other people, which is in direct conflict with the desire to be different and unique. The end result is that humans tend to fit in with certain social groups, and try to be different from others. These social groups meld perspectives together, so that the general result is that each social group will have its own general perspective on life that it strives to keep different from other social groups, where individual perspectives tend to meld themselves to be closer to the group. While the potential loss of unique perspectives is unfortunate, as long as there are many social groups, the end result is a diverse population of perspectives in society.

Religions, however, attempt to enforce very similar "bubbles" of perspective, which can grow very large. Monotheism, usually in the form of Christianity, is extremely common in the western world, and is so common in the United States that it has created an enormous bubble of very similar perspectives. To apply the laws of economics to the situation, Christianity is a monopoly on the capitalism of perspectives. Whereas the ideal scenario is a lot of small bubbles of perspectives "competing" with each other, a monopoly makes it much more difficult for smaller, radically different perspectives to gain hold, and actively attempts to make itself larger in any way possible. Just as a monopoly is considered a serious problem in a capitalistic economy, so is a religious monopoly on perspectives.

Some more tolerant views of religion hold that an individual should be free to worship God in whatever way they wish, so long as they are worshiping God. This has two problems, the first being that it often excludes polytheistic religions, but primarily because it always excludes atheism. Theists who believe that atheists are to be tolerated, but would prefer that they didn't exist, are eliminating a perspective.

Consequently, atheists who simply tolerate religion are also eliminating a perspective. The simple fact is that both atheism and theism should always coexist so long as they are compatible with society and other perspectives. This means that the only rational opinion that one can have for religion is that it should be maintained as an entirely personal choice of perspective, and consequently valued as such. Of course, rationality itself is a perspective, so it would be more accurate to say that this is the only possible perspective that does not eliminate other perspectives (unless you can prove that one of the perspectives is sufficiently detrimental to society as a whole). The most valid perspectives, in general, are ones that tolerate other perspectives. Contact is on of my favorite movies, and it does a superb job of illustrating how both science and religion must coexist, and that it would be difficult for either to exist without the other. Science gives us technology, and religion gives us the faith that drives us to believe in potential discoveries before we have any actual evidence to believe them.

Differences in opinions are not problems, they are the manifestations of our unique perspective that make everyone valuable to society. Provided, of course, you aren't screaming "DEATH TO THE INFIDELS", because then you are trying to eliminate someone else's perspective to the detriment of society. Because of this delicate balance between perspectives, it is up to society to decide which perspectives are too much of a danger to others. In doing so, however, we must always remember that Islam is not a single perspective, it is 1.5 billion perspectives.

May 24, 2011

Genetic Game Generation

So theoretically, one could take most of the known game mechanics and give them a genetic identity, and combine this with content generation in such a way you could create an algorithm that pumped out entire randomly generated games with their own (weird) mechanics. If you had a sufficiently advanced library, the genetic code of a given game wouldn't actually be particularly complex, similar to Spore's procedurally generated creatures. By taking advantage of this one could craft a game using the genetic code and then send it around as nothing more then a highly compressed ASCII character sequence.

Naturally this would be very difficult to pull off, because there would have to be very complex interactions between the genetic codes of various game mechanics and rules. However, it has also been demonstrated that you can combine just about any type of game with any other type of game, so in practice it should be possible to generate a majority of fairly workable games after a bit of training. Once the genetic algorithm gets trained enough, it would probably start producing much more reasonable games, although it could also collapse into a single genre if there isn't enough mutability in the algorithm. Seeing whether it collapsed into a popular genre or not would be a rather interesting thing to study.

What's even weirder is that because everything is generated, the game should be able to improvise the game forever, if there is no need of an end. This naturally ignores all the issues with plot, which is an entirely different AI related task.

May 15, 2011

The Ninth Circle of Bugs

So I'm rewriting my 2D culling kd-tree for my graphics engine, and a strange bug pops up. On release mode, one of the images vanished. Since it didn't happen in debug mode, it was already a heisenbug. A heisenbug is defined as a bug that vanishes when you try to find it. It took me almost a day to trace the bug to the rebalance function. At first I thought the image had simply been removed from a node accidentally, but this wasn't the case. It took another day to finally figure out that the numimages variable was getting set to 0, thus causing the node to think it was empty and resulted in it deleting itself and removing itself from the tree (which caused all sorts of other problems).

Unfortunately, I could not verify the tree. Any attempt that so much as touched the tree's memory would wipe out the bug, or so I thought. Then I tried adding the verification function into an if statement that would only activate if the bug appeared - it did not. The act of adding a line of code that was never executed actually caused the bug to vanish.

I was absolutely stunned. This was completely insane. Following the advice of a friend, I was forced to assume the compiler somehow screwed something up, so I randomly disabled various optimizations in release mode. It turned out that disabling the Omit Frame Pointers optimization removed the bug. I didn't actually know what frame pointers were, only that I had turned on this optimization in many other projects for the hell of it and it had never caused any problems (no optimizations ever should, for that matter). What I discovered was astonishing. Frame pointers couldn't be omitted from a function if it got too complicated or needed to unwind the stack due to a possible exception. On a hunch, instead of adding the verification function to the chunk of code that was only executed if the error occurred, I instead added a vestigial 'throw "derp";' line.

The problem vanished.

I knew instantly that either the problem was caused by the omission of frame pointers, which would indicate a bug in the VC++ 2010 compiler (unlikely), or when the frame pointers were included, it masked the bug (much more likely). But I also had another piece of knowledge at my disposal - exactly how I could modify the function without masking the bug. I considered decompiling the function and forcing VC++ to use the flawed assembly, but that didn't allow me to modify the assembly in any meaningful way. A bit more experimentation revealed that any access of the root node, or for that matter, the 'this' pointer itself (unless it was for calling a function) caused the inclusion of the frame pointer. I realized that a global variable would be exempt from this, and that I might be able to get by this limitation by assigning the address of whatever variable I needed to the global variable and passing that into the function instead.

This approach, however, failed. In fact most attempts to get around the frame pointer inclusion failed. I did, however, notice what appeared to be a separate bug in another part of the tree. A short investigation later revealed an unrelated bug in the tree caused by the solve function. However, what was causing this bug (duplicated parentC pointers) still threw up errors after solving the first bug, indicating that it was possible this mysterious insane compiler induced bug was just a symptom of a deeper one that would be easier to detect. After more hunting, a second unrelated bug was found. Clearly this tree was not nearly as stable as I had thought it was.

A third bug was eventually found, and I discovered the root cause of this bug to be an #NaN float value in the tree. This should never ever, ever happen, because it destabilizes the tree, but sure enough, I finally found the cause.

_totalremove(node->total,(const float (&)[4])currect);

Casting from a float* that was previous cast from a float[4] causes read errors at totally random times, despite this being completely valid under the circumstances. My only guess is that the compiler somehow interpreted this cast as undefined behavior and went crazy. I will never know. All I know is that I should never, ever, ever, ever, ever cast to that data type ever again, because guess what? After removing all my debug equipement and putting the cast back in, I was able to reliable reproduce the bug that started this whole mess, and removing the cast made the bug vanish.

This entire week long trek through hell was because the compiler fucked up on a goddamn variable cast. It wasn't a memory leak, it wasn't a buffer overrun, it was just a goddamn miscast variable.

Lesson: Re-validate every inch of your data structure the instant you realize you have a heisenbug, and make sure your validation function properly checks for all things that can screw things up.

May 8, 2011

A recent article by Jesse Stay describes how Twitter and Facebook are killing RSS. Many people point out that you don't really need an RSS feed for either service, since the content they generate is not particularly conducive to an RSS feed. While this is strictly true if you are attempting to read the actual RSS feed, I don't consider this the primary benefit of an RSS feed.

RSS feeds provide a way to broadcast data in a standard format, which then allows an application to be quickly constructed using an RSS parser to process that data. Since its an open standard, efficient, open-source RSS parsers propagate rapidly. This allows creative use of RSS feeds to comb vastly different types of media, and more importantly allows inter-site integration through a single API. That is, if you publish your blog on an RSS feed, scrapers on Last.fm can pick it up and display it on your artist page. The reason RSS is so valuable is because it provides a standard method of communicating contextualized data over the web.

An interesting consequence is that few people actually benefit from the human-readability of RSS. Hence, if there is ever an RSS 3.0, it would benefit greatly from a compressed machine version (perhaps utilizing something like Google's protocol buffers) for fast and efficient data transfer. Proper caching is also important, so an RSS feed is only served up when its been updated. Being able to directly indicate data formats like video and mp3 would also help to enforce more global methods of parsing them (an example being the very useful RSS feed that Newgrounds provides on my audio page). This is a more general problem with XML based formats, however, and is best left for a separate debate.

Either way, while RSS as a standard publication method may be dying, the internet must strive to keep it available for API developers, because RSS promotes freedom of information by providing an easy way to process that information. The interconnectivity of the internet and the freedom of information that it experiences cannot be provided by a proprietary protocol. RSS hasn't even gotten near its full potential and its already dying. Do your part to save RSS by making your website's information accessible via RSS, even if its only in the metadata. The user interface to RSS may be facing extinction, but the information parsing it provides must not be allowed to die.

May 3, 2011

College Is Broken

The reason I have been repeatedly rejected from the computer science major at my college is partly due to underfunded and crowded conditions, but primarily because they are letting in the wrong students. Apparently, had I gotten a 3.5 in all of my classes, I would have been in the major already. Because I instead got a 4.0 in one class and a 3.0 in another, they have rejected me. Why? Because when funding gets tight, they simply throw out anyone with inconsistent grades. Nevermind that half the time people with inconsistent grades are the ones actually passionate about something, while the people with rock solid consistent grades are simply good at getting rock solid consistent grades and don't actually really know what they want to do, but heard that programming pays well.

Nevermind that Math 308 has been shown as the best indicator of success in computer science related math courses and I got a 3.9 in it, which is apparently very hard to do. Nevermind that the professor I talked to had tried to convince the committee to weigh student grades differently in an effort to improve the process but was ignored. Instead, I am to whore myself out to a bunch of grad students because no one wants to look at the paper I wrote until I help a bunch of other people with their papers.

Wow, this sounds familiar. It's kind of like that academic ponzi scheme everyone's been complaining about recently. I have to get involved in this just to get into a major to take some classes? Is this worth my time?

Sony can't do basic security. Modern games are made of brown. User interfaces are rarely built in a user-centric fashion. Academic insistence that performance doesn't matter dominates everything to the point that horrifically bad code is being put into production and customers are told to get new computers. These people have all gone to college, and this is the resulting mess?

I have seen many people defend academic rigor, but I believe there is a point where it becomes utterly stupid. When rigor only exists in theoretical thesis papers, the second some guy actually runs a company with a decent idea, and doesn't screw it up, you end up with Google because they exploited an economic disparity worth hundreds of billions of dollars, created by this insane educational system that is too self-absorbed to figure out how utterly broken it is.