Work related posts have been moved.

9 November, 2010

My work and computing related posts are now at

If you have come here from a work-related perspective (computing, semweb, bioinformatics, math). Perhaps you could go there right now and not read the gory personal stuff here.

Use the wordpress rss mechanism to follow categories:

Follow Paul Murray on Quora

Advertisements

Living Green

8 September, 2018

A while ago, Make Hack Void was contacted by a certain Tracey B, who was interested in a collaborative art project thingy involving, hopefully, some LED lights evoking waves on a sea shore. I had been fooling about with Arduinos and NeoPixels, and I mostly approve of art in general, so I stuck my hand up. The result was – well, not as grand as I might have hoped. But it did work, at least.

Anyway. It seems someone in Norway wants to try something similar, on a slightly bigger scale, so I’ll write down here some stuff which hopefully might be useful to her. I belive she already works with breadboards and arduinos, so this will not be a detailed how-to.

Initial Impressions

Tracey had already sourced a couple of strings of individually addressable LEDs off the internets, which she brought to our initial meeting. But, had no idea how to go about making them light up, much less do some kind of seascape-y thing. With the aid of a magifying glass app, I examined them and determined that each led was powered by a WS2811 driver chip and that the string had three conductors: power, ground, and data. So, my initial reaction was “yep, I think I can make these things go”. I took one of the two strings home with me to see if I could make them at least light up.

This proved to be no problem.

There were other possibilities that might have made the project different. For instance, there are RGB strings of LEDS with four conductors: ground, R, G and B. Another possibility is common-anode. Instead of ground, there’s a +5v. This works well with a ULN2003A. You use a PWM arduino output to switch the ULN2003A, which supplies the power that the lights need. The disadvantage is that you only get one colour for the whole string, which limits what you can do. The advantage is that some of these strings are 12v and quite a bit brighter than what we had.

In any event, I found that the neopixel library that adafruit makes for the arduino worked perfectly fine, except that this particular string did not have the standard RGB arrangement. That also is perfectly fine: the library comes with 6 constants for the 6 possible permutations of RGB. It meant that mixing these particular lights with a string of the more standard variant would be awkward ÔÇŽ but we weren’t planning to do that.

Making them light up

So, with the aid of a loupe I worked out which end of the string was in and which was out. Or maybe I just tried it both ways and found which one worked ­čÖé . Ground and power off the arduino board itself into red and black and one of the standard adafruit demo sketches into pin 6 and from there into the white conductor on the string, and the thing lit up just fine. I discovered the RGB/BGR thing about this particular strand at that time, but this was no problem.

The code

The code – legal arrangement

When doing Arduino projects, I do so with the agreement that the code will be released into the public domain and published on github.

Even for paid projects, the code is released publicly. My position is that you are not paying for proprietary code, you are paying for getting me to write the code that you want. No contracts, no legal nonsense. When I accept jobs on the ‘gigs and collaborations’ board, I just ask that the fee be remitted to my PayPal if the code works for my client and they are happy with it. I think I have been done out of my fee only once.

For a weekend job, I typically charge $50 AUD. It’s my hobby, I do it for fun. I think I did Tracey’s job for free (pretty sure), and just asked her to cover the cost of parts. I do confidential, proprietary code at my real actual job. Any sort of confidentially requirements mean that you have to pay me real actual money, which for me is $100/hr.

Tracey was perfectly happy with the Living Green code being released to the public domain, which is what I expected, and we could proceed.

The code – design of the effect

The code is here.
.

The only design spec I was working with was “something something waves on the sea shore, it can be pretty abstract”. I didn’t know at the time how the strings were going to be mounted or arranged. The string itself was 50 lights long, and Tracey had two of them. I wrote a sketch that would power 100 lights.

Neopixels work by chaining the data. Data is sent to the lights in a stream, and each light removes the head of the stream and sends the rest of the data down to the next light in the chain. If the data falls off the end of the chain – this is no problem. That meant that I didn’t need to worry about the exact number of lights we would be working with.

So, I set up a system of sine waves that would be added together. It’s hideously over-engineered, of course, because that’s just how I roll.

The heart of the system is a C++ class named ‘Sine’. Sine has a wavelength and a frequency (fixed values), and a current theta position. Frequency is rotations per second, wavelenght is how many pixels long the wave is. When advanceMicros() is called, theta is updated. The v() method gets the current value of the sine wave at a given position along the strand, adjusted to a 0-1 range. v_for_mul gives a value of -1 to +1, which I decided to include when I wanted to multiply sine waves together.

There is additional code in there to permit the creation of a static ‘advanceAllMicros’ method. When the Sine objects are instantiated, they automagically add themselves to a static linked list of Sine objects. This means that if you simply create a Sine object and the code periodically invokes advanceAllMicros, that Sine object will move with correct timing without you having to do anything further.

With that class written, it was a matter of coming up with a pleasing effect.

I created a sine wave that moved in one direction (waveIn), and another that moved in the opposite direction (waveOut). I gave these a slightly different wavelenght and speed so that it wouldn’t look too regular. I decided that one of them would be green-ish, and the other kinda cyan. The rgb value of each pixel becomes an average of these two values.

I then decided that it would be nice if these two effects sort of took turns – the wave would move one way and then the other. So I created another sine wave, waveInOut, which moves a bit slower. Rather than taking an average of waveIn and waveOut, I took a weighted average, the weight being taken from waveInOut. This weight doesn’t vary by position along the string – I just use waveInOut.v(0). I could have used position along the string, but you want the effect to be ordered enough that a viewer can see a pattern, but no so ordered that it’s predictable. Another issue is that people aren’t going to be looking at it for very long, so it’s can’t be too visually chaotic.

