Page 1 of 2 12 LastLast
Results 1 to 10 of 34

Thread: New ideas for AI in games?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    AI has been previously a very popular topic and in certain occasions there was even a degree that you can obtain in institutions. However, it didn't live up to the expectations and later was renamed to "Intelligent Systems" and now is an area of science that has limited applications, being more like a meta-science itself.

    In games, dealing with AI usually ends up with using one of Seach Algorithms, probability sets, Markov chains and so on.

    In my opinion, to achieve a good AI in games you need to translate expert's player knowledge into execution scheme that accurately reproduces the expert's decision making process. Of course, you can take advantage of processing power and apply search algorithms and exact physics calculations whenever possible to beat the player, something that is difficult to achieve in real-time for a human mind.

  2. #2
    I'm building the game so that there's no distinction between Human and AI controlled player. TPlayer class might have MoveTo() command so that, whichever executes it, will automatically follow the set rules of the game. For AI you can map all options it can do at the time, and then select 1 of them. Might be combination of weighted and random choice.

    In a board game you can try all those available moves (which is usually quite few), and the moves that would follow that. A scenario that leads to defeat would naturally set the weight value low, and a victory condition respectively high. In many games you can also value the scenarios "progressive weight". For example in a game where your goal is to move all pieces to opposite side of the board, then naturally scenario where sum of distances of all your pieces on board being smallest, is most valuable. Or scenario where enemy has less pieces than you may be more valuable than normal neutral state.

  3. #3
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Not in games I haven't. But in the last week I have been looking at artificial neural networks, which are indeed very interesting. The prospect of being able to implement one on todays hardware and multi-threaded concepts offers some interesting evolution in that field. However, due to how abstract it is, I've been toying with the idea of a multi-agent system which in my opinion is the better option. Something like having the game thread along with an independant AI thread that simply has a pointer to the TPlayer^.Input() function is interesting for multi-core systems.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  4. #4
    Well, I do have AI in my Boulder Dash game The Probe - the enemies have decision making as to when to turn, or go forward.

  5. #5
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    I've created and am in the process of improving generic AI components in JenJin. It currently covers techniques related to movement however I've done little on decision related AI such as state machines but have researched such techniques extensively. Currently I have various steering implementations, path finding and following, region biased constraints as well as extensive tie ins with various 'region' types in the engine (Terrain (spherical + flat), portal/indoor and voxel (think minecraft). As the engine is designed along side a WYSIWYG content tool, anything that can be visually configurable is so.

    When I grace the AI portions again (I'm currently finishing off the GL2.x support, was only ES2/GL3/4 previously) I'll finish off the event hooks and it should then be possible to code state machines with scripts. Events can be triggered from lots of different things :

    A Spatial entity entering the confines of a region
    Coming within a given radius of a fixed point or another entity
    User events specified in scripts
    etc

    You can also trigger timer style 'events' for paradigms that don't fit well with classic events IE you may want the bias for an entity to move away from another to scale with distance to that entity.

    And obviously anything that's needed that I don't add can just be hard-coded/scripted in any game client code.

    --

    I will eventually look at options for using neural-networks as I believe it's something that a lot of people would like to experiment with however, they are not for the faint hearted and how they are used is not as direct as people would imagine. They do little more than bias state machine outcomes in most games and very few use them for direct control of an entities actions.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  6. #6
    PGDCE Developer de_jean_7777's Avatar
    Join Date
    Nov 2006
    Location
    Bosnia and Herzegovina (Herzegovina)
    Posts
    287
    In my current game project the AI is simple. All entities follow a set of actions. When an action is complete it goes on to the next action in the list. Some actions have simple decision making, which can result in jumping to another action (a random chance or so) The action state is stored individually for each entity. Actions can be chained, so they are performed simultaneously (e.g. following a path, and firing projectiles at the same time, while making a decision to change paths). With time I expand the number of action types, for now it's: path following, waiting at a point, teleporting to a point, and firing projectiles, timer to go on to next action, and random chance to go on to next action (a sort of random behavior at certain points). This is sort of simple scripting with limited number of actions, and works well enough for a simple top-down scrolling space shooter. I also intend to make some actions situation aware, like projectile firing, so that the enemies don't fire too many projectiles and swamp the player. The actions are configurable to a certain extent. The most tiring part is coding all the action lists and configuring them, so I made some helper functions and predefined actions to help.

  7. #7
    Quote Originally Posted by de_jean_7777 View Post
    In my current game project the AI is simple. All entities follow a set of actions. When an action is complete it goes on to the next action in the list. Some actions have simple decision making, which can result in jumping to another action (a random chance or so) The action state is stored individually for each entity. Actions can be chained, so they are performed simultaneously (e.g. following a path, and firing projectiles at the same time, while making a decision to change paths). With time I expand the number of action types, for now it's: path following, waiting at a point, teleporting to a point, and firing projectiles, timer to go on to next action, and random chance to go on to next action (a sort of random behavior at certain points). This is sort of simple scripting with limited number of actions, and works well enough for a simple top-down scrolling space shooter. I also intend to make some actions situation aware, like projectile firing, so that the enemies don't fire too many projectiles and swamp the player. The actions are configurable to a certain extent. The most tiring part is coding all the action lists and configuring them, so I made some helper functions and predefined actions to help.
    Sounds very cool! I don't suppose you could share some code snip-its or something?

  8. #8
    PGDCE Developer de_jean_7777's Avatar
    Join Date
    Nov 2006
    Location
    Bosnia and Herzegovina (Herzegovina)
    Posts
    287
    This is the action type.

    Code:
       TEntityAction = record
          {action and it's properties}
          action, effect, properties: longword;
          {action is complete}
          done: boolean;
    
          {direction}
          vDir: TVector3f;
    
          {distance traveled, speed}
          distance, speed: single;
          {minimum duration, max duration, start wait time minimum, start wait time maximum}
          minTime, maxTime, startWaitTimeMin, startWaitTimeMax: single;
    
          along: PEntityAction; {action to be performed along with this one}
          next: PEntityAction; {action to be performed after this one}
    
          {an associated path}
          path: PPath;
    
          {an associated projectile group}
          projectileGroup: PProjectileGroup;
       end;
    This holds action data per each entity and action.


    Code:
       TEntityActionData = record
          initialized, done: boolean;
    
          distancemoved: single;
          lineardir: longint;
          actionTime, startWaitTime: single;
          timer: TTimerData;
          waitedAtStart: boolean;
    
          vPos: TVector3f;
       end;
    Here is a simple move action.

    Code:
    procedure actionMoveDistance(var ent: TEntity; var a: TEntityAction; var d: TEntityActionData);
    var
       vmMov: TVector3f;
       dist: Single;
    begin
       if(d.distancemoved < a.distance) then begin
          vmMov := a.vDir * (a.speed * oxMainTimeFlow);
          dist := vmDistance(vmvZero3f, vmMov);
    
          d.distancemoved := d.distancemoved + dist;
    
          ent.vPos := ent.vPos + vmMov;
          if(a.distance < d.distancemoved) then begin
             ent.vPos := ent.vPos - (a.vDir * (d.distancemoved - a.distance));
             d.distancemoved := a.distance;
    
             nextAction(ent);
          end;
       end;
    end;
    There is a lot more, but I think if I shown how everything works this would be one really huge post. I still need to expand this and improve the already existing code.

  9. #9
    Quote Originally Posted by Lifepower View Post
    AI has been previously a very popular topic and in certain occasions there was even a degree that you can obtain in institutions. However, it didn't live up to the expectations and later was renamed to "Intelligent Systems" and now is an area of science that has limited applications, being more like a meta-science itself.
    I think the problem that the concept over-hypes itself already in the name. But I consider "AI" and "game AI" to be very different.

    I wrote two whole chapters about game AI in "Tricks of the Mac Game Programming Gurus" in 1995, probably one of the longer texts about the subject at the time. But I didn't call it "game AI" because "AI" was such a hyped concept, I called it "behavior" and "environment". But it was about the usual stuff, basic behaviors (hunter, evader, patrol), path finding, FSMs, game state analysis...

    Today I am teaching graphics and game programming, I have similar material in my textbooks, but now I call it "game AI" and I actually consider the concept a nice contrast to AI. Game AI is well known to be limited, so we don't expect wonders, which is a good thing.

    My favorite game AI techniques are flocking and influence maps. They can really produce interesting and convincing behaviors. But do spice it up with some randomness.

  10. #10
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    I'd love to have a PGD Challenge that is all about AI.

    The thing I love about the whole topic, in some ways Ingemar is right (it's a bit overhyped), you can hack at it and as long as you make it look like it's doing something intelligent, or behaving intelligent, then you have a pretty good game AI. It's something that can be easy to get into, but can be hard to master.

    I think such a challenge would have your players go against and try to "beat" it OR create non-player AI character/bots, etc that have to work with the player in some way.

    Designing the challenge rules might be as interesting as designing the games that go into the challenge it's self.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •