Friday, 11 September 2009

Improving the AI

I've noticed the following situation quite a lot:

...where the player can see the monster but the monster cannot see the player (and thus is still asleep) This is because the player FoV is calculated using Recursive Shadowcasting, and lacking a working noise model, monsters initially use a simple implementation of Bresenham's line algorithm to calculate if they are aware of the player or not.

In an ideal world, the monsters would either use a noise system or recursive shadowcasting of their own to find the player, but in the meantime, I need to think of a better way to make monsters active. I'm proposing that, for now, if a monster is in the FoV of the player, but cannot directly see the player, then that is equivalent to having direct line of sight (via Bresenham) to the player, and the monster will awaken and then move in a random direction to try and achieve direct line of sight.

And to answer some questions I've had about screen resolution, here is the main window maximised on my laptop running at 1366 x 768 and with the main display minimised, giving a tile display of 112 x 22 using Bitstream Vera Sans Mono, 11 pt. text (click to zoom in to see at full resolution):

The mininum (default) size is 900 x 730.


Mario Donick said...

Given that we are facing each other:

Shouldn't a monster be able to see me if I can see it? Then, one application of recursive shadowcasting should be enough for both.

Adding the ability for reacting on noise is an additional layer (and should be accesable by the player, too, even when not seeing a monster).

Dave said...

Yeah, I think I'll go for that. If the monster becomes visible, then, assuming the player makes the stealth roll, force it to see the player (and act appropriately)