Author Topic: AI Theory  (Read 2997 times)

0 Members and 1 Guest are viewing this topic.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
AI Theory
« on: July 25, 2011, 06:51:30 pm »
For a game I've been planning on making (platformer SHMUP), I would need a somewhat-complex AI.
What it would do in the end would be follow/home in on the player in a physics-based enviroment--jumping over holes and such.
Also I plan on making it shoot, but I haven't thought about that so much yet.

This obviously isn't code, but thoughts.  Final thing will probably be in axe, but the ideas are pretty much general and could be applied to axe, asm, maybe even basic.
Anyway, what I have so far:
Spoiler For kind of big:
If player is to the left of AI
   If area to left is open
If there is floor to the left
      Move left
      Else
         If there is floor two or three tiles to the left and there is no wall two or three tiles to the left
         Move left and jump
         Else
         Check above?  Maybe just jump and keep checking
         End
      End
   Else
      If area to the right is open
         If there is floor to the right
               Move right
               Else
                  If there is floor two or three tiles to the left and there is no wall two or three tiles to the left
                  Move left and jump
                  Else
                  Check above?  Maybe just jump and keep checking
                  End
               End
      Else
      Jump, set something to check if area to left is open then right.  If AI lands without moving left or right, then the AI must be in a pit-—idk what to do at this point
       End
   End
End

.next part is pretty much same as previous--just switch "left" with "right" and vice-versa =P
If player is to the right of AI
   If area to right is open
If there is floor to the right
      Move right
      Else
         If there is floor two or three tiles to the right and there is no wall two or three tiles to the right
         Move right and jump
         Else
         Check above?  Maybe just jump and keep checking
         End
      End
   Else
      If area to the left is open
         If there is floor to the left
               Move left
               Else
                  If there is floor two or three tiles to the right and there is no wall two or three tiles to the right
                  Move right and jump
                  Else
                  Check above?  Maybe just jump and keep checking
                  End
               End
      Else
      Jump, set something to check if area to right is open then left.  If AI lands without moving right or left, then the AI must be in a pit-—idk what to do at this point
       End
   End
End
It's not exactly organized, and I don't have it check for whether player is above or below (ie if it were below it would look for a hole that's not a pit), or if there's a ledge it can jump over a hole onto, but one gets the general idea.


I was wondering if this has been experimented with before in calc games, how practical it would be, and if there would be a better way to organize this stuff.  Also if there's any ideas I've overlooked..

TIA :)
« Last Edit: October 26, 2011, 10:42:51 am by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Ashbad

  • Guest
Re: AI Theory
« Reply #1 on: July 25, 2011, 09:47:41 pm »
Well, it's a good start, but it's pretty simple :P.  All you're really doing is checking for boundaries and where the player is, without any concern for thing like complex obstacles, the player being out of sight of the enemy, the enemy's conditions (if other enemies are being slaughtered or the enemy's health gets critical and there is a chance for escape), the enemy should hide, run away, hold its ground rather than be aggressive, etc.), perhaps thinking about alternative ways to go, etc.  This is a good basic framework for all AI in games that try to propose a challenge, as code that will make the player think the AI is "smart" rather than just a following system, will impress the player more, and possibly provide a much bigger challenge.

Edit: also the indenting in your pseudocode seems out of whack as well.
« Last Edit: July 25, 2011, 09:49:37 pm by Ashbad »

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: AI Theory
« Reply #2 on: July 25, 2011, 10:42:55 pm »
As I said, I haven't put much time into it :P
I don't really plan on anything too complex atm, first things first (ie the engine)
I can't get too complex with this, b/c I have only ~6mhz to play around with.

I might take the health into account, tho...
« Last Edit: July 25, 2011, 10:55:23 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue