syntax
Source Link

You have almost answered your question in your post. You say that you

simple do a expanding circle, starting from the production building, and choose the first carrier found due it has the shortest direct way.

So this should be your initial point, the production building. You do not need to cycle through all of your idle minions to get the nearest one, instead you can start searching for the idle minions around your building and stop whenever you find one.

Having no idea how your map and pathing models are setup, I would assume that you have some kind of two-dimensional array as a map, with XY orientation and elements meaning what type of object you have on the map. Buildings, trees, roads etc. Minions and other "moveable" objects go in separate array with just XY coordinates for their position.

If this is your case - you can just send a wave from your production building and see which idle minion it arrives first. It would be your nearest idle minion.

If you don't have this, and you have XY coordinates system, with the list of the objects on the map and their XY coordinates, widths, lengths, shapes, etc. then it's going to be painful.

If your map is huge and sending a wave will lead to significant calculations and slows down the system, if your map and objects on it are 'indestructible', 'immovable' etc. you can build up hashtable with the shortest paths or just lengths of the shortest paths from any-to-any points on the map. There would always be no more than n*(n-1)/2 elements in your hashtable, where n is total number of the 'map-squares'.

If your map and objects are changeable, you still can build up such hashtable and update only the part, where your changed points belong to. Consider you build new building on the tile (x=10, y=15), meaning that you need to update only paths for the pairs of points, which shortest paths lead through this point.

Having such a table, you can easily get all the paths starting from the point where your production building stands, sort them by lengths, join with the points where your minions stand and get the one with the shortest path.

I know, it all sounds like you need to build some path-finding engine from a scratch, but when you do it you nowknow it's got to work perfectly.

You have almost answered your question in your post. You say that you

simple do a expanding circle, starting from the production building, and choose the first carrier found due it has the shortest direct way.

So this should be your initial point, the production building. You do not need to cycle through all of your idle minions to get the nearest one, instead you can start searching for the idle minions around your building and stop whenever you find one.

Having no idea how your map and pathing models are setup, I would assume that you have some kind of two-dimensional array as a map, with XY orientation and elements meaning what type of object you have on the map. Buildings, trees, roads etc. Minions and other "moveable" objects go in separate array with just XY coordinates for their position.

If this is your case - you can just send a wave from your production building and see which idle minion it arrives first. It would be your nearest idle minion.

If you don't have this, and you have XY coordinates system, with the list of the objects on the map and their XY coordinates, widths, lengths, shapes, etc. then it's going to be painful.

If your map is huge and sending a wave will lead to significant calculations and slows down the system, if your map and objects on it are 'indestructible', 'immovable' etc. you can build up hashtable with the shortest paths or just lengths of the shortest paths from any-to-any points on the map. There would always be no more than n*(n-1)/2 elements in your hashtable, where n is total number of the 'map-squares'.

If your map and objects are changeable, you still can build up such hashtable and update only the part, where your changed points belong to. Consider you build new building on the tile (x=10, y=15), meaning that you need to update only paths for the pairs of points, which shortest paths lead through this point.

Having such a table, you can easily get all the paths starting from the point where your production building stands, sort them by lengths, join with the points where your minions stand and get the one with the shortest path.

I know, it all sounds like you need to build some path-finding engine from a scratch, but when you do it you now it's got to work perfectly.

You have almost answered your question in your post. You say that you

simple do a expanding circle, starting from the production building, and choose the first carrier found due it has the shortest direct way.

So this should be your initial point, the production building. You do not need to cycle through all of your idle minions to get the nearest one, instead you can start searching for the idle minions around your building and stop whenever you find one.

Having no idea how your map and pathing models are setup, I would assume that you have some kind of two-dimensional array as a map, with XY orientation and elements meaning what type of object you have on the map. Buildings, trees, roads etc. Minions and other "moveable" objects go in separate array with just XY coordinates for their position.

If this is your case - you can just send a wave from your production building and see which idle minion it arrives first. It would be your nearest idle minion.

If you don't have this, and you have XY coordinates system, with the list of the objects on the map and their XY coordinates, widths, lengths, shapes, etc. then it's going to be painful.

If your map is huge and sending a wave will lead to significant calculations and slows down the system, if your map and objects on it are 'indestructible', 'immovable' etc. you can build up hashtable with the shortest paths or just lengths of the shortest paths from any-to-any points on the map. There would always be no more than n*(n-1)/2 elements in your hashtable, where n is total number of the 'map-squares'.

If your map and objects are changeable, you still can build up such hashtable and update only the part, where your changed points belong to. Consider you build new building on the tile (x=10, y=15), meaning that you need to update only paths for the pairs of points, which shortest paths lead through this point.

Having such a table, you can easily get all the paths starting from the point where your production building stands, sort them by lengths, join with the points where your minions stand and get the one with the shortest path.

I know, it all sounds like you need to build some path-finding engine from a scratch, but when you do it you know it's got to work perfectly.

Source Link

You have almost answered your question in your post. You say that you

simple do a expanding circle, starting from the production building, and choose the first carrier found due it has the shortest direct way.

So this should be your initial point, the production building. You do not need to cycle through all of your idle minions to get the nearest one, instead you can start searching for the idle minions around your building and stop whenever you find one.

Having no idea how your map and pathing models are setup, I would assume that you have some kind of two-dimensional array as a map, with XY orientation and elements meaning what type of object you have on the map. Buildings, trees, roads etc. Minions and other "moveable" objects go in separate array with just XY coordinates for their position.

If this is your case - you can just send a wave from your production building and see which idle minion it arrives first. It would be your nearest idle minion.

If you don't have this, and you have XY coordinates system, with the list of the objects on the map and their XY coordinates, widths, lengths, shapes, etc. then it's going to be painful.

If your map is huge and sending a wave will lead to significant calculations and slows down the system, if your map and objects on it are 'indestructible', 'immovable' etc. you can build up hashtable with the shortest paths or just lengths of the shortest paths from any-to-any points on the map. There would always be no more than n*(n-1)/2 elements in your hashtable, where n is total number of the 'map-squares'.

If your map and objects are changeable, you still can build up such hashtable and update only the part, where your changed points belong to. Consider you build new building on the tile (x=10, y=15), meaning that you need to update only paths for the pairs of points, which shortest paths lead through this point.

Having such a table, you can easily get all the paths starting from the point where your production building stands, sort them by lengths, join with the points where your minions stand and get the one with the shortest path.

I know, it all sounds like you need to build some path-finding engine from a scratch, but when you do it you now it's got to work perfectly.