Jump to content
  • entries
    335
  • comments
    900
  • views
    258,589

Hunt and chase returns


EricBall

413 views

Hopefully this will be the last update to the enemy AI routines. I would appreciate if the various level creators can update their levels to the latest code (using the Leprechaun Level Editor, v20061101) and see how well things work. For the attached WIP the leprechauns eventually find the player at the starting position, something I was having great difficulty accomplishing with drop off detection.

 

The Leprechaun (and player) color indicates the direction their joystick is pointing:

gold	UP
orange	DOWN
pink	LEFT
blue	RIGHT
purple	UP & LEFT
violet	DOWN & LEFT
lt blue	UP & RIGHT
cyan	DOWN & RIGHT

A lighter color means the leprechaun is in hunt mode, versus chase mode. The AI is mostly based on the last action and hunt versus chase mode. See do_enemy in LEPBANK1.ASM for the gory details.

3 Comments


Recommended Comments

First thoughts: Enemies apparently won't drop off of ropes unless you are directly underneath them. This means enemies can get stuck on ropes that have walls on either end (i.e., that you can only exit from by dropping).

 

They just go back and forth forever.

 

Second thought: When an enemy is in chase mode and hits a wall, currently it moves in a random direction, changing state to hunt, correct? A suggestion: if an enemy hits a wall and is also on a ladder, move him up/down towards the player (if the player is above/below) and leave him in chase mode. Same when moving up/down on a ladder.

 

Take this situation, for example:

				P
	  =-----------=
 E	   =|		 |=
-----------|		 |-----------

- are floors, | are walls, = are ladders.

P is the player

E is the enemy, chasing P to the right. When he hits the wall (and ladder), 80% of the time he just turns around.

 

The behavior appears to be the same when reaching the top/bottom of a ladder.

 

Third thought: this is a wild, completely out-of-the blue idea, but have you considered, or tried, implementing a Pac-Man style logic? Have the enemies chase the player on a timer; when the timer elapses, have them head towards a corner for a short period of time before starting the chase timer again. Some variety of this might be very nice, especially if the behavior was slightly different for the different enemies (like in Pac-Man): different enemies might have different length timers, they might chase directly towards the player or towards a spot ahead/behind the player, etc.

Link to comment

First thoughts: Enemies apparently won't drop off of ropes unless you are directly underneath them. This means enemies can get stuck on ropes that have walls on either end (i.e., that you can only exit from by dropping). They just go back and forth forever.

Hmm... interesting point; I hadn't thought of that. I can certainly add logic for the enemy to try dropping off a rope when they are in hunt mode and they reach the end of the rope. (Though there still could be a problem if the ends of the rope have rock/dirt under them.)

 

Second thought: When an enemy is in chase mode and hits a wall, currently it moves in a random direction, changing state to hunt, correct? A suggestion: if an enemy hits a wall and is also on a ladder, move him up/down towards the player (if the player is above/below) and leave him in chase mode. Same when moving up/down on a ladder.

Yeah, I have a sneaking suspicion that the enemies are kicking into hunt mode too easily. The enemies are still dumb in your switchback level 'cause they kick into hunt mode which takes them away from the player. On a related note, falling kicks the enemy out of hunt mode which can cause other issues.

 

Third thought: this is a wild, completely out-of-the blue idea, but have you considered, or tried, implementing a Pac-Man style logic? Have the enemies chase the player on a timer; when the timer elapses, have them head towards a corner for a short period of time before starting the chase timer again. Some variety of this might be very nice, especially if the behavior was slightly different for the different enemies (like in Pac-Man): different enemies might have different length timers, they might chase directly towards the player or towards a spot ahead/behind the player, etc.

Haven't considered (or tried) anything like that. I don't know how well it will work, though there are four corners and four enemies....

Link to comment

Second thought: When an enemy is in chase mode and hits a wall, currently it moves in a random direction, changing state to hunt, correct? A suggestion: if an enemy hits a wall and is also on a ladder, move him up/down towards the player (if the player is above/below) and leave him in chase mode. Same when moving up/down on a ladder.

Yeah, I have a sneaking suspicion that the enemies are kicking into hunt mode too easily. The enemies are still dumb in your switchback level 'cause they kick into hunt mode which takes them away from the player. On a related note, falling kicks the enemy out of hunt mode which can cause other issues.

I did notice, though, that the switchback level works *much* better now than it did before.

 

Another note: I have seen some really weird behavior, similar to what I noted above, like this:

	P
------------



------------------=   E
			 |--------

Sometimes in this situation the enemy will do this forever:

1. move L to the ladder

2. move U to the top of the ladder, then

3. move R, fall down one square, then

4. goto 1.

 

It's as if, rather than moving randomly when reaching the top of the level, the enemy perversely moves purposely away from the player. This seems to happen more often (only?) when two enemies are involved; maybe the routine to keep them from overlapping is driving this somehow, but it sure is strange looking to see one or more enemies moving in this tight little circle forever.

 

Third thought: this is a wild, completely out-of-the blue idea, but have you considered, or tried, implementing a Pac-Man style logic? Have the enemies chase the player on a timer; when the timer elapses, have them head towards a corner for a short period of time before starting the chase timer again. Some variety of this might be very nice, especially if the behavior was slightly different for the different enemies (like in Pac-Man): different enemies might have different length timers, they might chase directly towards the player or towards a spot ahead/behind the player, etc.

Haven't considered (or tried) anything like that. I don't know how well it will work, though there are four corners and four enemies....

Off the top of my head, the benefits:

You don't have to worry too much about enemies getting stuck, since they will switch to "head to corners" mode at some point.

You don't have to worry about the enemies making transitions from hunt to chase or vice versa at the wrong times, which seems to be a vexing issue. :lol:

 

I really like the hunt/chase idea and, ultimately, I think if/when you can get it working right it will be better than a Pac-Man-style AI - but it might be interesting to see what the ghosts can do. :D

 

EDIT: My final thoughts, for now: This AI is much better than the old AI - except for a few glitches (mentioned above) it is very good. :ponder:

Link to comment
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...