Autor Beitrag
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 06.02.05 10:18 
Hallo,
ich habe mich heute mal wieder versucht ein Programm zu schreiben, welches ein weg zum ziel suchen soll, doch leider passiert nichts bzw. das progamm hängs sich auf(wenn ich das auskometierte reintue)

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
function TForm1.FindPfad(x,y:Integer;ZielEreicht:Boolean):Boolean;
var
  r:Integer;
  b:Boolean;
begin
  sleep(10);
  application.ProcessMessages;
  r:=1;
  if (x = MapX) or (y = MapY) then exit;
  if (x = ZielX) and (y = ZielY) then result:=True;
  if (x > MapX) or (y > MapY) or (x < 0 ) or (y < 0) then Begin
    result:=False;
    exit;
  end;

  b:=False;

  while (not b) and (r < 4) do begin
    if Map[x,y] <> ClBlack then result:=False;

//    if Map[x,y] = clBlack then begin
      if r = 1 then b:=FindPfad(x,y+1,ZielEreicht);
      if r = 2 then b:=FindPfad(x+1,y,ZielEreicht);
      if r = 3 then b:=FindPfad(x,y-1,ZielEreicht);
      if r = 4 then b:=FindPfad(x-1,y,ZielEreicht);
      inc(r);
      if b then break;
 //   end;
  end;

  if not b then
  Map[x,y]:=clRed;
  Zeichne;
  result:=b;

end;

_________________
MFG
Michael Springwald, "kann kein englisch...."
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: So 06.02.05 10:40 
Hi,
Ich kann dir speziell zu deinem Fehler nichts sagen, aber wir haben im Projekt Omorphia eine Backtracing Unit. Du kannst sie dir ja mal anschauen vllt hilft sie dir ein wenig.
Omorphia AIBacktracing

mfg matze

_________________
si tacuisses, philosophus mansisses.
Basti
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 345

Windows Vista
D2005 Pers, D7 Pers
BeitragVerfasst: So 06.02.05 13:52 
Also so kann man da ziemlich schlecht was zu sagen.
Wenn es sich aufhängt, ist es wahrscheinlich eien Endlosschleife.
Setz mal einen Haltepunkt in der Schleife und mach dann Schritt für Schritt
mit F7 weiter.
Wenn du dann eine Variable im Quelltext rechts anklickst und auf fehlersuche -
Auswerten/Ändern gehst, kannst du den Wert prüfen.
So würde ich das einfach mal durchlaufen lassen.
Dann siehst du, warum die Bedingung nicht erfüllt wird und weshalb dadurch
eine Endlosschleife entsteht.

_________________
Der Computer ist die logische Weiterentwicklung des Menschen: Intelligenz ohne Moral.
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Mo 07.02.05 06:46 
Hi Mimi,

mit deinem Problem kann dir BenBE sicher helfen. Da er die Unit in Omorphia geschrieben hat. Kann dir aber leider auch nicht mehr dazu sagen. Oder du Google's mal nach diesem Thema sollte auch etwas bringen.

Cu
Neo