Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jan 29, 2020 8:29 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Aug 02, 2012 8:07 am 

Joined: Sat Jul 14, 2012 2:35 am
Posts: 19

i was wondering why movement via astar pathfinding of the slick library was so unexpected. while avoiding an obstacle, the mover object was always moving towards the obstacle directly before travelling around.

in the implementation of the astar, it calculates the "distance" just by the cost of the given TileBasedMap. As suggested, the map could return 1 for each tile. But doing this, the cost for travelling diagonal is equal to the cost for travelling horizontal or vertical. the problem is, u cant use another value for getCost in the TileBasedMap since u dont know, from which tile u came from outside the algorithm.

// the cost to get to this node is cost the current plus the movement
// cost to reach this node. Note that the heursitic value is only used
// in the sorted open list
float nextStepCost = current.cost + getMovementCost(mover, current.x, current.y, xp, yp);

a quick solution to this bug could be to multiply the cost by square root of 2 for diagonal movement.

greetz Ben

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group