Monday, September 25, 2006

No one has to be about to die for you to save a life...

Education. Not one of my normal rants, its just I've noticed that this country has heavily standardised the education system. By standadised I mean improved the worse case, and this seems to have been done at the cost of the best case. My mother teaches in primary (elementary) schools, in the past 5 years more and more plans and assorted paperwork have to be done before a class is taught. It seems to take up all of her time.

Ofsted is the sword hung continually over their heads - "if your plans arn't up to date, or your not teaching from them, we'll be in trouble". It means that huge quantities of her time are spent writing these lession plans (short, mid-range and long term plans) that used to be used directly on lesson time. Apparently NQTs (newly qualified teachers) have the habbit of just downloading plans from the internet, complete with lists of questions to ask the children, filing them, and then reading them just before the class is due to be taught.

This seems sick strange and wrong! The government may have stopped closed door teaching, the dirty old man who teaches nothing but fear of the establishment, but the great teaching, the lessons that inspire children to interest also dissapear. The childhood lessons that you remember are the strange ones that arn't scripted - the ones where you take apart the old class tape player "just because". The ones where you spent the whole morning on a painting because the teacher's having a bad day (cant do that now, heaven forbid missing Numercy Hour).

Ensuring wall to wall mediocrity is a fine goal for a police state, but something has to be done if we want to keep kids interested in the world. If kids are endlessly told to go and colour the picture in when they finish all their work ahead of the class, they might stop trying to work faster than their class.

I've always believed that play is the best way to learn, and that applied learning is endlessly more useful. My brother asks why they are studying detailed poetry in secondary (high) school, and how finding images of the 20th century will help him in life, over say installing windows or how to get a good deal when shopping. The only answer I can really think of is "to keep you busy so your parents can go to work".

But ok, being a realist I cant think of a better way to improve the worst case teaching apart from standardisation. Its a shame that it has to impact all teachers good and bad to work at all!

Saturday, September 16, 2006

Got thinking about it and was probably a little enthusiastic last night. Thought someone must have done this before and remembered java's RMI, which is about what I'm looking for (if you could talk to it from lisp). Trying to get lisp to talk RMI is an option, but the protocol is heavily based on serialization, which'd be a major pain. It'd also require more communication between the languages which, over ports, is never a good thing.

The other option already coded into java is CORBA (I was rofl when I found out there was a organisation called omg). This looked really good until I got to the bit about IDL. Tis a contract for the client, saying what the server will do. In java it is automagically converted into local CORBA objects for the remote (server) class. The problem is that if you want ALL the classes (as you do when your programming) you have to convert all the IDL; you have to specify whick classes you want called in advance, generate IDL and copy it to the client, where it has to be converted into client classes and linked in. This is pants if you want to use all the java library from list (and dont want to generate all the IDL) or want to write classes at runtime in lisp and have them available in java. (OK we could get going on dynamic IDL-generated class loading, but probably best not to...)

So the proposal is a string-based RMI, jacol has implemented most of this, but I'm not too sure its as simple as it could be. Here's my current thoughts on this:

There will be a java server listening on a port. Once connected there are two commands generated by the lisp end and handeled by the java server.
(new-object, class name, parameters...) => object number
(invoke-method, object, method, parameters...) => object number | primative
We'll communicate objects using ints. At no time will the lisp end have any access (beyond the level of a number and maybe classtime) to the contents of a class, this is the programmers mess to sort out.

Java server will have a hashtable of int->object and will perform a lookup to find the object to operate on. Running this as a java server should mean that its really fast loading as there is no warm up time for the compiler, and it is expecting to run swing code...

Now...we also want the lisp side to be able to set callbacks on certain events, eg - "java button 34 pushed, so lisp function (take-over-world 53) is run". There will only be a few situations where these are required eg, GUI, timeouts etc... and it introduces a whole world of pain from concurrency to the need for an always-on-lisp-function-table.

"So half way through evaluating a list function, someone clicks the "make the monkey bigger" button" this is an issue surrounding lisp concurrency.

One option would be to have a wrapper for a lisp stratement call back. Eg if the function demanded an action listener (or one of a select few classes), we create a new action listener would makes a rmi call to lisp. Lisp then has a similar server, that just takes a string command and (evals) it.

