A Suggestion/Idea and a Minor Bug

Agamemnus

Warlord
Joined
Jan 9, 2002
Messages
286
Location
Massachusetts, New England, USA
I thought I could post this here since Firaxis doesn't seem to read their emails at all. (I sent one email on the 20th of this month and another one, about map generation, a few months ago.. it was mostly about a program I had written)

1) Suggestion

It just might be, although I do not know this for sure, that the slow loading and turn moving is associated with pathfinding.

Let me venture to guess that your current pathfinding routine involves checking for do-able paths a certain distance from a straight line between the two points? Well whatever it is, here's my suggestion:

It would be simple to find the shortest path if there were only 3 types of squares:
1) 1 movement point value squares.
2) 2 movement point value squares.
3) 0 movement point value squares (water, mountain, jungle, forest)
Then you could just search for the shortest path, extending in both sides in an arc if the path was not crosseable. (then if it is, get some more paths and use the shortest one)

It gets more complicated [er.. slower] when there are more units and/or ROADS and RAILROADS and SHIPS!!!

What I suggest is creating (once per world map knoweledge change) a different map that is based on easy movement, not a square map 'as is'..

This new map could be like a hill: ease of movement across regions can be defined as slopes on different sections of the hill. Rails could be defined as plains. :) Unaccessible terrain could be defined as ridges or water. :)

Obviously you'd need different maps for:
1) ships
2) restricted movement vehicles such as chariots, catapults, etc.

The hill map could then be stretched or 'fudged' (like the earth is fudged on a square, 2-d, map) to make it a 2-dimensional map, and then the map could be used to find a path as described earlier.

It is also possible to create 3-d shortest path algorithms. (such as a line is, in the simplest form, y = mx + b) However, I think the stretch approach would take less time to compute.

2) Minor Bug

When a city is captured the tile from where the capturing unit came from becomes temporarily blank (visibly).
 
I think that the pathfinding algorithms probably just solve a matrix equation - basically an optimisation routine, and there are quite a few examples. This kind of matrix manipulation will only take milliseconds to calculate - hit the "G" key, and move the mouse around - the fastest route to wherever you want to go is virtually instantaneously shown. :)
 
Replies:

1) The pathfinding routine is a function. So you only have to change it in one place. The difficulty of actually thinking while programming is understandable however. :D

2) Not player pathfinding, computer pathfinding.
 
Originally posted by ainwood
What's the difference? :confused:

Actually, they probably use the same algorithm. But waiting half a second for a path to be displayed during your turn is one thing. To take half a second to calculate each of thousands of possible paths during the AI's turn can seem like forever.
 
Originally posted by Zachriel


Actually, they probably use the same algorithm. But waiting half a second for a path to be displayed during your turn is one thing. To take half a second to calculate each of thousands of possible paths during the AI's turn can seem like forever.
But surely the bottleneck in displaying the path (which takes waaaay less than 1/2 a second BTW ;) ) has to be in redrawing the graphics. I'm sure that the path finding algorithm execution takes milliseconds. :)
 
Originally posted by ainwood
But surely the bottleneck in displaying the path (which takes waaaay less than 1/2 a second BTW ;) ) has to be in redrawing the graphics. I'm sure that the path finding algorithm execution takes milliseconds. :)

I believe the thread was meant to be about pathfinding being the cause of turn-lag, which it is. Milliseconds * thousands of paths = seconds. As I said, "Heuristic pathfinding is a rich area of mathmatics."
 
You are wrong on this issue. (I think uhhh maybe )

Actually, one could possibly design a circuit part that does pathfinding exclusively. Think 3D Accelerator type circuit :)

Any broken circuit will not conduct electricity. Therefore, if you set up a maze that you wanted to solve and made each leg a wire, connecting the two ends, you would quickly find the solution. It is unclear to me why electrons don't turn on and then off to check every other possibility. :confused: It seems that it only takes the electrons light speed to find the solution.

Perhaps you could even create a computer that harnesses this method of uh... calculating? :crazyeye:

You could modify this method:
1) set up an electron path with input from the map data
2) when one path is initiated (an electron at one of the ends is 'excited', I think) there is some mechanism to stop all the other paths. Voila! Shortest path algorithm! :goodjob:
 
I remember reading an article in Game Developer Magazine, a Post-Mortem I believe. The guy said that they had optimized the pathfinding for AOE (they were making sure the game could run on pentium 166 MHz). The problem was, even though that was optimized, how often the function was run wasn't and that turned out to be the problem.

I agree with Zachriel. With interactivity, a certain short period of time is nothing. Without interactivity and that time period multiplied by a thousand units, it's waiting time.

Dijkstra's shortest path algorithm is pretty efficient (O(log(n)) I believe) so the A* search must be even faster (assuming great heuristics), though I know it's not always the shortest path, which bugs me from time to time. I don't know how much they can continue to optimize it. Plus, there are other AI aspects that are much more important in overall gameplay.
 
Originally posted by Agamemnus
It is unclear to me why electrons don't turn on and then off to check every other possibility. :confused: It seems that it only takes the electrons light speed to find the solution.

Because the electrons aren't coursing through the circuit at light speed, which is what you seem to think they're doing. The actual velocity of electrons moving through a circuit is usually no more than a few centimeters per second, and often slower than that. What does travel at (nearly) the speed of light in the circuit is the voltage pressure, much in the same way sound travels much faster than any of the air molecules it's traveling through.
 
I knew that.. I said it takes them second to find the solution when the photons course thru them, not to move thru the wires. :) [Which, I believe, is Vs, electron flow speed or something]

Voltage pressure? Never heard of it...

-----------------------------------------------------

But anyways, why are they so smart? :?

-----------------------------------------------------
 
Back
Top Bottom