Einzelnen Beitrag anzeigen

Cicaro

Registriert seit: 9. Feb 2005
285 Beiträge
 
Delphi 7 Personal
 
#47

Re: Ideen zur Schach KI

  Alt 14. Apr 2005, 07:49
Zitat von glkgereon:
bevor du mit ner ki anfängst, schreib erstmal eine "grafik"-engine, die folgende anforderungen erfüllt:

- darstellung der akuellen stellung
- entgegennahme von user-inputs (maus, tastatur)
- entgegennahme von programm-inputs (functions/ procedures)
- einfach ansteuerung (zb. TrackFigure(x1,y1,x2,y2); )

dann erweiterst du diese engine mit einem reinen bewertungssystem, das einfach sagt, wie es seiner meinung nach grade steht.

dieses testest du dann ausführlich

wenn es gut ist, dann baust du ein das er züge selber ausprobiert.

und dann, ist es nur noch ein kleiner schritt bis zur "richtigen" ki
Guck mal hier:

Delphi-Quellcode:
type
 TMove = record
          A,B,rA,rB,V:TPoint;
         end;

 TFigure = record
            Pos:TPoint;
            ID:Integer;
           end;

 TFields = array[1..8,1..8] of TFigure;

 TBoard = class
 public
  Children:array of TBoard;
  Parent:TBoard;

  Fields:TFields;
  Move:TMove;
  Turn:Integer;
  wGetPawn,bGetPawn,wRochade,bRochade:Boolean;

  constructor Create(AParent:TBoard);
  destructor Destroy;override;

  procedure NewBoard;
  procedure LineUpFigures;
  procedure CopyFrom(B:TBoard);

  function KingMoveAllowed:Boolean;
  function RochadeAllowed:Boolean;
  function RookMoveAllowed:Boolean;
  function KnightMoveAllowed:Boolean;
  function BishopMoveAllowed:Boolean;
  function PawnMoveAllowed:Boolean;
  function PawnKillAllowed:Boolean;

  function Checked(Side,x,y:Integer):Boolean;
  function KingChecked(Side:Integer):Boolean;
  function GettingChecked:Boolean;

  function MovePossible:Boolean;
  function MoveAllowed:Boolean;
  procedure DoMove;
  // Einstieg der KI
  procedure TryNewMove;
 end;

 TChessBoard = class(TComponent)
 private
  FImage:TImage;
  FFieldWidth,FFieldHeight:Integer;
  FWhiteFieldColor,FWhiteFrameColor,FBlackFieldColor,FBlackFrameColor:TColor;
 public
  BitmapCollection:TBitmapCollection;
  Board:TBoard;

  constructor Create(Owner:TComponent);override;
  destructor Destroy;override;

  procedure DoBestMove;

  procedure DrawField(x,y:Integer);
  procedure DrawMovedFigures;
  procedure DrawBoard;
 published
  property Image:TImage read FImage write FImage;
  property FieldWidth:Integer read FFieldWidth write FFieldWidth default 32;
  property FieldHeight:Integer read FFieldHeight write FFieldHeight default 32;
  property WhiteFieldColor:TColor read FWhiteFieldColor write FWhiteFieldColor default $EFEFEF;
  property WhiteFrameColor:TColor read FWhiteFrameColor write FWhiteFrameColor default $DFDFDF;
  property BlackFieldColor:TColor read FBlackFieldColor write FBlackFieldColor default $BFBFBF;
  property BlackFrameColor:TColor read FBlackFrameColor write FBlackFrameColor default $CFCFCF;
 end;
Die meisten Methoden außer TBoard.TryNewMove funktionieren.
Du siehst hab schon vieles vorbereitet. Ist auch 'n Kopie von meinem Mehrspieler-Schach

Hier ist es!
  Mit Zitat antworten Zitat