This gives us two directional communication -
  • lisp can tell java to do something now
  • lisp can tell java to call some lisp later if one of a finite number of events happen
  • java can tell lisp to do something now
  • java can't tell lisp to run something later... (although this should be kinda trivial)
Looks do-able, just need to look up concurrency issues for clisp...[edit]D'oh - ok I'm not posting much (at all) at the moment, but when that passing comment comes up first on a google search for "clisp concurrency" you know they havn't implemented it yet. Yet another example of the Holyer effect.

There is something very broken (in a good way for me) about google, it gives far too much preference to subdomains! And it does all get indexed very, very fast compared to the rest of the web!

Friday, September 15, 2006

Now macs have all gots webcams, and seeing the current trend towards really shiny GUI buttons, why dooesn't Aqua now have buttons that really reflect what is going on in the room?

Right, I had a good go at lush and after too many errors I'm giving up. Not enough documentation - the Ogre toolkit looked awsome but without any documentation I thought I'd rather be back in Java. There were too many random crashes for my liking but Stack overflows are to be expected tho!:

? (fib 6000)

*** printf : sorry, stack full (Merci Yann)

My next effort is to get the jacol libary built under os x.... The plan here is to use the (if not) excellent (then slow) swing and jMonkey libaries from inside clisp. From what I can tell it (like lush) has been abandoned, but since I know a little Java I figured it was worth a go.

