top of page
  • Writer's pictureCharlie Kowalski

Flow Fields

We've all played RTS's before, playing ether a commander leading your troops or part of a group of survivors trying to explore the unknown world the versatility of the genre is endless. One consistent factor is the way these games handle movement of Ai entity's on the screen and that is by using a Flow Field. A Flow Field is a grid structure that allows for pathfinding of Ai entities to a clicked location on the grid with room for changings in terrain weights and impassable locations. Calculating The Flow field

Cost Field: The first part of the Flow Field is the cost field, this field determines landscape function of the Flow Field but assigning every square of the grid a byte cost. Given each square a byte allows the values inside to range from 1 to 255, this will be the weight cost to travel over the square for when we calculate the pathfinding. By default, all the squares are set to a byte value of 1 if we put the square to its max value, of 255, then that square would be labeled as impassable. The gives us the range of 2-254 to assign to different landscapes and environments to affect the decisions made in the pathfinding algorithm.

Integration field: The Integration Field is the hardest working part of the algorithm and makes up most of the complexity. The basic function of the Integration field is to got through all of the nodes on screen starting at the location that was clicked, setting that node to 0. Then it iterates through all of the neighbors nodes increasing the value by one as it grows distance from the center, it also interacts with the cost field scaling the increase by the value of the cost field. While calculating we also assign direction data in the cell so that when we get to the next step, we can point the entity's in the right direction.

Flow Field: The final part of the algorithm is taking the direction data from the integration field and comparing it to the neighbors to find the fastest and most efficient path to the target locations. For being the name sake of the AI program it doesn't have a lot of complexity's to do its more putting everything together. Following the Field: Using the data of the best direction of the Flow Field we can give this direction to the Ai entities and move there velocity in the determined best direction at any movement speed we pass in.

Here's a video showing off my code!

2 views0 comments

Recent Posts

See All

Define your final game: game description, intended player experience, platform, technology, market, team members. What changed from the mid-mortem? Set the context for the rest of your reflection. Ach

Hello and welcome to my third development blog! It has been a while since I've posted one due to being swamped with capstone work and work for other majors but I am here to talk about my experiences!

bottom of page