a Day with Haskell

I realized two important things the day before yesterday. The first is that I have programmed exclusively on Libaudioverse since the summer started. The second is that I know how to make an interpreter and, quite possibly, a compiler. Coupled with my interests (contributing to projects like Pypy, getting into grad school) and all the people who have said that compilers are a core part of CS, I've bumped it up my list a bit. My college does not give us the opportunity to take a class, so it's time to make my own.

To that end, I decided to finally learn Haskell and spent all of yesterday doing so. This has also been something on my list for a very long while. Basically, I was burned out with Libaudioverse, so it was time to do something else. Haskell is very unusual and also potentially very useful. I was actually quite impressed by how it was able to get at the core of some ideas, but there are some gotchas that prevented the code from being as clean as it could have been. I've got a commented implementation of binary search trees here and want to talk about just how strange Haskell is and why I'm actually very glad I'm learning it.

Please note that I am trying to convert some very deep ideas to English and am losing a lot of the elegance in the process. We can make nice analogies with imperative languages and real-world situations; this is not so with functional languages. Functional languages require working with them to understand them, in much the way that people say you shouldn't learn a foreign language by mapping it to your native tongue. If this post seems confusing or somehow lacking in detail, the reason is that the ideas in Haskell do not map well to English.

Read more…

My Thoughts on The Essential Shape of Games Part 1: What is the Essential Shape of a Game?

NOTE: this is old, and I no longer stand by the design in these posts for a variety of reasons.

My quest for an MMO is leading me down all sorts of interesting avenues, most recently Libaudioverse and self-taught digital signal processing. While Libaudioverse is my top priority project at the moment, I am still devoting a non-negligible amount of thought to some core issues with game programming.

One of these is how one might go about making a game system that has three essential properties: network friendliness, developer friendliness, and flexibility. Spurred on by a design pattern called the Entity Component System, my brain began to generate ideas specifically aimed at MMOs, and for a while it seemed that an Entity Component System was the silver bullet. But I no longer think it is, at least not by itself.

And I wasn't even asking the right question. The question I should have been asking is this: leaving aside network issues for the moment, is there some structure that seems to encapsulate most or all games? The answer seems to be possibly, but I have yet to implement it.

Herein I share my thoughts on what the structure might be. Part 2 defines the problem in terms of an MMO and part 3 will talk about the options for actually getting this up and running. But first, we need to define the structure.

Read more…

Thoughts On C++

I've been refactoring Libaudioverse for the last little while. Specifically, I've been making it C++11. The last time I looked at it, C++11 was this theoretically nice thing as far as I was concerned: if you were anywhere but windows, you could use it no problem. Otherwise, hello Boost and really long compile times. VC++ 2013 changed that. The refactor to Libaudioverse shall shortly be completed (I've got maybe 4 more hours of work). C++11 is solely responsible for a lot of headache-saving, both now and in future. C++11 has changed my opinion of the language. Here's what got me to go from "this is revolting" to "this isn't really my favorite, but it gets the job done when speed really does count". I spent a great deal of time looking at alternatives for projects that need native code. In so far as I can tell, C++ has a huge amount of libraries and is the only option that runs on everything.

Read more…

Some Quick Notes on This Site

Here's just a quick couple things that you ought to know.

First, the comment system has accessibility issues. I am working on this, but the solutions are all suboptimal and it's going to take time. I will see e-mails if you comment. This is hitting NVDA and Firefox the hardest: that combination can't comment, at all. I need to open discussion with Disqus about this as they claim NVDA and Firefox are supported; failing that, I will probably need to write my own or move to WordPress. I can probably get something together, but it's going to take time. For the record, I did manage to comment using NVDA and Firefox when I originally set it up; it has apparently broken since.

Secondly, this blog is set up for MathJax. I'm going to tell you how you view MathJax accessibly in what will probably be the first article in an articles section. It can be done and does not involve MathPlayer. I could use inline LaTeX, but I wish to actually have it look like math; also, the procedure that will work for this web site will work for a miriad of others, not least of which is Stackoverflow. The "official" solutions we're supposed to be using don't work. Specifically why this is the case, and what isn't being done is the discussion of another post.

A Big Status Update and a New Project

I've been quiet on this blog for a good while. Life got really busy. Here's everything that's been going on. The most major piece of news is that I'm a founding member of 3 Mouse Technology. We're well under way at this point and I can finally talk about it publicly. I'm also deprecating Camlorn_audio in favor of a new project. More about both of these below.

Read more…

Python: 2D Rotation and Scaling in Less Than 1 KB

This code isn't super complicated, but has the potential to be quite useful and also quite fast. For those wondering why it works, see complex numbers on Wikipedia. The specific section of interest is "multiplication and division in polar form." I cannot yet produce the formulas heere as I have just realized I have no support for LaTeX and, because of the poor state of math accessibility everywheree, I need to find one that preserves the LaTeX as alt text.

Anyhow, here's the actual code itself:

"""2D transformation library.
Vectors are tuples: (x, y).
Make_rotation takes an angle in degrees, returning a transform that can rotate a vector by degrees.  Negative values are allowed.
Make_scale returns a transform that scales a vector's magnitude.
Multiplying transformations produces a transform that does everything as if they had all been applied separately.
Call apply_transformation to actually use your transform.  Transforms are valid forever.

from math import sin, cos, pi

def make_rotation(degrees):
    rads = degrees/180.0*pi
    return cos(rads)+sin(rads)*1j

#for clarity
def make_scale(factor):
    return factor

def apply_transform(vector, transform):
    result = (vector[0]+vector[1]*1j)*transform
    return result.real, result.imag