© 2011–2012 Steve Andrews
There once was a time when all people believed in God and the church ruled. This time was called the Dark Ages.
- Richard Lederer
I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours.
- Stephen Roberts

Here’s the scenario – you have a large number of photos imported from your camera and they are all massively oversized for upload to the Web.  If you are stuck on an ADSL connection like myself uploading is terribly slow so ideally you want to pre-process the images before uploading them.

Well the good news is if you are using OS/X there is a command line script you can use to do this:

sips ( scriptable image processing system).  I came across this completely by accident but it’s a really handy tool. 

Have a look at the manual pages but essentially if you want to resize an image to a maximum height / width of 960px (depending on which is largest) and preserve the aspect ratio you simply:

sips -Z 960 my_image.jpg

I was playing around with Ruby using the Gosu graphics library a few weeks ago whilst waiting for our internet connection to be sorted and ended up kocking together a biomorph implementation in about 200 lines of code (and that was me being verbose, gotta love Ruby).

Biomorphs are virtual creatures as described by Richard Dawkins in his book The Blind Watchmaker. I guess the point is to show how relative complexity can develop from simplicity in surprising ways using a few simple rules.

The Rubymorph script can be found on Github.

Here is a quick example of the sort of thing it can generate:

Using a BSP Tree to generate a dungeon is surprisingly simple yet effective.

Start with a rectangle and split it recursively until each sub-rectangle is approximately the size you want your dungeon rooms to be. The splitting operation is:

  • select a split orientation – vertical or horizontal
  • select a random position (x for vertical, y for horizontal)
  • split and apply above to sub-rectangles (recursive)

BSP Tree iterations

…and so on. What you are left with is a BSP tree whose leaf nodes you can use as room containers for your dungeon. This has numerous benefits – the leaf nodes are guaranteed not to overlap and you can guarantee that all rooms can be connected by recursively traversing the tree backwards and connecting sub-nodes with corridors.

For Sanguine all I need to generate is an ASCII representation which my Map class can parse to instantiate all of the Locations using a given key. Here is quick screen shot of a generated small map sans corridors:

Dungeon generation

After being distracted writing a C# client for LCoG I finally had time away (not to mention limited distractions) to restart development on my roguelike game. I’ve written it in Ruby and instead of using the traditional Ncurses approach for the UI I’ve opted for a tile-based implementation using the fantastic libgosu.

The source is available on GitHub.

Hail Eris!

Hail Eris!

Several thousand years ago, a small tribe of ignorant near-savages wrote various collections of myths, wild tales, lies, and gibberish. Over the centuries, these stories were embroidered, garbled, mutilated, and torn into small pieces that were then repeatedly shuffled. Finally, this material was badly translated into several languages successively. The resultant text, creationists feel, is the best guide to this complex and technical subject.
- Tom Weller, on evolution

Posted verbatim from a post on JudoForum, useful distinction of forward ukemi (mae/zenpo?):

You seem to be confusing the use of a roll to practice a vertical breakfall, and a true-rolling breakfall. For vertical breakfall practice returning to your feet is just kind of an extra bonus that speeds up practice a bit.

You want to fall with your body extended, not balled up. This is the way you typically fall with judo throws which deliver you straight down to the ground (try rolling out of a harai goshi sometime). In this type of fall, to get up you do not tuck your leg underneath or allow your body to curl up. Rather you land in a good, extended ukemi position and then tense up you body and leg and look behind yourself. Your whole body will lurch right up. This sounds a bit goofy, but it prevents the habit of tucking legs, etc. that can be very detrimental when you are taking a vertical fall.

A “true” rolling breakfall, or roll-out (i.e with the leg tucked under to roll up) is more applicable to techniques that project you outwards when thrown, rather than vertically down to the mat. Many (most?) Aikido throwing techniques project uke outwards rather than straight down, so roll-outs are very popular among the Aikido set, and are generally what you see them doing. If you ever work out with an Aikido person you also have to be careful throwing them, because some of them do not really know how to deal with the type of vertical fall that Judo techniques typically deliver. They may not realize the difference, so don’t throw them too hard the first time.

To break the rolling breakfall into its most basic component, we have our students squat with their butts only a few inches off the ground. Put one foot forward, put the hand of the same side as the foot on the mat (palm down) with your fingers facing towards your body. Now do a slow motion roll-drop to your front knee, then bend and touch your shoulder, once your shoulder touches push off with your back feet and roll across your shoulders. You should feel the mat from one shoulder to the other. As you roll over, allow your legs to extend out and land in the side ukemi position.

Neither one of these types of breakfall are absoloutely right or wrong. They are most applicable to different situations. The majority of Judo throws are going to require a vertical-type breakfall. However, on hard surfaces a rolling type breakfall is going to beway easier on your body. The best thing is to know how to do both types and when to do them.

Looking for a really handy function to calculate the distance between 2 points on a torus?

Here is a simple C# implementation:

public static double Distance(Point a, Point b, int size)
{
    int x = Math.Abs(b.X - a.X);
    int y = Math.Abs(b.Y - a.Y);

    int minX = Math.Min(x, (size - x));
    minX *= minX;

    int minY = Math.Min(y, (size - y));
    minY *= minY;

    return Math.Sqrt(minX + minY);
}