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:

Everyone needs a blog. This is mine.

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:

What actually *is* a *Wall of Force*?

Well, the thing to note is that it is an evocation, not a conjuration. Very different.

A conjurer creates matter having certain properties by knotting the aether into a particular “shape”. A spray of something an acidic, a ball of burning stuff. It will exist for a period of time, usually, and then unravel.

Evocation is quite different, and goes back to Plato’s ideal forms.

What is the *nature* of fire? Well, the nature of fire is __to burn__. An evoker “evokes” – “manifests”, if you prefer – this inner nature of fire, without recourse to any gross matter on which the burniness subsists, and so creates a spherical region of sheer burniness – burniness in and of itself. (The concussion and sound are *consequences* of this, rather than being things in themselves.) Thus, a *Fireball*. Likewise, a *Cone of Cold* is a cone of sheer freeziness; and a *Sound Burst* a burst of loudness.

Now, what is the nature of solid matter, qua being solid matter? As the mage Pauli explains, the nature of solid matter is that it *excludes other solid matter from the volume it occupies*, and exerts __force__ on other solid matter that tries to do so. Why can you not press your hand through a brick wall? Because the brick wall *pushes back on your hand*, in order to keep it out.

That is what a *Wall of Force* is – a volume in which is evoked sheer solidity, solidity in and of itself. Such walls need to be thin because they need to displace the air previously occupying the space. Even a *Bigby’s Hand* (showing my years – we no longer call the spell that, for legal reasons) is only a thin membrane in the approximate shape of a hand. Of course, these ideal forms can only be manifested briefly on Prime – often instantaneously – as Prime is not the place where these forms reside (they normally reside in the same place that fictional objects do). Maintaining an evocation for longer than an instant is always more advanced magic.

Assignment: 200 words. Summarise pp 453-460, “on the nature of fictional objects”.

Additional Credit: explain why a *Disintegrate* unfailingly dispels a *Wall of Force*.

So, everything has gone to shit, Coin is probably dead, Limen was probably in the holy-of-holies – the tesseract – and has kinda stolen our plan. The dimensional anchor is imbedded in Coin’s portrait, and the rope extends off to … somewhere.

We had a bit of a chat to these kinda godlike dudes, who are Coin’s “children”. Maybe. We were going to want to catch up with Limen at the other end of this rope thing. We could follow that rope (which no doubt let through the Plane of Infinite Rats), or maybe take a shortcut.

We opted for the shortcut. We were waned that it might get a little damp.

Now, there’s a bit of history there. One of the doorways opened out onto a ship, which we sank a while ago and which “now” probably lies on the bottom of an ocean.

Checkov’s Gun was mentioned.

Oh, and we needed to find a wizard who was not very good (at being a wizard), but who was going to help in some unspecified way.

And they gave us a little thingy which would stop time while we all had a full nights rest and levelled up. Nice. And a second one. For later. Because we are going to need it.

In the “morning”, John gives everyone a *Water Breathing* spell, which will last for a while, ditto a *Wind Walk*.

First door. Opened out into a sewer. There were all these skeletons that had had the flesh sucked off them, but it was ok because they were fully dead. Nice.

Our key/compass pointed “thataway” to the next door, so we went thataway. Tied up in the middle of the fetor was some dude calling for help. “Please help!”, he yelled, “He’s coming back!”. A brief interrogation during which Brus for the first time ever used his “Detect Lies” class ability determined that he was lying his ass off. We ignored him and went for the door. Oh, and I think Picklick shot him a bit just to see what would happen, because even though Morgs was not at the table that’s just how he rolls.

Anyway. As soon as we got close the dude, of course, attacked and a couple more emerged out of the scenery (it was a sewer – lot’s of scenery). We managed to get them down without *too* much trouble, because it turns out they were flesh-suckers. Every sucked cooked flesh off a chicken bone? Well, they did that. Faugh has taken 3 points of Charisma drain, which – well – doesn’t really do much to him. I think Will took some as well, which *does* affect him. But, he’s rocking about 20 normally, so he’s ok for the moment.

There was a ping from a pile of scenery, and we uncovered a *Ring of Water Walking*. We gave it to Faugh, on account of he is a gnome and occasionally gets in over his head.

Next door. Wood panelled rooms which smelled *awesome* with beeswax. Brus drops a *Bloodhound* spell every day, so was relived to be out of the sewer. Following our compass, we found a wooden shield that had been pierced through with a very odd foot-and-a-half long shortspear, made of a weird material, kinda chitinous and aww shit: is that a bee stinger?

