Flying Wiener Dog

Released Books


An Ember in the Wind


A Foundation in Wisdom

Apps


WordMutation (NEW!)


Orbitual


Permutation


Arcade

Artificial Intelligence Tools

The AI Tools package is an extension for Stencyl development environment. It is a general-purpose graphs toolset, which includes an implementation of A* pathfinding.

Downloads:       [ai-tools-current.zip]       [ai-tools-current.tar.gz]       [sample stencyl export]

More examples and past releases are available from the Archives Page. There is a playable demo here.
 

General Discussion

The AI Tools extension is designed as a general-purpose toolset for problems which can be solved, or partially solved, using graphs. Example problems include:

  • Solving a maze
  • Finding the best path from point A to point B
  • Identify if two areas are connected
  • NPC navigation of a technology tree (e.g. researching upgrades in a real-time strategy game)
  • Decision making

Quick Function Reference

Function                        

   

Description

autoGraph

 

Generates a graph from the scene tiles (all layers). Row, column coordinates with no tile collision boxes are marked as nodes.

 

 

findPath

 

Returns a path from the initial point to the goal. The path can either be a list of steps, or a list of visited coordinates. [more discussion]

 

 

pathCost

 

Returns the total cost of travelling along a specified path.

 

 

autoDrawGraph

 

Drawing block that draws the specified graph. Be sure to specify stroke thickness and stroke color (example below). This block is intended to help debug graphs generated by the "autoGraph" block (above), or other graphs that overlay a scene.

 

 

createGraph

 

Creates an empty graph.

 

 

setNorm

 

Specifies the norm used for the heuristic function. [more discussion]

 

 

exportGraph

 

Returns a list containing the graph data. [more discussion]

 

 

isConnectionAt

 

Returns true if there is an edge connecting the two specified nodes. For one-way connections, the source is the first node, and destination the second.

 

 

getConnectionName

 

Returns the name of the specified connection.

 

 

setConnectionName

 

Sets the name of the specified connection.

 

 

setConnectionCost

 

Sets the cost of the specified connection.

 

 

connectNode

 

Connects two nodes. The connection can be given a name, which will be included in the data "find path" returns. Note that the connection will be one-way, with the source being the first node, and destination the second.

 

 

deleteConnection

 

Deletes the connection linking the two specified nodes. For two-way connections, you will need to call this function for both directions.

 

 

isNodeAt

 

Returns true if there is a node at the specified location.

 

 

getNodeName

 

Returns the name of a node at the specified location.

 

 

setNodeName

 

Sets the name of a node at the specified location.

 

 

addNode

 

Adds a node to the graph at the specified coordinates. The node can be given a name, which will be included in the data "find path" returns.

 

 

deleteNode

 

Deletes the specified node and all connections associated with it.

 

 

graphList

 

Returns a list of defined graphs.

 

 

deleteGraph

 

Deletes the specified graph.

 

 

graphDefined

 

Returns true if the specified graph is defined.

 

 

mergePath

 

Optimizes a list of nodes. mergePath searches for collinear nodes, eliminates interior nodes, and preserves only the endpoints.

 

 

primCopy

 

Creates a new graph with the specified name, which is the result returned by Prim's Algorithm.