Autor Beitrag
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Di 16.12.08 16:22 
Wir sollen für Solitaire ( Brettspiel ) ein Programm erstellen, welches möglichst effizient, das Spiel "löst" wenn ein Stein mit der Feldnummer n fehlt.

Was ich weis, das Bruteforce/Backtracking wohl sinnlos sein wird. Was ich nicht weis ist, wie ich die Lösung des Spiels sonst umsetzen soll.
Hilfsfunktionen sind nicht das Problem sondern das Spiel selber.

Ich dachte ersteinmal an eine Art Regeln die man aufstellt, von wegen wenn der Stein fehlt dann tausche niemals den anderen o.ä. aber damit komm ich nicht wirklich weiter.

Wie gehe ich am besten an das Problem heran?
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: Di 16.12.08 16:25 
Der von dir verlinkte WP-Artikel weiß was dazu ;) .
Jerk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Di 16.12.08 16:31 
*facepalm*
Ok also sozusagen einen "Baum" erstellen.
d.h.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
n= anzahl verbleibender Spielsteine
FUNKTION TEST : BOOLEAN
Für jedes leere Feld:
  Gibt es mögliche Sprünge?
    Springe
    n=n-1
    wenn TEST = FALSE
      mache zug rückgängig
    SONST
      Gebe Ergebnis aus
  SONST
    Wenn n=1 
      return TRUE
    SONST
      return FALSE
Jerk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Fr 19.12.08 10:40 
Sorry für den Doppelpost, aber ich sitze noch an dem Problem.

Das Rekursive Backtracking habe ich verstanden, doch bekomme ich es nicht hin die "Züge" rückgängig zu machen. Da das Spielfeld ja ein Array (3-Dim) ist dachte ich wäre ein Stack doch eher ungeeignet oder?
Fiete
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 617
Erhaltene Danke: 364

W7
Delphi 6 pro
BeitragVerfasst: Fr 19.12.08 11:27 
Moin Jerk,
schau mal hier nach www.delphi-forum.de/...dlerspiel_83197.html.

Gruß
Fiete

_________________
Fietes Gesetz: use your brain (THINK)