You bet your booty it was.

Anyway. We found this nice room with a boiling kettle, some tea making gear, and no wizard. We opened a door and looked down a corridor to see a dude in a wizard’s hat bolting towards us, pursued by a swarm of unhappy bees. We admit the wizard, slam the door shut, and Picklick proceeds to wedge the door.

Thud!

Them is some big-ass bees. The wizard mentions that he seems to have upset them. Then there’s a knock on the other door. We reason that bees usually don’t knock, so we let the guy in. Wizard looks like he’s seen a ghost.

Guy says “I’m sorry!” and splits open, and a swarm of bees emerge. Then the other swarm breaks through the wedged door.

Fight fight. Will (or Bottom) gets stung, takes Dex damage. We hightail it to the next door, dragging the wizard along.

But there are two doors! One goes to the bottom of the ocean, and one goes – well, somewhere else. We opt for waterworld. But first, a plan is needed. We rope ourselves together – a good start. We will close the other doors, open the portal door and wait for the inrushing water to equalise pressure. Cool. But we have two problems – we have dudes in armour, and we have a wizard who did not get this morning’s *Water Breathing*.

For the Wizard, we decide to stuff him into a *Bag of Holding*. He won’t be in there too long, so will probably not suffocate. Rather than try to convince him to to this, Picklick saps him and we stuff his uncoscious body into the bag. We actually have two, but one of them has a few corpses in it (it’s a long story) so we put him in the other one.

Now, our first thought was to use *Wind Walk*. But after a moment we recall that that spell doesn’t really work well underwater.

But remember that ring of *Water Walking*? That we gave Faugh?

If the spell is cast underwater (or while the subjects are partially or wholly submerged in whatever liquid they are in), the subjects are borne toward the surface at 60 feet per round until they can stand on it.

We decide that Faugh is our buoy. Problem solved!

So we secure our loos items (ioun stones, in particular) and open the door.

Well Brus, who opened the door, takes damage, people are washed back, there’s pummelling and cold damage and John drops a *Resist Energy (cold), Mass*. Much damage. The other doors in the room strain to control the pressure, and John’s invisible Fairy Dragon puts up a *Wall of Force* It won’t last long.

We get through the door and underwater, and far enough away from the portal to not be sucked back in once the WoF goes down. It’s cold, but we are warmed by the thought of what is going to happen to those fucking bees.

Faugh pops us to the top, cork-like. There is a fortuitous boat just nearby, the crew a little startled by people bobbing to the surface of the sea out of absolutely nowhere, and possibly also by the sight of a deep gnome calmly walking on the water like it ain’t no thing.

Aboard the boat, we let our wizard out of the bag. He’s a little bluish, but not too bad. He is also wet, having made the mistake of opening the bag for a moment.

And here we are. Alive, but still racing the clock.

Well, maybe not really complicated math. Or maths, depending on where you come from.

It’s like this. I recently discovered 3d printing. Yay! My thinginverse page is here. Saw a thing by a dude doing a loxodromic lampshade and I am like “man, I am all over that shit like stink on vomit!”

So I decided to do a better one. Mainly because what I *really* want to do is a quasifuchsian curlicue lampshade.

So. I need to write a 3-d bilinear transform that moves the xy plane onto the unit sphere.

Any bilinear transform can be done using two sphere inversions, which are easy-peasy.

So, what pair of sphere inversions do the thingy that I want?

Well, we need more invariants. I want the unit circle to be constant. I want all points on the xy plane to be moved to the unit sphere. I want the z<0 half-plane to be moved to the *exterior* of the sphere.

Now, for some math(s).

I think it’s pretty obvious that the two inversion spheres will be centered on the xy=0 axis. This means that I only have four numbers to figure out. In fact, I can just work with one slice of the space and just do it as a 2-d operation, which makes visualising it muuuch easier.

Three points is enough to fully specify a mobius transform, and I have three points here:

[1,0,0]->[1,0,0]; [0,0,0]->[0,0,1]; ∞->[0,0,-1].

But I don’t want to do this as a mobius transform … although it would be a hell of a lot easier if I did. No! I will stick to the original plan. A pair of sphere inversions. Because you can do arbitrary stuff with it, that’s why.

So, what two inversions accomplish my little plan?

