![]() |
Re: Suche Suchbaum Code
Sowas? :roll:
Delphi-Quellcode:
Function FindBestMove(Level: Integer; aPlayer, aOpponent: TPlayer;
Var aBoard: TBoard; Var aBestMove: TMove; aPatt: Boolean): Integer; var Dummy: TMove; aMoves: TMoveList; i, N, S: Integer; begin Result := sPassScore; aBestMove.mPlayer := plEmpty; CreateAllMoves(aPlayer, aOpponent, aBoard, aMoves, N); if (N = 0) then if aPatt or (Level = 0) then begin Result := 0; // Unentschieden // Oder so: Spieler mit mehr Steinen gewinnt // Result := FinalScore (aBoard, aPlayer, aOpponent); Exit; end else Result := -FindBestMove(Level, aOpponent, aPlayer, ABoard, Dummy, True) else for i := 0 to N - 1 do begin MakeMove(aBoard, aMoves[i]); S := Score(aBoard, aPlayer, aOpponent); if s = sWinScore then s := s + Level // Die Gewinnzüge möglichst früh ausführen. else if (Level > 0) then S := -FindBestMove(Level - 1, aOpponent, aPlayer, ABoard, Dummy, False); UndoMove(aBoard, aMoves[i]); if (S > Result) then begin Result := S; aBestMove := aMoves[i]; end; end; End; Zitat:
|
Re: Suche Suchbaum Code
naja danke werde es so versuche
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:19 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz