• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
  • entries
    206
  • comments
    217
  • views
    222236

Pathfinding Part 2

Sign in to follow this  
Followers 0
gdunbar

1230 views

See Part 1 for background: https://www.gamedev.net/blog/717/entry-2255124-pathfinding-part-1/

OK, so I had reached the point of frustration with my old pathfinding... what to do about it? It had become obvious to me that my pathfinding would have to do some searching to find a path to the target, rather than just walking towards the target semi-blindly.

The classic pathfinding algorithm is called A*. Simplified: A* does a search of the pathfinding space, optimizing the search such that it looks first at paths that go towards the target. It is relatively efficient and quite effective. I won't try to give a full description of A* as that has already been done, many places, very well. Here's one example from the comments: http://www.policyalmanac.org/games/aStarTutorial.htm

However, I had some concerns about A*:

  1. While efficient as far as search algorithms go, it is still a search algorithm. Running it every "tick" (generally 60 times per second) for every actor in a SENG game would have some cost.
  2. A* works very well for one entity searching in a static environment. However, as few as 2 entities can get stuck doing A*, constantly running into each other without ever finding the target. This is solveable, but I'd already solved these issues with my heuristic.
  3. Most importantly: A* works on a discrete space, like a chess-board. SENG has a continuous movement space. The Internet suggests some ways to deal with this, but it isn't a clear cut-and-dried algorithm. Mostly, "first, divide your space into discrete chunks".


A quick note: SENG uses a tile system for basic terrain (2.5 feet x 2.5 feet tiles). However, "objects" (like tables) and actors can have arbitrary position. Movement of actors is in any direction. Disallowing movement except along tiles (in order to implement A*) would be a significant step backwards for the game engine.

I decided to do a combination of A* and my heuristic:

  1. If we are close to the target, or far from the target, just use the "move towards the target" heuristic.
  2. Run A*, just using the tiles of the area (ignoring other actors).

    • If A* fails (no path to the target, or path too long), just move towards the target.

  • Pick the point on the A* path 12.5 feet from the moving actor. Call this the waypoint.

    • Use the heuristic movement to move towards the waypoint until we are halfway there, or if we aren't making progress towards the waypoint.

    • Go back to (1).


      OK, here's an example. In this picture, the actor wants to follow the green path. A* calculates the blue path as the optimal path to the target. (Note that this path would actually be a jagged line due to the tile based nature of the algorithm, but I didn't feel like drawing that). The red path represents the waypoint that the actor has selected to move towards.

      gallery_98001_495_65749.jpg

      In this picture, the actor has gotten halfway to the waypoint, so he recalculates:

      gallery_98001_495_35436.jpg

      And, in this last picture, the actor got halfway to the next waypoint. Note that the waypoint is now starting to move around the corner; however, the heuristic movement is capable of negotiating simple obstacles and will "bounce" around the corner of lava in the way.

      gallery_98001_495_77701.jpg

      I am very pleased; this new pathfinding algorithm combines many of the good features of A* and the heuristic:

      1. Very efficient. We generally only perform a search of the area tiles every few seconds (per actor). There is no noticeable performance impact of this pathfinding algorithm vs the heuristic.
      2. Works well with moving targets and moving obstacles. The heuristic algorithm, with its simple minded directed movement, deals quite well with this. A* is restricted to the long-range planning where these problems aren't a factor.
      3. Movement is continuous, so the actor moves directly towards the target with no zig-zagging. There is actually just a little visible zig-zagging due to waypoints always being the center of a tile, but it is barely noticeable.
      4. Properly moves around indentations, long walls and other complex formations, due to use of A*.


      When I next release a beta of 10 Fantasy Fights, you can experience for yourself!

  • 2
    Sign in to follow this  
    Followers 0


    2 Comments


    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!


    Register a new account

    Sign in

    Already have an account? Sign in here.


    Sign In Now