Jump to content
IGNORED

BASIC / Assembly code for enemy AI


Recommended Posts

I am looking for BASIC and/or assembly code examples for enemy AI. Any good resources or examples you know of? Are their particular AI code examples you like to use in your games? I have searched here an AA and haven't found much. Google is useless because of all the deep learning AI for playing Atari games pages that come up. I am particularly interested in AI for an enemy moving toward and attacking a player. Many thanks!!!

Link to comment
Share on other sites

Such things aren't machine specific.  In the modern day it's more sophisticated but still relevant to older systems.

Games like Wolf3D tended to use set paths combined with a pathfinding methodology if they spotted the player.

 

In it's simplest form a pathfinding algorithm just heads for the player but in anything but an obstacle free open world it's a flawed concept because obstacles can halt the enemy in his tracks.

Just throwing something in like random deviation can be sufficient to turn a simple faulty algorithm into one that looks and acts more intelligent.

  • Like 1
Link to comment
Share on other sites

Really depends on the game type you are doing. Is it real-time or turn-based? How many enemies are active in the same time?

In action games usually the only viable option for machines with limited CPU is a variant of State Machine or Decision Tree, sometimes with some simple scripting language, sometimes "hardcoded". Basic info about Wolfenstein3D AI is in http://fabiensanglard.net/gebbwolf3d_v2.1.pdf

 

  • Like 1
Link to comment
Share on other sites

I agree with Rybags, obstacles add great complexity.  One of my current projects is to add AI to 2600 Combat.  Biplanes, Jets and tanks with open playfields were easy the tank levels with mazes were challenging to create and I still don't have it where I want it. 

 

For War Room, the AI was pretty simple. 

A few parameters in the game:

- No obstacles but there is a green slime that starts in the middle and grows and the bullets are not unlimited

- Bullets are not unlimited and bullet packs appear randomly

- Game is broken into rounds where you have to outlast your opponent (IIRC, everyone gets ten hits.)

 

This is from memory so it may not be perfectly accurate but AI Priorities change based on game state:

Grabbing bullets are generally the first priority and this changes things up quite a bit and works to randomize things a bit.

If AI has no bullets, it flees from the opponent

If the opponent has no bullets, it gets more aggressive in attacking.

If the AI has a lot of life left and the opponent is down to almost no life left, the AI gets more aggressive in attacking.

 

Shooting:

AI only shoots if it is lined up with the opponent Horizontally, Vertically or Diagonally.  This shot is always based on where the opponent is and doesn't anticipate where the opponent will be.

 

One thing that I have never figured out is that Player 2 is much better than Player 1 even though I think the logic is exactly the same.

 

Search for "AI logic" in the assembly code...  It isn't commented very well.

 

 

 

  • Like 2
Link to comment
Share on other sites

23 hours ago, Schlortt said:

I agree with Rybags, obstacles add great complexity.  One of my current projects is to add AI to 2600 Combat.  Biplanes, Jets and tanks with open playfields were easy the tank levels with mazes were challenging to create and I still don't have it where I want it. 

 

For War Room, the AI was pretty simple. 

A few parameters in the game:

- No obstacles but there is a green slime that starts in the middle and grows and the bullets are not unlimited

- Bullets are not unlimited and bullet packs appear randomly

- Game is broken into rounds where you have to outlast your opponent (IIRC, everyone gets ten hits.)

 

This is from memory so it may not be perfectly accurate but AI Priorities change based on game state:

Grabbing bullets are generally the first priority and this changes things up quite a bit and works to randomize things a bit.

If AI has no bullets, it flees from the opponent

If the opponent has no bullets, it gets more aggressive in attacking.

If the AI has a lot of life left and the opponent is down to almost no life left, the AI gets more aggressive in attacking.

 

Shooting:

AI only shoots if it is lined up with the opponent Horizontally, Vertically or Diagonally.  This shot is always based on where the opponent is and doesn't anticipate where the opponent will be.

 

One thing that I have never figured out is that Player 2 is much better than Player 1 even though I think the logic is exactly the same.

 

Search for "AI logic" in the assembly code...  It isn't commented very well.

 

 

 

Awesome! Thanks for posting :)

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...