Finally, I decided that it would be nice to have some sparkly highlights simulating ripples. So I made rippleBase and rippleMul. These run fairly quickly, and the effect is difficult to describe. But I was happy with it. I add this as a pure blue component to the final result, just to mix it up a little.

Finally, I felt that maybe a high-tide/low-tide component would be nice, so I added a tide Sine object with a frequency of ‘once every half hour’, which would adjust the overall effect of the main wave components.

The point of all this being: once you have defined an object that does something definite and simple, playing about with it is reasonably easy. With the Sine object defined, fooling about with different frequencies, different intensities, different combinations of waves is simpler.

What I would do differently

I’m pretty happy with the effect I eventually got. The main issue was the ‘tide’ thing. Having a half-hour cycle is kinda cool, but no-one is standing there looking at them for that long, so it was a bit pointless. The lights were not bright enough for the site, and having them slowly go dim over time didn’t work well on the day. My clients addressed this by rebooting the whole thing periodically, which isn’t ideal.

The code – overall control

Well, with all those parameters to play with, you’d like your client to be able to play with them. I built a mounting box for the project out of a small plastic food container and put a potentiometer and a couple of buttons in it. This allows you to get numbers into the sketch.

Ultimately, I rigged it up so that you could control the overall speed of the effect and the hightide/lowtide brighness. As I mentioned, the whole ‘tide’ thing was a bad idea, so ultimately this control box was pretty useless. I stuck the Arduino itself into it, but that’s all it turned out to be good for.

What I would do differently

These days, I’d provide a web interface. Several ways to do this.

Alternative ways to do sketch control

Don’t bother.

Why bother? It’s some background lights for the real show, which is the art stuff and art words. Relax! Just because I’m doing up some blinkenlights, doesn’t mean it’s the most important thing in the world. Get it right and put that in the code. Of course: this means that you really need to see the final result installed so that you can perform final code tweaks.

Arduino serves up web pages

This is not ideal if you want the general public to be able to fool with the settings, because network interaction will interfere with the display. It will freeze or get choppy while pages are being served.

There’s issues with storage, too. Web pages are bulky, especially if you want images. So we are talking SD cards. It’s really not worth it.

Arduino communicates via HTTP/JSON

Put the webpage elsewhere, have the arduino accept JSON packets from the HTML forms. I have had some sucess using AngularJS for this. The NodeMCU connects to the household web router, with the SSID and password being given to the arduino over a serial connection and stored in EEPROM. Most of the web page content is on wordpress or something.

For the ‘art installation in a shipping container’ situation ÔÇŽ perhaps you’d want to set up a router.

Arduino communicates via serial

That is, you have a computer hidden behind a cushion somewhere and an app running on it talking to the arduino over USB. I’m tending to think this would be the best option if you want to let the system communicate with the general public, simply because it allows you to use a domain name. Have the domain name point at a server on that computer, and have it connected via serial to the microprocessor. To keep people from fooling with the exhibit remotely, have a password that changes periodically.

In general

In general, it helps if you have a fairly definite idea of what you want a system to do. “It should have public interaction” needs to be narrowed down a bit.

Any system that involves serving up web pages is going to need something better than a microprocessor to actually serve them up. A microprocessor can do it, but not well.

I would not be inclined to attempt this remotely, communicating via skype or email.

Physical installation

So, the big day came. We were going to actually mount these lights into Tracey’s art thing.

The art thing turned out to be a fabric covering over some seashell forms made of bubble-wrap. (Which doesn’t do the art side of things justice, of course. Is the Mona Lisa just some pigment on a board? If your job is maintaining the Lourve climate control, then yes.)

The lights themselves – I should mention – were more like christmas lights than like the neopixel strips available from adafruit. Attached to the forms, they did not lay down in neat rows, which was good.

We decided to lay the lights on top of the forms under the fabric. We tried laying them under the bubblewrap, but the light was a bit too diffuse and dim. In the end, we simply stuck them down with tape.

Strings of neopixels can be cut. To operate, all that needs to happen is that they need to be supplied with 5v power, and a data line needs to come out of the out of the last pixel on one string and into the in side of the other. I was concerned that chopping the strings up into fragments might ruin the effect, but this turned out to be not the case. For the ‘nautilus’ shell, we attached a string in a spiral. For the scallop, we cut a length of string into five strips, lad them next to each other, and connected them. The ‘wave’ effect was still evident, or evident enough. Enough that you could say ‘yep, that is totally meant to be the sea’, which is all you need really.

Connections were done from the arduino to the pieces and between each piece using brown automotive wire and automotive ‘bullet’ connectors. This was very horrible, bulky, and ugly. I have since looked at using modular phone handset connectors for the same job, but these are also pretty horrible and the socket for a modular phone connector is bulky.

In retrospect, a three-conductor stereo audio cable with 1/4″ jacks might have been better. An issue might be capacitance, which would limit the length of the the data line.

You cannot power lights like this off the microprocessor pin. We used a separate power supply. The arduino and the neopixels both use 5v USB power, so any USB power-pack is suitable and proved adequate. Power was taken out of this for both the lights and the microprocessor.