First up this error shows up after ./configure --prefix=/sw/bin (cause I'm a fink user) and doing make

;; Compiling file /Users/tomkelly/Desktop/jacol-0.33/lib/md2.lisp ...
*** - invalid byte #xE9 in CHARSET:ASCII conversion

Tis a character encoding thingy (guess the old version of clisp wasn't utf8 friendly). A little searching showed and answer in an old log page. So it seems to build if you change the 'pre:' section in the Makefile to (alternative fix)
clisp -q -c build.lisp
clisp -Efile ISO-8859-1 -Eterminal ISO-8859-1 -Emisc ISO-8859-1 -q -c ./lib/md5.lisp;
cp ./lib/md5.fas ./src/lisp;



next up I didnt want to install this fly by night (read: no native os x) thing onto my system (and beside make install didn't really work). I changed the jacol-0.33/bin/jacol script by replacing the relevant line with:
then I could start the server-
/jacol-0.33/bin$ jacol -jp 2424 -s
Java server listening on port 2424
Lisp server listening on port 16763
To get me a java server running on port 2424. A basic test says it works - woo!
~/Desktop/jacol-0.33/examples/dates $ ../../bin/jacol date-formatter.lisp
18:46:03 2006
September 2006 AD
The time is 06 46 04
Your time zone is BST
Your time zone is also British Summer Time

But I did end changing the /bin/jacol script file to point to the absolute location of JACOL_HOME. Guess I'm just a linux l4m3r...swing demo works too -

(I always have to get one picture into a post....) Right, so now what do I have to do to be able to call java fns from inside the clisp interactive environment thingy?

Then I decided that I've got way to much free time at the moment for it to be this easy, so I'm trying to write my own socket based RMI for lisp. The trick is with these things to make sure that someone else you can talk to has finished the same thing, or that there are lots of people doing the same thing around you doing the same thing.I have neither - most of the lisp/java crossovers are abandoned....

Monday, September 11, 2006

"The Starcraft AI isn't very I"
"...but it's kinda A"

Here's a thought, if you have a very small circular polygon, and grow the edges outwards (camp skeleton stylee) then it is just an approximation of a Voronoi:

If a and b are polygons and we give each edge a negative weight then where they intersect we get a voronoi tesselation of sorts. By giving the sides different negative speed we immitate a voronoi where each point has a shape that grows out of it. (We could even change the shape as it grows outwards, but thats getting ahead of ourselves)

Now of course this is pointless (as the voronoi has a lower time complexity) for circles. However if we wanted to create an interesting brick wall, instead of circles we could use brick shapes... suddenly we are in the situation where we can grow interesting bricks to fit the shape of the walls. So different shaped bricks can be mixed and matched with suitable input polygon generators.

(from a punt in cambridge, just downstream of the mathematical bridge, or rob's version)
(tower of london from the river side)
There is still a problem when we then get to texturing corners. As explained by Legakis, 2D texturing dont work right on the corners of buildings:

His approach was to cut the building up into a bunch of lego (more like duplo) blocks (funny that he ended up needing a straight skleton implementation to shrink the mortar between the bricks in correctly) . Each block was then textured according to its meta data and situation eg 'next to a window and on the side = this type of block'. This doesn't give much scope for interaction between the bricks, but it does look like a really fast algorithm!

There's some serious potential for improvement here - we push the camp skeleton into 3D and then give it an input volume (bounded by the outer wall and a shrunk wall thickness). Then we create brick shaped (tiny) input polygons in the centre of the bricks and let them grow outwards into one another to fill all the spaces. We get a nicely tesselated brick wall out of it! We'd need to remember to set different speeds on different sides to keep a proportioned brick shape -

(grey are input polygons with various negative weights, other bold lines are camp skeleton output-should extrapolate to 3D too....)
This is too much detail for today's graphcis cards, but from this we could render the bump/displacement maps to make walls look really good. There would be some work in defining where the centre of bricks would go, and possibly the need to tweak Felkel's skeleton implementation to give priority to one brick after an intersection (to keep them square) but it should all work kinda nicely in the end....

I guess we would let the brick volumes intersect, then shrink them back in again to create the morar. The outside surfaces could have a roof-like straight skeleton applied to them to make them bevelled.

Well thats enough work for a pHD, but I've been thinking about this and I think Bristol has left a giant gap in my education - working with other people (who arn't nerds). Think its time I got a job behind a bar.

Random thoughts:
  • If a straight skeleton is created, then we can take another line pattern, say a 'curve' and exturude it along the edges of the skeleton? It wouldn't change the intersection points and would need to be scaled for the different weights, but it may be a faster way to make more complicated rooves:
  • People keep comming to this page for a straight skeleton implemetation (often in java). I think I'd better write one that I dont mind publishing. Think I'll get all the ideas correct in lush first and then throw it into java. I tried seperating out my code from sity the other night, but was far too tightly coupled to get it out gracefully (and its crap).

Sunday, September 10, 2006

Now onwards! just having a go at getting lush to compile on my mac/os x 10.4. Why? well I'm a convert of paul graham's and want to learn lisp, but I'm also into graphics so lush seems about right. I'm a little concerned that it doesn't get updates more than once a year, but may well be a fun toy.

Finally got it built by following the readme and the obvious google links. Once it I was trying to run the demos I kept getting errors like this

*** error : cannot configure OpenGL could not be found.
please make sure GLUT or libMesaglut3 is installed.
Both the library and the development packages are needed.
(see /Users/tomkelly/Desktop/lush-1.2/packages/opengl/opengl-config.lsh for more details)

turned out I also needed to fink install glut, sdl-image & sdl to get the correct .so libraries to run the demo. I just installed it locally to try it out, then ran the lush1.2/demos/RUNME script and it gave me a neat (if slow) menu. I was kinda supprised how little code made the menu (compared to say - java & swing).

Really neat stuff - I gotta learn lisp and learn it good. I've got two things I want to work on nowish -
  • Terrain generation. I've just started reading papers, such as those about the ROAM algorithm - seems really compact algorithm for regular terrain meshes. I kinda invented it in my head the night before, realised how obvious the idea was and then found it online. Realtime mesh decimation (with things like animated deforms or 3D objects) seems like a fun thing to do. Annoyingly the US is way out front in this with the Lawrence Livermore Labs turning out some great papers. First thing is to look through the options - the types of decimation (removing a point, edge or triangle) in combination with organisational schemes (bintrees, octrees, triangle trees or BSP), ideally being able to plug each into each other to get some quick readings would be neat - perhaps lush will help me out on this. It'd be cool to come up with a non-regular mesh decimation technique that allowed for real-time deformations and animations...
  • A rigerous camp skeleton implementation would be fantastic and would be a really good start for a rewrite sity. General plan would be to work out the details, implement it and get it right in lisp then take back into java.
Come to that I find that graham is really into the web based apps, makes me feel a bit out in the cold...all the stuff thats really heating up at the moment is the web sheneagoats. Perhaps I need to get into the games market more - nah working in games would be too much like hard work after all those rumours of how hard they push people at EA.

Blogger rant - would it be that hard for the bloggy people to make uploaded images appear the cursor position? ;) Still I really like the beta version!