Saturday, July 3, 2010

Games

And now, for something completely else. Hi was originally intended by me as a high-level language for writing games, though I think I am ending up with something which is more suitable for scientific calculations. Now simple functional languages aren't even that good at game code due to the fact unions of types are usually used for situations where in an OO language you'ld use simple inheritance which gives a much simpler approach. I.e., in a functional language, in a game, where you'ld want to manipulate a list of different character types, you'ld need to know a-priori what kind of characters go into that list, whereas in an OO language, you'ld define a list on an abstract interface for characters and derive different characters implementing that interface.

You can work around that problem a bit if you implement type classes, existential types, and simple coercions, which is what I did in Hi. (This actually means you're looking at a very complex solver, which cannot solve all puzzles presented. But, I don't care as long as it typechecks the constraints it is given, for the code it is presented. I rely on the programmer to guide the typechecker through it, and the fact that most programs just are not that complex.)

Since I am looking a looong compiles. I started patching up simple skeletal animation. (I don't know a lot of this, I ended up coding something simple with a small number of control points, where simulations are made a-la a physics engine. I minimize the square-root of the averaged squared distance to where I want those control points to be subject to a number of constraints.)

No comments:

Post a Comment