Speaking of which, originally I had a UNO-3 set up for all this, but during installation I decided it was a little bulky. I had a leostick clone in my parts box, and soldered connections onto that. Much smaller.

So, how did it go?

It was just not bright enough. Originally, the exhibit was outdoors. Outdoors on an Australian spring day. It’s just not feasible to do any sort of light show it a situation like that. The Australian sun is not just bright, it’s full of UV which physiologically makes it even brighter. Fireworks are not bright enough on an Aussie spring day. 5v LEDs? They never had a chance.

The exhibitors managed to get it moved inside, which at least made the display visible. As I mentioned, the tidal stuff was a mistake, making the lights dim in comparison to ambient.

But, it was rather pretty overall. The power supply worked just fine, and the thing was nicely in context. A couple of people stopped and looked for a moment, which is mostly all you can hope for. Unappreciated art is almost proverbial.

I’m thinking of doing something like this, but in a shipping container. Do you have any advice?

Jeez. Shipping container eh?

I’m pretty sure a string of 50 5v LEDs isn’t going to cut it there, either. Not if it’s a major part of the installation. Here’s some 12v neopixels. Here’s some more. On the plus side, they’re 12v and bright as. On the minus side, it’s $50-$60 for 20 of them. You are not going to get away with much change from a thousand bucks if you want to have an effect encompassing the whole container, no matter how you do it.

You’ll want to inject power into them at intervals – don’t just try powering them from one end. The current will set fire to something. Power each strand of 12 individually. Data is less of a concern. You can daisy-chain everything you have, or run separate logical strands. Adafruit will happily sell you a power supply, but if you’re in Norway then you’d be better off just going to an electronics shop. The nice thing about 12v is: car battery.

I’d get online and search “outdoor stage lighting”, or “DMX”, or I’d head over to “Capital Sound and Lighting” (or the equivalent wherever you happen to be) and talk to those guys. Rent something. I’d explain the them that gosh darn it I’m an actual computer programmer and I can make DMX-driven lights dance, which means actually getting one or two from somewhere and playing with them beforehand so you can justifiably claim that.

An arduino will talk to DMX lights. But there might be better options. Although it’s unlikely that there’s be an off-the-shelf effect box that does what you want, quite possibly there’s a way to get some python code or something talking to an attached peripheral.

In summary

  • The best is the enemy of the good.
  • Some lighting won’t amaze anyone, not in this day and age. Remember that it’s only a support for the actual content of the exhibit.
  • What you are thinking of is probably do-able. It’s going to cost some money.
  • Someone like me needs something concrete to work with first. Art usually happens within the constraints of some medium. The key moment was when Tracey handed me the strand of lights that she wanted me to work with.
  • Nothing is ever quite as good or quite as bad as it first appears to be.

Faust

28 March, 2018

A Faustian bargain. A deal with the devil.

What is it, precisely, that makes a Fasustian bargain Fasustian? Any bargain involves exchanging X for Y, and that’s cool. But a Faustian bargain is more than simply an unfair or ill-considered bargain. It’s more than simply that X was actually worth more than Y. It’s that X was the thing that gave Y its value. That when you surrender X to get Y, Y becomes worthless because you have surrendered┬áX.

Wilde (I think) does this in “The Gift”. The classic is the exchange of your soul for power. Once you have surrendered your soul, any power you might wield you only wield at the command of the one to whom your soul now belongs.

Awesome as Y might be, if you surrender the entire point of having Y in order to get it, then you have made a bad bargain.


More Minecraft

4 March, 2018

This is going to get very freaky, very weird. Oh, maybe not for people who already have a particular kink – people with lisps, Haskel programmers. But everyone not already an FP weenie will need to take a shot of espresso and/or whiskey.

Ok.

So, the build described on my previous post does indeed process astral sorcery crystals. But building all of those chains of NBT variables is a pain. Wouldn’t it be nice if there was a function that would simply get the size and cut of a crystal, nested all the way down in those NBT tags? Well, you can build them.

There are a couple of things to know. First, all of the built-in operators can be turned into an operator variable using (obviously) the operator entry in the portable programmer. You can then use the apply operator to give that variable some parameters, and it works the same as if you had simply used the operator.

Second, FP languages have an interesting method of handling functions with multiple arguments. In principle, a function only ever has one argument – it maps one thing onto another thing. So how is something like, say, addition done? Say we want to add 100 and 200. Well, the + function takes one integer argument. So when you give it a parameter of 100, it returns a function that adds 100 to things. This function is then applied to the second argument, giving you the 300 you wanted.

In Integrated Dynamics you can totally do that, you can take a function taking three arguments and bind something to the first argument, giving you a function (an operator) that takes two arguments. And so on.

I suppose the third thing to note is that all the things I am interested in start at a tag named ‘tag’. That is, various things give you back various types of lists and NBTs. The outer layers are specific to entities, inventories, blocks. For instance, an entity reader gives you an NBT that talks about the location and orientation of the entity, the inventory reader gives you an NBT talking about which slot in the inventory an item is in, the grindstone just starts at the top level, because it’s not done as a cointainer. The stuff common to these containing the astral sorcery gear starts at ‘tag’, wherever that might be. From that point you walk down: tag, astralsorcery, crystalProperties, size/collectiveCapability/purity.

So what I really want is a pair of functions which, given an NBT with a ‘tag’ entry, walk down to the integer ‘size’ entry and return it.

Let’s see how deep the rabbit-hole goes.

Walking down the tree

