Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Assume a character is located on a n by n grid and has to reach a certain entry on that grid. Its current position is (x1,y1). Also on the same grid is an enemy with coordinates (x2,y2). Each step algorithm randomly generates new candidate locations for the hero (if there are k candidates then there is a kx2 matrix of new potential locations.

What I need is some distance objective function to compare the candidates. I'm currently using d1 - c * d2, where d1 is distance to the objective (measure in terms of number of pixels for each axis), d2 is distance to the enemy and c is some coefficient (this is very much like a set-up for Lagrangian). It's not working very well though. I'd be quite keen to learn how what constrained distance function are used for similar cases.

Any suggestions are very much appreciated.

share|improve this question
I'm not sure I understand what your problem is. Is that an AI problem, i.e. is your "character" or "hero" located in (x1,y1) computer-driven? If so, are you trying to make this AI both go to its goal, let's say in (xg,yg), and avoid its enemy in (x2,y2)? Please try to clarify this a bit. – Laurent Couvidou Apr 6 '12 at 11:03
2  
Maybe you should just skip all the maths and tell us in plain words what behaviour you are trying to achieve. – eBusiness Apr 6 '12 at 15:02
1  
You need to say, at minimum, what you consider "not working very well." – John Calsbeek Apr 6 '12 at 15:58
OK, here's the challenge: the character needs to et to some entry on the grid without being killed by an enemy which performs a random walk. For this purpose the step that the cahracter takes has to account for 1)distance to the target 2)distance to the enemy. What's the best way of doing it? – sigma.z.1980 Apr 8 '12 at 1:09

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.