Inge Jones wrote:Helmic wrote:I think a more elegant solution to the speed problem is to just have prisoners/workers jog if they're far away from their destination or running late, then slow down when they get close to it.
There are two things wrong with this. Firstly it doesn't address the unrealistic time it takes to walk 1 meter *compared to clock time*. Secondly the type of processing needed to calculate whether a prisoner needs to jog is not only expensive to the system, but dreadfully hard to actually compute. Can you imagine writing an algorithm that takes into account where the prisoner is going, and what he's going to do, and how long that activity will need to complete, then subtract that from a cutoff time derived from *all* the factors that might limit available time in the location doing the activity? Only humans can efficiently apply this sort of multi-factorial logic, because we all have our own CPUs.
Neither of those things you said make sense.
Of course it addresses the unrealistic amount of time it takes to walk 1 meter, that's the whole point of jogging, to move faster. The game isn't going to have "realistic" movement rates because that would result in way too fast animations. However, we CAN "cheat" the system by having people who need to move a long distance move faster without penalizing people who design their prisons to minimize walk times.
If a prisoner is 20 units from his destination, he'll walk at a rate of, say, 10 units per second. He gets there in two seconds. If another prisoner is 100 units from his destination, he'll jog at maybe 40 units per second until he's 20 units from his destination, at which point he'll slow back down to 10 units per second, taking four seconds. Had he not ran, he would have taken a grand total of ten seconds. Prisoners closer to their destination will always get there before prisoners further away, but far away prisoners then don't take so long that they don't have any time left over to fulfill needs once they get there.
As for performance impact, what are you talking about? Distance is already calculated as a normal part of pathfinding, doing a quick comparison to see if the prisoner should run would be trivial. You just determine whether they run or walk with a simple comparison test, if it's greater than 20 units (or whatever arbitrary distance we want to use) they run at the set running speed, else they walk. When they're within X units of their destination, walk. It's cheap to the point of being utterly negligible even with thousands of AI pathing everywhere. And the AI already knows how to sprint, they just don't sprint enough when they should be in a hurry.