First, create an NBT object with that ‘tag’ at the top level. For instance, if your entity reader has a crystal floating in front of it, grab the entity aspect of the reader, then use entityNBT and then NBT.tagNBT to grab the ‘Item’ entry out of that tag. You could build a function to do this, but for now I am not going to bother.

I label the item variable ‘crystal’, its NBT ‘crystalNBT’, and the Item entry of that ‘crystalItem’.

This gives us an NBT with the structure that we will be working with – it’s our test data.

Next I use the portable programmer ‘Operator’ function to get two operators: ‘reduce’ and ‘NBT NBT Value NBT’. Yeah, I know. I label these ╬╗reduce and ╬╗getNBT.

I then create a list of string containing the values ‘tag’,’astralsorcery’, ‘crystalProperties’. Case-sensitive, remember. I label this tag2cp.

Now at this stage, we can get the inner NBT fairly easily without needing ╬╗reduce. Create a variable ‘reduce(╬╗getNBT, tag2cp, crystalItem)’. This will use the reduce function to walk down the list of strings applying the ╬╗getNBT operator each time, starting with crystalItem. At the end of the list, it will have reached the target NBT.

You can achieve the same effect using the apply3 operator: ‘╬╗reduce apply3(╬╗getNBT, tag2cp, crystalItem)’.

But I don’t want a variable that extracts the stuff out of crystalItem, I want a function that will extract out of any suitable NBT.

Making the treewalk into an operator

To do this, I ‘╬╗reduce apply(╬╗getNBT)’ to get another variable which I name ‘╬╗nbtWalk’. This is a function that takes two arguments – a list of string and an NBT. It will walk down any NBT with a list, returning the final NBT.

I then create a variable ‘╬╗nbtWalk apply( tag2cp)’, which I label ‘╬╗nbt2cp’. This is a function which, given an NBT, will return that final NBT containing the crystla properties (if it’s there, obviously).

When you create a variable ‘╬╗nbt2cp apply(crystalItem)’ and drop it into a display, well blow me down if it don’t display that inner NBT containing the stuff we want. Let’s label this variable ‘cprops’ for now. We wont need it in the final result, but it’s handy for testing the next bit.

Getting the integer

Now, we can’t use the ╬╗nbtWalk function to get all the way down to size and cut, because these are integers and the ╬╗getNBT function will return nothing.

So, we create an operator variable out of ‘NBT NBT Value Integer’ and label it ‘╬╗getInt’. You can apply an NBT and a string to this to get an integer from inside an NBT. The problem is that the arguments are around the wrong way. If you used ‘apply’, you’d have to bind the NBT first and you’d get a function that would get any integer out of some particular NBT if you give it a tag name. NOt what we want.

So, create a new operator using ‘flip(╬╗getInt)’. This gives us the get Int function with its arguments swapped. I name this ‘╬╗getInt_YX’, with the idea that function arguments are usually named ‘X’, ‘Y’ in that order.

Create a string ‘size’ labelled – ohh, I dunno – ‘size’. At this stage, you can create a variable ‘apply2(╬╗getInt_YX, size, cprops)’ and drop it in a display, and you should see an integer. And not just any integer, but the size of the crystal sitting in front of the entity reader.

Now create a new variable ‘╬╗getInt_YX apply(size)’. This gives you a function returning the size value from any NBT that it is passed. I label this ‘╬╗getSize’.

Putting it together

And to put it together, we use the pipe operator: ‘.’. Simply ╬╗nbt2cp . ╬╗getSize’ to give a new operator, which I label ‘╬╗nbtSize’. And this is the magic, this is the thing we are trying to build. It’s a function taking one argument – the top level astral sorcery NBT containing a ‘tag’ entry, and returning the size of the crystalProperties NBT buried three levels deep. Try it! Create a variable ‘╬╗nbtSize apply crystalItem’. Drop it in a display, and you should see the size. Naturally, you will want to make ones for purity and collectiveCapability (which I always label ‘cut’) as well.

From here

From here, you can, well, do stuff. Turn ‘entity->get(‘Item’)->╬╗nbtSize’ into a single operator, if you want.

But the real thing is building predicates. With these functions, you can now build a predicate ‘crystal has size 900’ by applying 900 to the == operator and piping ╬╗nbtSize into it. This can be used in item exporters and importers as a filter. Stuff like that. I’m not going to rebuild my setup using this method, but the business of sorting out completed crystals from ones still needing to be cut could have been done that way. If it were the case that you could put multiple crystals in the one growth pool, and you want to pull out the ones that are ready, then that’s the way to go.

Anyway, that’s what it took to make this happen in my creative test world. Haven’t used it in survival, yet, but that’s how it’s done.


Some minecraft

2 March, 2018

This post attempts to describe my setup for growing maxed-out astral sorcery crystals using integrated dynamics and integrated tunnels.

To make all this work, we use several ID channels. Each channel has a single chest or fluid tank. The components work by exporting and importing crystals between appropriate channels.

Starlight

Run fluid pipe from beneath your lightwell into a tank. If you are using Thermal Dynamics for this, it must be at least hardened or it will break (starlight is extremely cold). You will need a servo, because lightwells don’t auto-extract. Attach a fluid interface to the tank – my setup uses channel 0.

Channels

Add three chests to the network each with its own item interface on channels 1,2, and 3. Channel 1 will be for crystals needing to be grown, channel 2 for crystals needing to be cut, and channel 3 for completed maxed-out crystals.

Budding off new crystals