lets call our spheres (circles) Γ1=[0,0,c1]*r1 and Γ2=[0,0,c2]*r2. I invert the point *first* in Γ2 and *then* in Γ1. IOW, p’ = Γ1(Γ2(p)) .

To do a cirlce inversion, you move the center of the circle to the origin, scale the radius to 1, invert, and then move things back again. Inversion is a matter of dividing the coordinates by the square of the distance, which is easy to get

the halfway point is [ x/r, (z-c)/r].

the distance squared of that halfway point is (x/r)^2 + ((z-c)/r)^2 , which is (x^2+(z-c)^2)/r^2

so invertiing we get

[ x/r / ((x^2+(z-c)^2)/r^2), ((z-c)/r)/((x^2+(z-c)^2)/r^2)]

simplify

[ x / ((x^2+(z-c)^2)/r), ((z-c))/((x^2+(z-c)^2)/r)]

[ rx / (x^2+(z-c)^2), (r(z-c))/(x^2+(z-c)^2)]

and then move everything back

[ r^2 x / (x^2+(z-c)^2), (r^2 (z-c))/(x^2+(z-c)^2) + c]

so the effect of Γ2 is

[ r2^2 x / (x^2+(z-c2)^2), (r2^2 (z-c2))/(x^2+(z-c2)^2) + c2]

and the effect of Γ1 Γ2 is

…

ooh-kay. Let’s just do that common term first

K = ({r2^2 x / (x^2+(z-c2)^2)}^2+({(r2^2 (z-c2))/(x^2+(z-c2)^2) + c2}-c1)^2)

giving us

[ r1^2 x / K, (r1^2 (z-c1))/K + c1]

Now, the only way (sorta) this can map the point at infinity to [0,-1] is if K is infinite for [∞,0] and c1 = -1.

So that’s one of our constants sorted. Yay! Let’s substitute it in:

K = ({r2^2 x / (x^2+(z-c2)^2)}^2+({(r2^2 (z-c2))/(x^2+(z-c2)^2) + c2}+1)^2)

Γ1 Γ2 [x, z] = [ r1^2 x / K, (r1^2 (z+1))/K – 1]

Now, what’s going to make K infinite for [∞,0] ? Well, (x^2+(z-c2)^2) needs to be zero. That ain’t going to happen. But that x^2 term in the bottom means that … have we got an infinite radius for one of the circles?? That’s … possible. In fact, inverting the

got it.

If you invert the xy plane through a with radius 2 that is tangent to the origin, this moves the xy plane onto a unit circle centered at .5. Problem is, it’s inverted because it has only been throug one reflection. So invert it through [0,0,-2],r=2, and then reflect the z coordinate at -.25 (or just reflect z and subtract 1). The problem with *that* is that you can’t express it as a pair of sphere inversions if you paramterise it the way I have been doing.

But you know what? Screw it. I only want one specific job done, so I’ll do that.

Thanks guys!

Well, I have found the optimal strategy for Spartacus combat, assuming a simple back-and-forth. The result is … surprising. Surprising enough that I’m wondering “how much better is the optimal strategy to the suboptimal?’

Source is on github.

Ok. The algorithm appears to be generating correct numbers. A couple of bugs, all of them important.

I asked it to compute how to behave in a 1/1 vs. 2/2 battle. This is the smallest situation where one of the parties needs to make a choice: if the 1/1 player manages to make one hit on the 2/2 player, should that player take it off attack or off defence?

Output looks like this:

Calculate state for [A:1/1 vs. D:2/2 (6)] and [A:2/2 vs. D:1/1 (6)] Calculate state for [A:2/1 vs. D:1/1 (5)] and [A:1/1 vs. D:2/1 (5)] Calculate state for [A:1/1 vs. D:1/1 (4)] and [A:1/1 vs. D:1/1 (4)] [A:1/1 vs. D:1/1 (4)] D: winprob 36.8 [A:1/1 vs. D:2/1 (5)], 1 hits. Take 1 off attack, go to state [A:1/1 vs. D:1/1 (4)] invert for attack winprob: 63.1 [A:2/1 vs. D:1/1 (5)] D: winprob 5.1 [A:1/1 vs. D:2/1 (5)] D: winprob 81.6 Calculate state for [A:1/2 vs. D:1/1 (5)] and [A:1/1 vs. D:1/2 (5)] [A:1/1 vs. D:1/2 (5)], 1 hits. Take 1 off defence, go to state [A:1/1 vs. D:1/1 (4)] invert for attack winprob: 63.1 [A:1/2 vs. D:1/1 (5)] D: winprob 9.6 [A:1/1 vs. D:1/2 (5)] D: winprob 83.4 [A:1/1 vs. D:2/2 (6)], 1 hits. Take 1 off defence, go to state [A:1/1 vs. D:2/1 (5)] invert for attack winprob: 94.8 [A:1/1 vs. D:2/2 (6)], 2 hits. Take 1 off attack, 1 off defence, go to state [A:1/1 vs. D:1/1 (4)] invert for attack winprob: 63.1 [A:1/1 vs. D:2/2 (6)] D: winprob 98.3 [A:2/2 vs. D:1/1 (6)] D: winprob 0.4

