Quote:
Originally Posted by pro4never
Keep in mind pull closest will be a method pulling all possible coords near you that are valid and then checking their distance vs target and returning the closest one. Assuming no large obstacles it will return the most efficient coord to move to each time.
|
If you are talking about your pull weights method it is in no way efficient.
Unless I'm completely blind(slight chance) the following code gives me a wacked out path.
EDIT: Yes, this works very well for going short distances, but not when your trying to travel from one end of BI to the other.
PHP Code:
public static Coord PullWeights(Client C, Coord Where)
{
List<Weight> Weights = new List<Weight>();
Coord L = new Coord(C.MyChar.X, C.MyChar.Y);
Coord ToReturn = L;
try
{
for (int Y = C.MyChar.Y - 17; Y < C.MyChar.Y + 17; Y++)
{
for (int X = C.MyChar.X - 17; X < C.MyChar.X + 17; X++)
{
if (C.MyChar.ValidDmap(C.MyChar.Map, (ushort)X, (ushort)Y))
{
Coord Z = new Coord((ushort)X, (ushort)Y);
Weights.Add(new Weight(Z, (ushort)Distance((ushort)X, (ushort)Y, Where.X, Where.Y)));
}
}
}
int Dist = Distance(C.MyChar.X, C.MyChar.Y, Where.X, Where.Y);
foreach (Weight I in Weights)
{
if (I.Dist < Dist)
{
ToReturn = I.Where;
Dist = I.Dist;
if (Dist < 2)
break;
}
}
}
catch { }
Console.WriteLine("Point: {0}, {1} Dist: {2}", ToReturn.X, ToReturn.Y, Distance(ToReturn.X, ToReturn.Y, C.MyChar.TargetCord.X, C.MyChar.TargetCord.Y));
return ToReturn;
}
This is the path that it returns. This image is on a small scale, Same results given on a large scale.
[Only registered and activated users can see links. Click Here To Register...]