Create a spot for the budding pool. This spot will have an entity reader, a world fluid exporter, and an world item importer. Easiest way to to this is to place a solid block, put the components on that, then break the solid block.

Create a fluid variable from a bucket of starlight. This goes in the place fluids aspect of the fluid placer, using channel 0. This will keep the block full of starlight as it is used up.

Throw a celestial crystal with a purity of 100% in the pool. To get one of these, go through the process manually: you only need to do it once.

Make a variable from the ‘entities’ aspect of the reader. This will be of list type. Make an integer variable from the len of that list. Make a constant variable 1. Make a boolean variable that is true when the list length > 1. Put this in the ‘pick up all item entities’ aspect of the world item importer. Set the channel to 1 (or 2, that also works). The rate does not matter, because each crystal counts as its own stack.

The result is that the crystal in the pool will be grown, the starlight replenished as needed, and when a new crystal buds off, it will be put in the chest on channel 1.

Growing the crystals

Make another pool. This one needs a world fluid exporter exporting starlight from channel 0, an entity reader, a world item exporter, and two world item importers.

As with the budding-off pool, read the entities aspect to get a list variable and use the ‘is empty’ list operator to get a boolean variable (easier than len()==0). This goes in the ‘place all item entities’ aspect of the world item exporter, which must get its items from channel 1. The effect of this is that it will pick out a crystal from the ‘needing to be grown’ chest whenever there is no crystal in the pool.

And now it gets a little complicated. ­čÖé

Take a variable off the ‘entity’ aspect of the reader. Make a variable entity off this using ‘entity NBT’, to give an NBT object. Create String variables with the strings ‘Item’, ‘tag’, ‘astralsorcery’, ‘crystalProperties’, ‘size’, and ‘collectiveCapability’. These are probably case sensitive.

Using the NBT.tag function, create a series of variables drilling down the NBT tree -> ‘Item’, ‘tag’, astralsorcery’, ‘crystalProperties’, then on that final NBT create two integer variables using NBT.integer for ‘size’ and ‘collectiveCapability’. Use your labeller. In my setup, I label the ‘collectiveCapability’ variable to ‘cut’, and the ‘size’ variable to ‘size’, duh.

Create two integer variables with values 100 and 900 (assuming we are making celestial crystals. You’d use 400 for regular crystals ÔÇŽ but why would you bother? You only need one to start with). Create three boolean variables size==900 (which I label ‘big’), cut==100 (which I label ‘perfect’), and cut!=100 (which I label ‘imperfect’).

Create a variable using the && operator for ‘big && perfect’. This goes in the ‘pick up all item entities’ aspect of one of the world item importers and should import into to channel 3. This is the output.

Create a variable for ‘big && imperfect’. This goes in the ‘pick up all entities’ aspect of the other world item importer and should import into channel 2.

The end result is that whenever this pool is empty, a crystal will be placed into it from chest #1 and the crystal will be grown until it has size 900. At that point it will get put either in chest 2 or 3 depending on whether is it properly cut or not.

Cutting the crystals

Place a grindstone. This will need 3 player simulators and a block reader. Place another chest with an inventory reader, an item interface, and an item exporter. The item interface will be on channel 4.

Take a variable from the ‘inventory empty’ aspect of the inventory reader. I label this ‘4empty’.

Take a variable from the Tile Entity NBT aspect of the block reader on the grindstone. Make string variables ‘tag’, ‘astralsorcery’, ‘crystalProperties’, ‘size’ and ‘collectiveCapability’ (or re-use the ones you already have).

As with the growth pool, descend the NBT tree on the grindstone to get integer variables for tag.astralsorcery.crystalProperties.size and .collectiveCapability . I prefix all the label names with gs_ for ‘grindstone’, and so these two variables get labelled ‘gs_size’ and ‘gs_cut’.

Use the NBT.hasKey(‘tag’) operator on the root tile entity NBT variable to make a variable named ‘gs_hasCrystal’, and the negation of this to make a variable named ‘gs_noCrystal’. This works because the ‘tag’ NBT entry on the grindstone is only present if there is a crystal in it (there is no ‘Item’ entry because the grindstone is not an inventory – that’s why you need player simulators).

Make a boolean variable labelled ‘gs_perfect’, from ‘gs_cut == 100’. Make another boolean variable ‘gs_imperfect’ from ‘gs_cut != 100’.

Make a boolean variable ‘gs_toosmall’ from ‘gs_size < 100'. I use 100 because a single pass of the grindstone takes less than 100 size off a crystal, and I already have an integer variable with a value 100, so I can re-use it ­čÖé .

Make a boolean variable 'gs_done' from 'gs_toosmall || gs_perfect', and a variable 'gs_notdone' from '!gs_done'.

On the item exporter on the chest, have it 'export all items items' from channel 2 with the condition 'gs_noCrystal && 4empty'. This will place one and only one crystal needing to be cut in the chest when the grindstone is empty. Because the item interface on the chest is channel 4, and the item exporter takes from channel 2, the crystal is moved from channel 2 to channel 4 of the system.

Make an 'item' variable from any celestial crystal.

On the first player simulator on the grindstone, have it 'click item' using the celestial crystal item variable. Channel 4, right-click true, and check NBT to false (otherwise the crystal needing to be cut must be identical to the crystal you made the item variable with). This will place a single crystal from chest 4 into the grindstone, but because the chest only has a crystal when the grindstone is empty, it will not continuously right-click the grindstone and potentially ruin the crystal in there. In effect, what is happening is that chest #4 is used to overcome the problem that we cannot put a boolean on the 'right click with item' aspect of the player simulator. The presence or not of a crystal in chest 4 serves as that boolean.

I have just been watching direwolf’s youtube video. I was not aware of the tiny chest. Using one of these would make this system simpler, as you do not need the 4empty mechanism to ensure that the chest only has one item in it. You still need the gs_noCrystal so that it only gets filled when the grindstone has no crystal in it.

On the second player simulator, make a variable ‘gs_hasCrystal && gs_notDone’ and put it in the ‘click empty’ aspect. This will turn the grindstone until the crystal is too small to grind anymore or the cut is 100.

On the third player simulator, make a variable ‘gs_hasCrystal && gs_done’ and place it in the ‘click empty’ aspect with sneak == true. Set the channel to 1. This will pick up completed (or incomplete cut too-small) crystals and put them back in the bin of crystals to be grown.

The end result is that whenever the grindstone is empty, a crystal is right-clicked into it from chest 2 via chest 4. This gets empty clicked until the crystal is either perfect or too small to grind anymore. At that point, the third player simulator sneak-clicks it back into inventory #1, from where it will make its way to the growing pool.

General notes

And that’s it.

I use a separate variable store for each of the three processes – they’re not that expensive, and it helps with keeping things organised. Labelling the variables is also indispensably helpful when using the programmer. Label the strings, too.

Playing New Horizons III, I find that ID occasionally jams. This tends to happen when I reload the game, and when I AFK away at my main base which is several chunks away (my AS setup is in a sparkly star zone). To fix this, my variable stores are connected to the rest of the system via an extra length of logic cable. I find that breaking and then replacing it un-jams things.

I sometimes find that the World Item Importer on the budding pool fails to import an item. This leaves two crystals in the pool, and astral sorcery will only grow crystals if there’s just one. To fix, pick up both crystals and chuck one back in the pool. The other you can just put in chest 1.

Growing crystals is slow, but this system means you can AFK and come back to three or four maxed-out celestial crystals. One of these will make 11 lenses. The waste crystals that you got from creating your initial 100% pure crystal can be thrown into the lightwells.

And you can add more pools for growing and budding by making a new variable store, making a new set of variables for the pool, and importing/exporting to the existing chests. I’m finding that neither growing nor budding is obviously the critical path – budding is slow because once the crystal gets to 900, it will still be a couple more cycles before the crystal buds; but growing is also slow because after the crystal is grown to 900, cutting will reduce its size and it will need more growing anyway.

In the image at the top of this post, crystals are moving from right to left through the system, because that’s how I wound up building it.

The display reading 799 shows the size of the crystal in the budding pool. It will hit 900 and stay there until the crystal splits, at which point one of the smaller crystals will be removed and one will remain to be grown up to 900 again.

The displays reading 824 and 100 are the size and cut of the crystal in the growing pool.

Not visible in the image are two more displays showing the size and cut of the crystal in the grindstone. These are normally 0, because grinding happens very fast and the grindstone is usually empty.

The displays are not necessary, but they are kinda cool. They are also helpful in that you can see if the system is jammed or not – when it becomes jammed, the displays read 0 even though there should always be a crystal in the budding pool.

If you don’t want to build the full system, I’d suggest that the grindstone displays make it so much easier to grind crystals. Player simulators are expensive, so doing the grinding manually is an option – just come back to the setup every now and again and grind the crystals in chest 2. The displays make it a simple matter to just right-click that grindstone until the numbers are improved, and then it’s back into chest 1.

Personally, I think AS should be nerfed with the rule that if you bud off a new crystal from a celestial crystal, the new, purer crystal should just be a regular one. But as it is, with this system you can have a chestful of maxed crystals AFK.


Br Warming’s Philosphy

22 October, 2017

Our DM is asking us to kinda distil down the essence of what our characters are about. As in: if your character was a D&D god, what would he or she be the god of?

Brother Warming-Light-Of-Saranrae has a couple of things going on, character-development-wise. We have the “half drow who has repudiated his drow-ness” thing. We have the “dude who was very keen to keep out character who was a vampire from going full-on bad” thing.

But really, the thing he does more than anything else is charge into battle. However, we have a priest of Iomedae, goddess of valour, and a paladin of Gorrum, god of getting into bar fights. Aren’t we just doubling up?

Iomedae’s code is here. There are a couple of points in it that aren’t really Br Warming’s thing:

  • I will learn the weight of my sword. Without my heart to guide it, it is worthless-my strength is not is my sword, but in my heart. If I lose my sword, I have lost a tool. If I betray my heart, I have died.
  • I will guard the honor of my fellows, both thought and deed, and I will have faith in them
  • I will never refuse a challenge from an equal
  • I will give honor to worthy enemies, and contempt to the rest
  • I will suffer death before dishonor
  • I will be temperate in my actions and moderate in my behavior

Br Warming is maybe about valour, but he isn’t really about honour. He certainly isn’t about “I will never refuse a challenge from an equal”. His attitude to that is “Meh”. There’s a diffidence about him. Shame isn’t a big motivator for him, which isn’t to say he’s immune from it. He was rebuked, once, by Iomedae herself for lack of clarity of purpose, and he accepted and learned from it.

Gorum’s described here and . here.

The Lord in Iron is considered brash and impulsive; he takes what he wants, by force if necessary, and answers any direct opposition to his will with violence. His priests and followers tend to follow the god’s example, which means that there are more ruthless and exploitative members of his faith than those who espouse altruism.

(This passage would be better if the weasel-words “is considered brash and impulsive” was just made “is brash and impulsive”).

Br Warming is not really about fighting for the sake of it. He isn’t trying to prove something, he’s trying to accomplish something. Furthermore, he is good. Gorum isn’t. He isn’t going to get all offended by stuff and respond with violence – that is a part of the drow character that he has refused.

So, what is he about?


Choose your purpose. Choose your destiny. Choose your cause. Choose right. Choose redemption and rescue. Choose to stand against evil, great and small. Choose to protect the good. Choose to make a difference.

Do not fight for a cause for which you would not die. Do not hazard your life or the lives of others in mean, or ephemeral, or selfish causes; do not hazard your life for no gain. Act wisely as you may.

But then, fight! Fight extravagantly; fight without fear. Strike, and disdain to count the cost. Then strike again. If your life will win your purpose, spend it.

Have faith, and remember your reward in paradise. But first and last, remember the your goal here on earth. It must be worthy of you, so strive to be worthy of it.

“Fight extravagantly. Fight without fear.”

St Warming’s worshippers number a various orders of fanatical suicide monks. Humble as all get out, and prone to directly attacking the command tent or the heavily defended siege equipment. Whatever is going to win the day. It’s also quite common for battlefield medics and unarmoured sappers to venerate him.

They also number some people you wouldn’t expect – Andorran rogue/bards running the underground rail out of Cheliax. Spies infiltrating Red Mantis cults – sure to get caught sooner or later. Even some engineers building bridges in mountain passes find comfort in his teachings. Firemen, or the fantasy equivalent.

Anyone doing something they see as good, that’s probably going to get them killed doing it, whether or not it directly involves fighting, whether or not anyone ever knows about it.


Environmentalism, Tony Abbot, and Satan.

11 October, 2017

A friend asked me for my perspective on this:

“Primitive people once killed goats to appease the volcano gods. We’re more sophisticated now but are still sacrificing our industries and our living standards to the climate gods to little more effect,”

Tony Abbot, reported by The Age.

My reply (which could stand a little editing):

I expect you are asking me specifically because of my past religious background, so I’ll add a perspective from that POV.

Some fundamentalist Christians see in environmentalism a strand of nature-worship. This may be understood as a philosophical pantheism, or a more naive tree-worship. There’s also an equivocation between the “paganism” of the modern hippie and ancient greco-roman “paganism”. They aren’t really the same thing at all, but we call them the same thing. And a person who isn’t a terribly clear thinker easily conflates pantheism with worship of the greek god Pan.

But so what? So what if Greenies think trees are nice? So what if some of ’em have Viking rune tattoos?

It’s important to understand that a fundamentalist christian believes that demonic spirits are literally real. Jesus cast demons out of people. Now, either Jesus was wrong, or demons are actually a thing. There a story of Jesus fasting for 40 days in the desert and being personally tempted by Satan. The story is clearly, clearly allegorical, but the biblical literalist takes the position that if this story was meant to be understood allegorically, God would have told us so.

The ancient Christians believed that the miracles of the pagans were perfectly real, and accomplished by demonic power. Fundies more-or-less regard anything in the least bit “spiritual” that isn’t christian to be of the devil. Whether the gods of Greece and Rome, or the vague woo-woo of the hippies, it’s all demons. When a hippie talks about a sense of connection with nature, they are being connected to the devil.

Fundamentalist Christians see “spirits” everywhere. This modern notion that we ought have a care for the natural world is probably spirits, which is to say demons. It’s all part of the same old big ball of wax that Jesus came to deliver us from. We know it’s spiritual because it’s about values. The abstract idea that values like environmentalism are spiritual and the more concrete idea that the Druids were in literally contact with actual, real demons gets all muddled up and stuck together in a big tangled mess of worrying ideas. (A person who believes in devils is afraid all the time, despite their protestations that their faith in Jesus keeps them safe from them. It’s a constant undercurrent of worry, especially for parents.)

The general notion that science is a good thing, also, is a spiritual force in our society. “Science” itself is a spirit, perhaps. Or perhaps blind trust in science – scientism, if you like – is a spirit, a great evil spirit sort of hovering in the air over humanity. An evil spirit clearly of the devil, because we should be putting our trust in Jesus alone. From it springs a multitude of lies, perhaps the greatest being that we don’t really have eternal spirits and that the devil is not real.

I appreciate that none of this makes much sense, that there’s a truckload of non sequitur in all this mess. But it doesn’t have to make sense. These are fragmentary ideas in the minds of (many? most?) Christians and especially fundamentalist Christians. Remember that most people are not terribly bright. [edit – perhaps what I really meant here was that most people are intellectually lazy, and perhaps what I mean by that is that I was]

This next bit is important, and perhaps I should edit this mail to make it more central:

Fundamentalist, biblical literalist Christians are creationists. The bible says what it says about where the world came from. In order to believe in creationism, you must conclude that the theory of evolution is wrong, or a lie. Consequently, creationists must and do believe that the scientific community is committing a fraud against all of humanity. And has been for hundreds of years. The idea that “science” is actually a vast conspiracy to deceive humanity is not new. It was not invented recently in reply to this latest climate science business. It’s as old as Gallileo and Newton. I mean, sure – not every scientist is an active conspirator. Some are misinformed by other scientsts (we all know that those white-coats are intelligent only in their specific area, and outside that they are absent-minded fools, unlike us reglar folks who have common sense). Some are mistaken. Most are just going along with the general consensus. But “the general consensus” is, of course, a spirit. The bible speaks of a “spirit of the age”. And it all comes back to The Devil.