The important line is this one: `[A:1/1 vs. D:2/2 (6)], 1 hits. Take 1 off defence, go to state [A:1/1 vs. D:2/1 (5)] invert for attack winprob: 94.8`.

If attacker is 1/1, and defender is 2/2, and the attacker scores 1 hit, then the defender should take it off defence. If they do, then they will be in the situation of being 2/1 vs 1/1, which has a 94.8% win probability. Looking at the output, if the defender were to take it of attack then next turn they be in 1/2 vs 1/1, which only has a 90.4% win probability.

Looking at this data, you might ejaculate “This is bullshit! The win probability for 1/1 vs 1/1 is 36.8%! It should be 50/50!” But you would be wrong. You see, that number is the win probability for *the player currently defending*. Certainly, their chance of losing is the same as the attackers chance of losing *if no hits are scored*, but there’s only at 21 in 36 chanceof that.

This applies to any situation and it brings us to our first useful result – it is a good idea to close and attack. In fact, it’s a very good idea. Even if you are weaker than your opponent, you are better off attacking and hoping that that first hit will knock them down some. If it does, great; and if it doesn’t, you are no worse off than you would be if they caught and hit you first.

So the ‘pre’ stage of the battle – moving your pieces around the board – matters, which means mobility matters. Absolutely you want to corner your opponent in such a way that you can get them on your next turn, but they cannot get you on their next turn. I am not sure if the shape of the board means there is a winning strategy for doing this, or if it’s always possible for the players to circle around each other, trying to get that first hit.

Another point of interest is that this strategy is the best strategy if the opponent also follows the best strategy. But what if they don’t? What if there’s a silly mistake that almost everyone makes when they play? Well, your best strategy is to take advantage of that quirk, which means that this strategy is not as good as that one. But I don’t think that your opponent tending to make a particular mistake is going to make this strategy *worse* than it is if they play perfectly.

But I could be wrong about that.

So now that I can generate the data, I can do some theorem testing on it. My first question is: if you take multiple hits, is your best strategy always the same as if you were to take these multiple hits one at a time? I think it’s likely that it is, but not certain. I this *is* the case, then I can make life much simpler by only being interested in the “you take one hit” set of strategies.

The main problem is *presenting* the algorithm. What I need is a simple set of rules saying what to do in any possible situation. That is: the thing that the rules tell you do do should be the same as what (according to this) you actually should do.

Tricky.

Ok. I have four numbers. We are discussing this from the POV of the defender because the question we are asking is “if I take 2 hits, which die should I take them off”?

chanceOfThisToInv is the probability that in the current situation, the attacker will score zero hits on me.

chanceOfInvToThis is the probability that in the reverse of this situation (I scored no hits so now it’s the attacker’s go) I will score zero hits in return on my attacker.

chanceOfThisToWinGivenNotLoop is the probability that *if* I do not score no hits, then I will go on to win. To calculate it, we work out for each possible number of hits what our best move is, and then for that move take the inverse of the possibility of winning (because that’s the situation our attcker will then be in), and multiply it by the probability of scoring that number of hits.

We then divide the total by the total chance of not scoring no hits.

chanceOfInvToLoseGivenNotLoop is calculated correspondingly.

Now, what’s my win probability?

To figure that out, I will have to sumultaneously figure out winProb and invLoseProb, I think, because they depend on one another.

First, let’s shrink the size of those variable names

ti = this to inv it = inv to this rw = raw win pobability, ignoring the loop ril = raw invers lose probability, ignoring the loop. wp = win probaibility ilp = inverse lose probability wp = (1-ti) rw + ti ilp ilp = (1-it) ril + it wp

