AI (Pathfinding)

This is a discussion on AI (Pathfinding) within the Game Programming forums, part of the General Programming Boards category; Here's the newest update to my game (Skylock: Cyborga). This update has the first bit of AI, in the form ...

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    AI (Pathfinding)

    Here's the newest update to my game (Skylock: Cyborga). This update has the first bit of AI, in the form of pathfinding.

    From the main menu choose the button that reads "Test" to load a simple test level. From the game screen you can cycle through the current trooper by clicking on the "Next" button located in the bottom left of the screen. When you cycle to the next trooper it will determine his allowed destination hex's (highlighted with a light shadow).

    If you click on a valid destination hex it will determine the quickest path and plot it (designated with red stars; pre-alpha place holder art). If you click again on one of his allowed destination hex's it will recalculate his path.

    It is currently a "dumb" AI, in that if there was a person (or in the actual final game, a wall, barrell, etc.) it would just walk through them. Over the next few days I hope to upgrade the pathfinding to a smarter AI to generate walk-around paths when the quickest path is blocked.

    Let me know what you think.

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    if you are interested in shortest path algo's look up dijkstra's algorithm (i cant spell). or look up 'greedy algorithms' in general. they are great for path finding.

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Try GameTutorials.com. They've got some AI demos.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Here's the latest version with a "smarter" AI. Of course, it could still use some tweaking but at least now they walk around other troopers, etc.

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    And the newest version complete with walking. The AI is smarter (though not exactly as 'smart' as I want it). This updated version has the troopers and bots actually walking with their respective movement animations. I do need to tweak the walking anims a little (ie: the speed between the frames, etc.).

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    thats lookin pretty good. you should have some way of identifying which player's move it is. i never know which guy is about to do the walking.

  7. #7
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    So jdinger, which path algorithm did you use?

  8. #8
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    The algorithm is one that I worked out over the last week or so. I don't know that it's patterned after any specific algorithm. I've never studied pathfinding AI.

    Basically I start with 2 variables: the Origin point and the Destination point. Then I iterate until the Origin point is equal to the Destination point taking these steps to get there:

    1-For each iteration determine where the destination point is from the current origin point (southwest, west, northwest, northeast, east, southeast).
    2-Based on the direction given from the first function I populate an 6 element integer array with the preferred order of directions to make the move.
    (ie: if I need to move east then the preferred order to try would be:
    0-east
    1-northeast
    2-southeast
    3-northwest
    4-southwest
    5-west
    3-Next loop through the preferred order and test if the hex that the current direction would move you to is clear, if so then move to it and break out of the loop.
    4-Update the origin point to be the point you just moved to and test to see if the new origin point equals the destination point. If so then you're done moving. If not then start back at step 1.

    thats lookin pretty good. you should have some way of identifying which player's move it is. i never know which guy is about to do the walking.
    That's in the works. This is very early in the AI. I was thinking of going with a highlight to the hex that the current trooper stands on. Like a mellow flashing red or green or something.
    Last edited by jdinger; 04-16-2003 at 10:23 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. chess ai contest
    By Raven Arkadon in forum Contests Board
    Replies: 7
    Last Post: 07-09-2005, 06:38 AM
  2. pathfinding ai problems
    By ichijoji in forum C++ Programming
    Replies: 0
    Last Post: 08-18-2003, 06:14 PM
  3. Pathfinding AI? (Not the A* Algorithim)
    By harryP in forum C++ Programming
    Replies: 22
    Last Post: 08-01-2003, 02:32 PM
  4. Game Design Topic #1 - AI Behavior
    By TechWins in forum Game Programming
    Replies: 13
    Last Post: 10-11-2002, 10:35 AM
  5. AI (pathfinding) tutorial
    By dirkduck in forum Game Programming
    Replies: 3
    Last Post: 02-09-2002, 11:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21