Reader small image

You're reading from  Unity 5.x Game AI Programming Cookbook

Product typeBook
Published inMar 2016
PublisherPackt
ISBN-139781783553570
Edition1st Edition
Tools
Right arrow
Author (1)
Jorge Palacios
Jorge Palacios
author image
Jorge Palacios

Jorge Palacios is a software and game developer with a BS in computer science and eight years of professional experience. He's been developing games for the last five years in different roles, from tool developer to lead programmer. Mainly focused on artificial intelligence and gameplay programming, he is currently working with Unity and HTML5. He's also a game-programming instructor, speaker, and game-jam organizer.
Read more about Jorge Palacios

Right arrow

Improving influence with convolution filters


Convolution filters are usually applied via image processing software, but we can use the same principles to change a grid's influence given a unit's value and its surroundings. In this recipe, we will explore a couple of algorithms to modify a grid using matrix filters.

Getting ready

It is important to have grasped the concept of influence maps before implementing this recipe, so that you can understand the context in which it is applied.

How to do it…

We will implement the Convolve function:

  1. Declare the Convolve function:

    public static void Convolve(
            float[,] matrix,
            ref float[,] source,
            ref float[,] destination)
    {
        // next steps
    }
  2. Initialize the variables for handling the computations and traversal of arrays:

    int matrixLength = matrix.GetLength(0);
    int size = (int)(matrixLength – 1) / 2;
    int height = source.GetLength(0);
    int width = source.GetLength(1);
    int I, j, k, m;
  3. Create the first loop for iterating over the destination...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Unity 5.x Game AI Programming Cookbook
Published in: Mar 2016Publisher: PacktISBN-13: 9781783553570

Author (1)

author image
Jorge Palacios

Jorge Palacios is a software and game developer with a BS in computer science and eight years of professional experience. He's been developing games for the last five years in different roles, from tool developer to lead programmer. Mainly focused on artificial intelligence and gameplay programming, he is currently working with Unity and HTML5. He's also a game-programming instructor, speaker, and game-jam organizer.
Read more about Jorge Palacios