Ahh crapsicks. I hate these. Actually, no I dont, it’s just been a while since I did one.

wp = (1-ti) rw + ti [ (1-it) ril + it wp ] wp = (1-ti) rw + ti (1-it) ril + ti it wp wp - ti it wp = (1-ti) rw + ti (1-it) ril wp = [ (1-ti) rw + ti (1-it) ril ] / (1 - ti it) ilp = (1-it) ril + it [ (1-ti) rw + ti ilp ] ilp = (1-it) ril + it (1-ti) rw + it ti ilp ilp - it ti ilp = (1-it) ril + it (1-ti) rw ilp = [ (1-it) ril + it (1-ti) rw ] / ( 1 - it ti)

So.

wp = [ (1-ti) rw + ti (1-it) ril ] / (1 - ti it) ilp = [ (1-it) ril + it (1-ti) rw ] / ( 1 - it ti)

Hmm, some common terms there. Rearranging:

wp = [ ti (1-it) ril + (1-ti) rw ] / (1 - it ti) ilp = [ (1-it) ril + it (1-ti) rw ] / ( 1 - it ti)

Damn! Look at all those multiplications of ril by (1-it)! Recall that we divided by 1-it to get to where we are. Maybe we can just use what we already have? I’ll call them ‘simple win’ and ‘simple inverse lose’

wp = [ ti sil + sw ] / (1 - it ti) ilp = [ sil + it sw ] / ( 1 - it ti)

Weird! Can it really be that simple?

On a 1, I lose; on a 2-3, I win; on a 4-0 I pass the dice to you. .1, .2, .7

On a 1-5, you lose. On a 6, you win. On a 7-0, you pass the dice to me. .5, .1, .4

wp = [ .7 .5 + .2 ] / (1 - .28) = .55 / .72 = .763 ilp = [ .5 + .4 .2 ] / ( 1 - .28) = .58 / .72 = .806

The numbers are different because they are in the form of expressing my chance of winning given who is currently holding the dice.

Now, let’s describe the game from the inverse POV.

On a 1-5, I lose. On a 6, I win. On a 7-0, I pass the dice to yoy. .5, .1, .4

On a 1, You lose; on a 2-3, You win; on a 4-0 you pass the dice to me. .1, .2, .7

wp = [ .4 .1 + .1 ] / (1 - .28) = .14 / .72 = ilp = [ .1 + .7 .1 ] / ( 1 - .28) = .17 / .72 =

And you can see that .14+.58 is .72 and .17+.55 is also .72.

I feel good. That’s how I’ll calculate it.

Ok! I have calculated the base probabilities. Code is here if you dare:

https://github.com/PaulMurrayCbr/Spartacus.git

Next problem is working out how to navigate the tree of possible situations.

A battle situation is a defender attack/defense and a attacker attack/defense. There are 1296 possible situations, which is a pretty manageable number.

Each situation has a probablility of being a *loss* for the defender. The probability is equal to the probability of the loss given each number of possible hits, multiplied by the probability of getting that many hits.

If the number of hits is zero, you havben’t lost. Probability zero (whew!).

If the number of hits is more than your total amount of dice minus two (because you need to retain at least one attack and on defense die), then the loss probability should you get that many hits is 1. You have lost.

If not, then run through each way that you can distribute the hits, and then reverse the attacker/defender situation. Pick the highest loss probability of these sitiations. That’s the move you should make, and your loss probability for that many hits is the 1-p of the reversed situtation.

Now, this sounds staggeringly recursive, but it isn’t because as you calculate these situation probabilities you cache them. So meh. So how do we work out in what order to calculate these situations, such that for every situation we know that the reverse situation has already been done?

Well, one way is to order the situations by total number of dice.

The other way is to write it recursively, use caching as a recursion short-cut, ant let the algorithm do it in whatever sequence it prefers. That’s the easy way and that’s the way I’ll do it.

The remaining problem is: how to exhibit the results? Well, hopefully there will be a general rule eg: “if you have more dice than your opponent, take it off defense, else take it off attack”. Discovering that general rule is the point of the exercise.

Wrong, wrong, wrong.

If the number of hits is zero, then the probability of loss is the 1-p probability of loss for the reverse situation. The problem is that there’s a probability that the reverse situation will also have zero hits, and this creates an infinite recursion if we do it recursively.

Of course, we are crating a Markov Chain. Or network. I’ll have to look into it a trifle more closely.