Gravity / Bead Sort Demo

So I was bored and watching videos, and I discovered these wonderful videos about the sounds of sorting.

I was intrigued by how fast the Gravity sort seemed to be, and others in the comments were as well. It seems to be one of the fastest in the video at about 11 seconds.

Most of the other sorts take 20 seconds or more.

So I wanted to try to implement the sort in C# to see what it can do. The fruits of that labour are here:

Not as pretty as the colour circle or the other visualizations in the sound of sorting project, but it does the trick.

Maybe some day in the distant future I’ll add visualizations, or you can fork the code and make some for yourself!

The relevant sort code is as follows:

public static void BeadSort(ref int[] data)
		int i, j, max, sum;
		byte[] beads;

		for (i = 1, max = data[0]; i < data.Length; ++i) if (data[i] > max)
			max = data[i];

		beads = new byte[max * data.Length];

		for (i = 0; i < data.Length; ++i)
			for (j = 0; j < data[i]; ++j)
				beads[i * max + j] = 1;

		for (j = 0; j < max; ++j)
			for (sum = i = 0; i < data.Length; ++i)
				sum += beads[i * max + j];
				beads[i * max + j] = 0;

			for (i = data.Length - sum; i < data.Length; ++i)
				beads[i * max + j] = 1;

		for (i = 0; i < data.Length; ++i)
			for (j = 0; j < max && Convert.ToBoolean(beads[i * max + j]); ++j);
			data[i] = j;

Don’t Disable Nav Mesh Agent

So I’ve been working on the game logic to my little Raccoon Run experiment for a few months now in spurts of an hour here or a minute or two there.

I’ve been racking my brain as to why it was not functioning properly.

I made the mistake of building out most of the logic I thought was needed before really testing incrementally.

I couldn’t figure out why my raccoon game pieces were not moving forward after making their initial move.

It turns out that I was disabling the Nav Mesh Agent component on the raccoon game pieces.

This made it impossible for the game pieces to move after their initial move. Turning the component on again does not work, for whatever reason. It must be something to do with how it’s implemented. Regardless, you need to set isStopped to true instead.


Live and learn!

Long Hiatus / New Project

Hi there! I’ve taken a long hiatus from posting here, but I’ve been working on the Ur clone game on and off for the past several months.

Recently Victoria helped me set up a pommodoro whiteboard so I can keep track of my progress. It’s worked somewhat, but September has a lot of social obligations and I haven’t kept up with it as much as I’d like.

I have also coded myself into a corner with the game logic. I’ve realized that it makes sense at this point to refactor a lot of the game logic code.

So when I do get time to do a pommodoro of work, I’ve been trying to clean up and finish that part.

I’m still missing some graphics and the menus and UI could use a lot of love, but I’m still working on it.

In the interim I’ve also bought myself a 3D printer. It’s the TronXY 100. A cheap and cheerful acrylic frame printer. You receive the parts for it flat-packed like Ikea furniture and assemble it yourself.

I’ve been quite liking it. At first it was pretty wonky. The screws for the Z axis (augers?) were too tight in the z-axis gear that meshes with them to carry the z-axis up and down. It was so tight that when I received it, the printer didn’t really work. I had to grease them with automotive grease to get it to even move.

Since then I’ve actually done tiny mods to increase the amount of printable space on the y-axis. I can print slightly larger things and the prints are more accurate now that I’ve tightened things down.

What remains is to maybe build a much sturdier box frame for it instead of the free sanding tower. The tower has some give and I think that manifests as waves in my prints.

All said, I’m as busy as I always am. Maybe I should take time more often to write down my thoughts here, as reading through them again really helps solidify my plans.

That’s all for now. Have a wonderful day!

Vacation in Japan

Since January Victoria and I have had a friend watch our two cats, and we’ve been living in Japan in Adachi ku. It’s been quite a lovely experience so far.

Victoria is taking classes during the mornings. She’s doing a second level introductory course in Japanese.

I find myself learning to read hiragana and katakana much better while I’ve been living here. Seeing it everywhere forces me to wonder what it says, check and reinforce my knowledge.

I even recognize a few kanji! But not many, maybe a handful.

Daily life is pretty interesting. Our apartment is a typical Japanese style with no insulation. Staying over winter offers us a glimpse into the past almost. In Ontario my home was pretty drafty in Winter but we had central heating most of the time I lived there growing up.

This apartment has a little wall air conditioner that doubles as a heater, and two little floor heaters are available in the unit. They can keep the unit… barely warm on a cold day. We wear sweaters indoors to compensate.

It has been lovely lately however. It was warm this past week when we saw our first snow, strangely enough. It has only snowed two days in the entire time we’ve been here. That’s pretty typical for Tokyo.

Even where I live in downtown Toronto we don’t get much snow, but this year they had a good blanket of it. It seems to happen each time we come to Japan. The last time we heard reports of “ice quakes” happening in Toronto in 2013.

We will be here until the end of March and I hope to do some more tourist-oriented activities in that time. It’ll get warmer. The plum blossoms are already out!

I hope we get to see the cherry blossoms too. That would be so lovely.

I made a post asking friends if they wanted post cards and I have already written four of them. Not many of my friends followed the instructions and sent me an address via PM so I didn’t have many to write. I did get the chance to go out and buy some cute stationery and get some selfies at some landmarks printed at the convenience store.

I think we have that in Toronto at Wal-mart although I’ve never used it, but the convenience stores here all have high quality colour printers with photo paper loaded and a friendly interface for printing photos. Great for making your own postcards!

We also have bought a few tiny toys from those vending machines, known as gashapon. I have a Genma Saotome dangling from my bag. I also picked up a little raccoon and a rabbit.

Victoria picked up a tiny Hermione and Harry Potter figure.

The food here is so cheap. If you buy from the grocery store and prepare your own meals, it’s a few dollars per meal.

If you go out to a place like Hotto Motto to eat, well yesterday they had a deal on. We both ate dinner for $8, total. Incredible! And the food is tasty. Hers was a chicken karaage rice bent?? and mine was a similar sort of thing with a tiny bit of spaghetti. All that for $8 is not bad when you’d easily pay double that to eat out in Toronto.

Even restaurants don’t seem that bad if you eat Japanese food. I assume people who say it’s expensive to eat here are going to McDonalds every day or going to other western style restaurants.

Even that is not very expensive.

I know I haven’t updated this blog for a while. I’ve been playing some more with Blender and Unity3D. has an example of a tutorial I did to create a little RPG. It’s still ongoing as the author of the tutorial is still publishing steps.

I think I’m going to make a new version of the old timesheet app I made in PHP years ago but in rails this time. My workplace uses rails so I think I’d like to know it better.

That’s it for this update. Have a lovely day, everyone!