caejones (caejones) wrote,

The Undying Robot Shogun

The extremely primitive AI in one of my games occasionally does something interesting, which I'm tempted to attribute to randomness more than design.

This is sort of a military strategy type game very loosely based on the Japanese Warring States era; today, a leader that I needed deposed left his castle (I don't think he's done that before) and fled across multiple islands. By the time I found him, all but a few civilians in the region had either starved to death or been killed in the manhunt, and he was living peacefully alone on that island with a house and a stable garden.
At no point in the code did I make any recommendation that would have pointed toward the strategy "quietly sneak out the back, get far away and hide where there is food", but there is some randomness in the choice of path a unit might take when not on an urgent mission, so presumably the random number generator led him out the back, and hunger led him the rest of the way. (There was also a snowstorm while I was searching, which probably killed off a lot of crops and helped the AI pick more distant food sources). I was pretty much resigned to him having gone off and starved or something before I got to him, until I got to a boat and started searching the whole district.

The most troubling part of the AI in this game is, surprisingly, the chain of command. In theory, if you give orders to a particular rank, they will pass the orders to their underlings, or to their fellows at the level of "regular ol' Samurai".
I decided I needed to rewrite that part entirely, when I came across a large group of Samurai screaming about recruitment, and eventually followed their trail to find that they were in a shouting match with the other half of the army, which was really hungry and shouting that they should search for food. While hilarious, this isn't the sort of thing that should be happening...
... And after I changed it, people started starving more often, and sometimes would just ignore my orders for no apparent reason. So basically trying to fix it caused both sides in that AI debate to lose. D'oh!

I'm still baffled by how the mid boss successfully implimented such a clever strategy. Well, ok, I suppose the cunning is a bit weaker considering that I eventually found him and beat a cutscene out of him, killing many of his followers along the way... but on the other hand, he was somehow alive afterward (which hints to me that there might be a bug, since that scene should only happen when he dies... did I do something to keep him alive perpetually and forget about it?). He stopped fighting after I beat him, though; maybe he joined me? Shouldn't have been possible, but is pretty cool and I kinda wish I's investigated further before running off and getting stabbed when I had a laggy time trying to line myself up with two samurai that were jointly killing everyone I was trying to recruit.
Tags: ai, games, rts
  • Post a new comment


    default userpic