AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Vier Gewinnt Anfängerbeispiel
Thema durchsuchen
Ansicht
Themen-Optionen

Vier Gewinnt Anfängerbeispiel

Ein Thema von boozzz · begonnen am 1. Apr 2005 · letzter Beitrag vom 2. Apr 2005
Antwort Antwort
Nils_13

Registriert seit: 15. Nov 2004
2.647 Beiträge
 
#1

Re: Vier Gewinnt Anfängerbeispiel

  Alt 2. Apr 2005, 09:02
Hi,

bei der procedure KI; ist es ziemlich sinnlos, andauernd
Delphi-Quellcode:
if AktuellesBrett[x+1,y]=1 and if AktuellesBrett[x+2,y]=1 and if AktuellesBrett[x+3,y]=1 then //
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
aufzurufen.
Delphi-Quellcode:
procedure ki(x, y: Integer);
begin
  for x:=1 to breite do //Ueberpfrung, ob Computer im n�hsten Zug gewinnen kann
    for y:=1 to hoehe do //Im Folgenden werden alle m�lichen Zge des Computers und deren Nachbarn betrachtet
      if AktuellesBrett[x,y]=2 then //Gegenenfalls wird das Viererpaar vollendet und die Prozedur KI beendet
        if AktuellesBrett[x+1,y]=1 and if AktuellesBrett[x+2,y]=1 and if AktuellesBrett[x+3,y]=1 then //
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-1,y]=1 and if AktuellesBrett[x-2,y]=1 and if AktuellesBrett[x-3,y]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-2,y]=1 and if AktuellesBrett[x-1,y]=1 and if AktuellesBrett[x+1,y]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-1,y]=1 and if AktuellesBrett[x+1,y]=1 and if AktuellesBrett[x+2,y]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x,y+1]=1 and if AktuellesBrett[x,y+2]=1 and if AktuellesBrett[x,y+3]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x,y-1]=1 and if AktuellesBrett[x,y-2]=1 and if AktuellesBrett[x,y-3]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x,y+1]=1 and if AktuellesBrett[x,y+2]=1 and if AktuellesBrett[x,y-1]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x,y+1]=1 and if AktuellesBrett[x,y-1]=1 and if AktuellesBrett[x,y-2]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x+1,y+1]=1 and if AktuellesBrett[x+2,y+2]=1 and if AktuellesBrett[x+3,y+3]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-1,y+1]=1 and if AktuellesBrett[x-2,y+2]=1 and if AktuellesBrett[x-3,y+3]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-1,y-1]=1 and if AktuellesBrett[x-2,y-2]=1 and if AktuellesBrett[x-3,y-3]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x+1,y-1]=1 and if AktuellesBrett[x+2,y-2]=1 and if AktuellesBrett[x+3,y-3]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x+1,y+1]=1 and if AktuellesBrett[x+2,y+2]=1 and if AktuellesBrett[x-1,y-1]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-1,y+1]=1 and if AktuellesBrett[x-2,y+2]=1 and if AktuellesBrett[x+1,y-1]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x-1,y-1]=1 and if AktuellesBrett[x-2,y-2]=1 and if AktuellesBrett[x+1,y+1]=1 then
        begin
          AktuellesBrett[x,y]:=1;
          P:=x; ergebnisliegtvor:=True; Exit;
        end
        else if AktuellesBrett[x+1,y-1]=1 and if AktuellesBrett[x+2,y-2]=1 and if
AktuellesBrett[x-1,y+1]=1 then
Lass dir da noch etwas besseres und kompakteres einfallen.

Bei der Brettnalyse ebenfalls.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:46 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-2025 by Thomas Breitkreuz