Now, not all fundies take the whole thing as seriously as all that. And many who do literally belive this stuff don’t really spend a lot of time thinking about the implications of it all. But these ideas are all part of the package, the big old mess of ideas sloshing around in the Hillsonger’s brain pan.

So we get to Tony Abbot, who is not a Hillsonger but is a Roman Catholic. There’s what the americans call a “dog-whistle” in this message – something that is heard by the people that it’s intended for, and is inaudible to anyone else. And that dog-whistle is the charge that environmentalism and the climate science establishment is literally Satanic. Literally motivated and orchestrated by The Devil. Ol’ Scratch. Lucifer himself. Really.

Sure, it’s a long stretch to cast coal-fired electricity plants as fighting the good fight on the side of God against the general corruption of the age. Ludicrous, when you think about it, particularly given Jesus’ views on excessive wealth. The trick, as always, is not to think about it, but to know it. What Orwell called “bellyfeel”, what Steve Colbert calls “truthiness”, what the average Christian calls “knowing it in your heart”. You just know by faith that those greenie ideas are all from the devil, and so we should dig up and burn more coal just to spit in the devil’s eye as much as for any other reason.


Well, you got trouble!

18 August, 2017

We spent the first half of the game trying to get our vehicle back on track. Then, the vehicle fixed, we decided to go head to some snowy hummocks off on the horizon. The hummocks proved to be igloos, inhabited by penguin people.

Most of the rest of the party went down to the proverbial D&D tavern. All kinds of stuff going on down there: strange herbs, stranger sauerkraut. My guy, being strictly teetotal found a soapbox and stared preaching.


Well, my friends, you sure do have a beautiful town here – beautiful town, igloos spotless as an igloo can be, clean streets, public order. You are people with pride, people with dignity. I see people looking build a nest, looking to start a family, looking to build your community just like any clean-living decent folk of any peaceful, law-abiding town in the world will do.

But I’ll tell you, good people: you got trouble. Oh yes! Trouble, right here! Why, just down in that tavern there, right under your very beaks, bold as brass, sitting right out on the main street – not an ounce of shame, not a thought for the decent folk walking by.

Now sure, I know one or two of you might stop by once in a while, and no harm come of of it. But I tell you, they sell alcohol in there! Booze! Hooch! Sauce! By any name the demon drink and I tell you, friends, once that liquor gets its hands on a man he’ll spend all day down at the bar. Never mind the fish needing to be caught! Never mind the eggs sitting on the ice! Oh no, he’ll be in there drinking just one more for the road and that’s trouble, my friends, no doubt about it.

And if they ain’t drinking they’re playing cards, they’re playing pick two, nickel spin, ball in the hole, gambling away the family food to any cheap jack hustler in a shiny suit with an eye for a mark. Before you know it you’re out on the street of a night – nary a crevice to hide from the wind in and that’s trouble, friends, standig out in the night with the storms coming in.

And I tell you, friends, the drink is the least of it. Seedy, disreputable places like that place there, that place right on your main street, why they have their back rooms, and what goes on in those back rooms I don’t want to talk about. They have the lichen in there, friends! Black lichen, and sure enough the red toadstools, too, growing it under the floorboards. Robbing a man of reason! Oh, it starts small, a sniff here or there, a little in your tea, but soon enough a man is taking an ounce a day and licking the walls for more.

And what’s worse is they’ll sell it to children – that’s right! Chicks, still haven’t lost they baby feathers, innocent chicks, and they’ll hook ’em when they’re young, and how will you feel when the chick you reared to be an honest hard-working son or daughter taking care of you in your old age is down at the tavern – right there, I tell you! – down at the tavern spending his or her hard earned fish on low entertainment, frittering away the family inheritance.

Friends, I won’t even talk about the shameless hens in there – scarlet women! Why, that kind of talk will scorch a young man’s ears! Those hens will exchange favours for pebbles to line their own nests, when you see a married man slipping through town with a pebble in his beak, headed for the tavern why you know what he’s going to be doing with it. And where do you suppose he got that pebble? Why from his own family nest! Robbing their own, for a few minutes dance – head bobbing, flippers flapping, drunk as sin and they call it a good night out.

And it all comes around onto your community, onto your homes, because wherever you see vice you’ll find crime, and corruption, and violence right here on the streets, because that’s trouble, and you got trouble right here in this town. Right there in the barrels of drink, right there under the floorboards, right there lounging around in the chairs, a blight on your community, a stain on your fine main street, an insult to every clean-living citizen walking past – yes sir I can tell you’re angry, you have a right to be angry and its long past time that the good, decent, clean living people of this fine, fine town took matters into hand, I say – is that a pitchfork I see? Well, we’ll need more pitchforks, friends, more axes and more crowbars because by the time we are done I promise you every barrel of liquor and baggie of lichen will be out the door and on the fire and every drunken hustler and bum will get the flipper-slapping of his life and we will clean up this town, right here on this street, right here, right now!


“Make a charisma check.”
Nat 20.

The good Reverend Josiah Ezekiel, sole remaining worshipper of the volcano-god Jehovah is as we speak striding toward the town tavern, surrounded by a pitchfork-wielding angry mob.