ID:1668343
 
(See the best response by Kaiochao.)
Okay, so I'm trying to develop some pathfinding of my own because I'm not really into using demos. I need some help here.

Let's say you're trying to move from point A to point B. Point B is directly North of Point A, however there's dense turf atoms blocking your path (as an example, we'll say you're in the middle of an upside-down U shape). I have my code where it alternates clockwise/counter-clockwise checks. If you're trying to move north and there is an object blocking your path, it will detect northeast. If northeast is blocked, it detects northwest, then east, west, southeast, southwest, and south. If no paths are available from point A to point B after this method, I have it set to return a "No path available." message.

I'm using for(var/atom/o in get_step(src,dir)) to detect dense turf atoms blocking your path, obviously substituting dir for the direction it's checking at any given point in time. This returns obj and mob atoms, but not turf atoms.

Is there some other way to go about doing this due to some function changes? I've been using similar methods in the past (not for this exact thing) and it has returned it detected a dense turf atom. I'm just wondering if there's some other method this should be done with.
Best response
get_step() returns a turf. Common mistake.
Let me elaborate a bit more. I want this pathfinding to detect ANY atoms. Obj, mob, AND turf. It's finding obj and mob atoms just fine, it's not returning any turf atoms.
Enter() and Exit() do this for you. There is no need to loop through the contents of the turf (by the way, you are already getting the turf by calling get_step()), as Enter() and Exit() automatically loop through the objects in that location themselves.

See my pathfinding snippet for further information: http://www.byond.com/forum/?post=1666799
Just going to put this out there, if I didn't write the code myself, 99% of the time I won't be able to understand it. I just will not be able to get any sort of information out of your pathfinding snippet, no matter how long I read through it. Hell, that's the first thing I checked when I came to the forums when I had this problem.

I get Enter() and Exit() do this, however you can't enter a dense turf, you just bump into it. Yes? I'm just wanting to figure out how to make this work without changing too much of what I have already.
Enter() and Exit() only detect whether you can move into a turf. They are perfect for what you are looking to do.

Enter() returns 1 if there are no dense objects in a turf, and the turf itself isn't dense. Exit() returns 1 by default.

however you can't enter a dense turf, you just bump into it.

Enter() does not trigger Bump(). Bump() is part of Move(). You aren't calling Move() you are calling Enter() and Exit(). This won't trigger Bump().

I'm just wanting to figure out how to make this work without changing too much of what I have already.

"I don't want to do things right. I want to do them really half-assed."
Oh, I see what you're saying. So, the question in this case is how do I go about putting this in without doing an entire re-write? Currently it's set as:
proc
pathfinding(atom/movable/o,obj/target/t)
moveloop
var/moved=0
var/distance=get_dist(o,t)
var/direction=get_dir(o,t)
for(var/atom/p in get_step(o,direction))
if(p.density==1)
if(direction==NORTH)
for(var/atom/ne in get_step(o,direction))
if(ne.density==1)

For reference, obj/target is a target that is placed at the location a player clicks or the location that an atom is trying to get to.
And that continues until it checks every direction. However, if it does not find that the northeast atom is dense for example:
                        else
moved=1
step(o,NORTHEAST)

And if the initial check of p wasn't dense:
            else
if(moved==0)
step(o,direction)
spawn(0.75)
var/distance2=get_dist(o,t)
if(distance2>0)
goto moveloop


What would you recommend changing here without doing an entire re-write of the code?
if(oldturf.Exit(o)&&newturf.Enter(o))


What would you recommend changing here without doing an entire re-write of the code?

I have to say, your current proc isn't recognizable as any kind of a pathfinding algorithm I've ever seen.

I can't give you any advice on what to change, because your code doesn't look to achieve the goal it's intended to. I've linked you my article for a complete pathfinding algorithm. That's really the best I can do for you.