Giter VIP home page Giter VIP logo

flowfieldai's Introduction

PersonalPortfolio_Q4

When I was little, I used to play a browser-based game a lot called "Pixel Legions". It was a strategy game with very simple graphics, where you would play as a certain colour. You'd have to conquer terrain and strategically eliminate all enemy forces on the map.

I was curious about how the AI pathfinding worked for that game, since it looked like every single pixel was able to find its own path. After research, I found it was done by using so-called "flowfields", which is a way to do pathfinding for a large amount of entities. Instead of calculating a path for every single enemy (which can go into the 1000's, if every "pixel" is an enemy), a path to the target would be calculated from every cell, which could be much cheaper depending on how large the level is.

To increase performance even more, the level could be divided into an octree, depending on the location of enemies so that we don't waste resources on empty cells.

Please refer to the project wiki to read some of the code snippets. Project demonstration

Here, you can see a flowfield without any calculations applied to it and AI agents placed on random cells.

Now you can see the direction of each cell. When an agent collides with a cell, it requests that direction and applies that vector to its own velocity. This means an agent does not need to calculate its own path, but rather just "follows the arrows on the ground".

flowfieldai's People

Contributors

ngmeijer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.