Postcards from Midnight

Dawn approached stealthily, running swift fingers of light over the Lands of Midnight. Far to the east, it touched the grim Keep of Utarg with a brief golden haze: the Targ sentries yawned and looked around only to see if the next watch approached to relieve them. The dawn moved on. trembling over the Downs of Athoril, cloaking them in scarlet and saffron. The hills which had seemed hunched herds of vast menacing creatures in the absence of light, seemed now to draw apart and unfold.

Thought I’d post a quick update on the progress, or lack of, for Lords of Midnight on iOS as I am aware that I have not posted anything for a while.

Unfortunately, the truth is that developed has comes come crashing back to a slow trickle. This is due to me moving house at the end of June. I am somewhat surprised at how much the move has disrupted my development work.
Obviously, I had a few days prior to the move as I dismantled my study and then concentrated on all things moving. Prior to that I had had 7 straight weeks of shouting at people, chasing down people, to make sure the move happened, so by the evening I was more than happy to throw myself into development.
After the move it took a week or so to hey my study up and running, and generally be in a more organised situation round the house in general. But the momentum had been lost. Since that time I have not really spent anytime near the computer, where I have been able to develop.

It has really surprised me, and a little disappointed me, at the level of disruption that has occurred, but all I can do now is try and get myself back in the saddle, so to speak.

Testing has been good, and the current version is relatively stable. It is also now working on all iOS devices. The current changes that I am working on are amendments to the AI with regard the Ice Crown Quest. And then after that I will be working on tweaks for the Xajorkith Defence.

Hopefully I can get my self kick started and fully operational soon!

We fought side-by-side on the Plains of Blood in the last war against Doomdark

Since the start of this project there has been an interesting issue with Doomdark’s armies reaching Blood too soon. I’d noticed it while playing, and the testers have brought it up more than a few times. I have checked the code, doubled checked the code, triple checked the code, and the fact is, there is absolutely no reason why Doomdark’s armies cannot reach Blood the first night.

There are two regiments that start the game at the keeps at the Gap of Valethor, lets call them regiments 100 and 101. These are both riders set to wander.

A wandering regiment has 6 turns in the night. Firstly it checks up to 3 locations away, if there is anything interesting between it and 3 locations, it will make 1 turn step toward it. If not, it will randomly pick a direction, and as long as it isn’t frozen wastes, make 1 turn step in that direction.

Movement costs depending on terrain and direction. eg: Cost is *2 turns for a warrior, and a mountain costs 4 turns. So a warrior walking out of a mountain will take 8 turns. You take the terrain cost from the terrain you are leaving not the one you are stepping into. So a warrior walking from plains into mountains will take 2 turns, leaving 4 turns. The next move will cost 8 turns, but the fact they only have 4 turns left, is not important, they take the move, but then have -ve turns left, and thus their processing ends.

The process will be repeated until the 6 turns have been exhausted.

Now regiment 100 starts at the keep directly north of Blood. If on its first move, it decides to move south, then that places it within 3 locations of Blood, which means the next turn will focus it on the stronghold, and therefore it will guaranty hitting Blood in the first night. A movement of southeast, or southwest, will reduce the chance that the regiment will hit Blood in the first night, but it is still a possibility.

So, the original AI for Lords of Midnight, makes it possible that Blood could be hit on the first night. But it hardly ever happened. On my version, it happened almost every time. And every time makes it impossible for you to recruit Lord Blood, let alone try and mount the Blood Defence.

I figured that the random number generator mustn’t be functioning, so tested that, double tested it, and then tested it again. It seemed to be giving a reasonable stream of numbers. Didn’t change the fact that the results I was getting were not desirable. So I considered placing a delay command on those regiments, just to slow them down.

Last night I was talking through the issue again with Mike and we decided to throw out the random routine, and use another one instead. He gave me the C code version of the one used in Midwinter. The results were the same! But then I noticed something. The random number functions generate a number between 0.0 and 1.0 And thus picking number between say 0 and 8 just involves multiplying 8 by the random number, and there was the problem. This number needed to be converted to an integer, a whole number, and it was being done with a cast to int. And this truncates, which means the number is ALWAYS rounded down. In theory it just means that in this instance, 8 would almost never be picked. And in the case of these wandering regiments, that just means losing Northwest. However, changing that one line of code in the random number generator, has put those wandering regiments, back on the right track.

Blood can still be hit, but it is hit much less often than before.