Code Monkey home page Code Monkey logo

fast-traversability-checking's Introduction

Fast Traversability Checking

This code checks to see whether a tile grid of solid/empty squares would still be traversable after changing extra squares to solid. It is optimized for making several queries of this sort onto the same setup.

For example, you can use it in a tile editor to highlight all locations it is ok to place an entity at, as the included demo demonstrates.

A demo and explanation of how it works can be found at:

http://www.boristhebrave.com/2017/07/08/fast-traversal-queries-of-procedurally-generated-rooms

Usage

Construct a WouldBlockTraversalCalculator with a 2d boolean array where true means a tile is walkable (i.e. empty) and false means it is not walkable (i.e. filled).

Then, for each possible placement, call wouldBlockTraversal with the list of exits, i.e. points that must remain traversable from each other, and a 2d boolean array solid where true means that the tile will be marked not walkable.

The function returns true if it is not possible to get between all the exits after placing the solid in the indicated location.

For best performance, solid should be much smaller than walkable.

Copyright

Code is covered by the MIT license.

The images are provided by fictionaldogs on the ZFGC forums. http://zfgc.com/forum/index.php?topic=41500.0 "If anybody wants to use anything, feel free to do so (with credit given if it is made outside of zfgc.com of course)."

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.