let m = { mo.GetPos()|-><Occupied> | mo inset mobs} in
SetObs(m);
);
private SetObs: map Grid`Point to Grid`PointAvalibility ==> ()
SetObs(mp) ==
(
obs := { |->}; -- remove old data could be replaced by using the thread -- id of the thread
obs := obs ++ mp
);
private WaitForAvalibility: Grid`Point ==> ()
WaitForAvalibility(p) == while IsPointBlocked(p) do
(
Util`PrintDebug("Waiting for obstacle on pos:");
Util`PrintValue(p);
Util`PrintInt(time);
Util`PrintDebug("Requesting Pos");
Util`PrintValue(p);
Util`PrintDebug("Mobs"); forall mo insetdom obs do
Util`PrintValue(mo);
if p insetdom obs then
Util`PrintDebug("in") else
Util`PrintDebug("not");
return p insetdom obs;
);
public GetNextPoint : setof Grid`Point * Grid`Point ==> [Grid`Point]
GetNextPoint(neighbours, dest) == let tmp : set1 of Grid`Point ={p| p inset neighbours
& notexists q inset neighbours &
Distance(p, dest) > Distance(q, dest)} in forall p inset tmp do
(
WaitForAvalibility(p);
return p
) precard neighbours > 0;
functions
Distance: Grid`Point * Grid`Point -> nat
Distance(p1, p2) == def a = (p2.X-p1.X)* (p2.X-p1.X) + (p2.Y-p1.Y)* (p2.Y-p1.Y) in if 0<= a then floor(MATH`sqrt(a)) else
0;
end NextMoveController
class NextMoveControllerTest issubclassof TestCase values
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.