Jump to content
  • entries
    334
  • comments
    900
  • views
    258,394

Leprechaun AI grumbling


EricBall

411 views

I've attached my current WIP, but no updates to the LLE since this version has obvious issues even with my built-in level.

 

I've added in the "walking on heads" feature. (It actually wasn't as hard as I thought it might have been as it required changes to only one bit of code.) When I first added it the leprechauns had an amusing habit of walking across the screen on top of one another. The look-ahead code took care of that but causes other quirkyness & problems. Hmm... just realized I need to check to make sure the leprechauns can't walk on the player's head. Yep, used BNE instead of BPL, so that should work.

 

Anyway, one important note: unlike Lode Runner, the leprechauns don't stop moving when they fall into a hole. Thus, if the hole is two bricks wide they will wander back & forth. This means two brick wide holes will probably not catch two leprechauns since the second walks over the first.

 

But the big change in this version is drop-off detection. In the attached WIP, the leprechauns simply reverse direction when they see a drop off and the player is higher than them. (If the player is on the same row or below, then they happily walk off the edge.) The problem with this method is it's very easy for the leprechauns to wander back and forth, never getting anywhere. A somewhat better solution was to treat the drop-off like a wall and fall into that routine (which rotates their virtual joystick). Then there was a 50/50 chance the leprechaun would walk off the edge anyway. But there was still a chance they would get stuck.

 

I think I'm going to have to re-implement hunt/chase logic or go back to no drop-off detection.

 

As I'm sure other coders are aware, good AI is tough to get right. I try to think through how the logic will play out, but I frequently don't anticipate something. (Fortunately, my bugs tend to be blatent rather than subtle.) Then I have to try to reproduce the quirk and trap it in the debugger, step through the code, and try to figure out what's going on.

 

I think part of the problem is the AI is based on what the leprechaun did last grid position, not so much the grid they are on right now. Most of the time it's not a big deal, but sometimes the leprechauns don't behave quite the way I expected.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...