Autor Beitrag
Lago
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 08:56 
Hallo.

Mein Programm nützt das UCI-Protokoll um Verbindung mit dem Schachprogramm aufzunehmen. In meinem Fall DelphiMAX.
Ich kann Verbindung herstellen mit dem DelphiMax und sende Daten. Ich empfange sie in einem Memo.
DelphiMax übergibt mir sehr viele Parameter, resp sehr viele Sachen die ich nicht brauche. Ich will, dass nur immer die "bestmove" Zeile angezeigt wird.


In Delphi habe ich die Möglichkeit das Ereignis ONNEWLINE anzuwählen. Ich möchte jetzt, dass DelphiMax mir nur immer den Zug zurückgibt und nichts anderes (sobald aller initialisiert ist natürlich)

Meine Frage:

Welchen Befehl muss ich ihm übergeben, dass das passiert?

Ich habe schon an vielen Orten nachgefragt... habe mich direkt an den Programmierer gewandt... keine Antwort und ich muss unbedingt weiter machen... Kann keiner von euch helfen?

Besten Dank für die Bemühungen.

Pascal
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 03.01.06 08:59 
Filtere Dir doch einfach die benötigte Zeile, indem Du einfach prüfst, dass die übergebene Zeile die "Boest-Move"-Zeile ist, die du willst.

D.h. du wirst voraussichtlich zwischen DelphiMax und deinem Memo noch eine extra Schicht einfügen, die genau diese Filterung erledigt ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 09:07 
Hmm.. das wäre eine gute Idee... Habe schon Probiert einfach mit Sleep eine Zeit zu Warten... usw usw...

Doch meistens hängt er sich dann auf... Wie hast du dir das vorgestellt?

Mit einer repeat schlaufe?

Danke übrigens für die schnelle Antwort :-)
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Di 03.01.06 09:09 
zeig doch mal wie du die zeilen in das memofeld einfügst.

_________________
Ein Nutzer der Ecke ;-)
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 09:19 
Hallo Martin,

Dies ist erst ein kleines Programm, damit ich einmal sehen kann wie er funktioniert...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.Button1Click(Sender: TObject);
begin
DosCommand1.CommandLine := 'U:\delphimax.exe';  //Programm wird gestartet
DosCommand1.Execute;
DosCommand1.SendLine('uci \n',true);           //Befehl zum initialisieren des Protokolls
DosCommand1.SendLine('debug',true);
DosCommand1.SendLine('isready \n',true);       //Ab jetzt geht das Schachspiel los
DosCommand1.SendLine('position moves e2e4 \n',true);    //Erste zug
DosCommand1.SendLine('go', true);                       //Sagt dem Programm, dass es zu Rechnen beginnen Soll
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
DosCommand1 := TDOSCommand.Create(self);
DosCommand1.OutputLines:=Memo1.Lines;           //DosCommand Output wird in Memo angezeigz
Edit1.Text:= 'position moves e7e5';              //Test
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
DosCommand1.SendLine(Edit1.Text,true);         //So soll er den nächsten Zug machen
end;


Die repeatschlaufe habe ich jetzt noch nicht Probiert... aber mit diesem Code wird eigentlich alles angezeigt...

Hoffentlich Hilft es weiter...

Pascal
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Di 03.01.06 09:36 
Das Problem hier ist eigentlich diese Zeile:
ausblenden Delphi-Quelltext
1:
DosCommand1.OutputLines:=Memo1.Lines;					

Damit gibst du an das die Komponente DosCommand1 ihre Ausgabe in das Memo1 schreiben soll und zwar alles.

Ich kenne die TDosCommand Komponente nicht. Zeig mir doch mal welche Events die Komponente zur Verfügung stellt. Vielleicht gibt es ja ein Event welches für jede Zeile der Ausgabe aufgerufen wird.

lg Martin

_________________
Ein Nutzer der Ecke ;-)
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 09:41 
Es gibt nur zwei Events... OnNewLine und OnTerminated.

Mit der OnNewLine könnte ich arbeiten, wenn ich dem Protokoll Mitteile das es mir nur immer den Bestmove zurück gibt.
(Ich finde es sollte möglich sein, denn mit all dem andern Hashtable schrott kann man ja e nix anfangen... Ich habe
diesen Befehl jedoch noch nirgend gefunden.. und schon sehr lange gesucht...)


Was meinst du... ist es möglich mit repeat eine lösung zu finden?
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Di 03.01.06 09:50 
user profile iconLago hat folgendes geschrieben:
Mit der OnNewLine könnte ich arbeiten, wenn ich dem Protokoll Mitteile das es mir nur immer den Bestmove zurück gibt.

Dann arbeite doch mit OnNewLine. Ich gehe mal davon aus, das OnNewLine einen Parameter vom Typ String besitzt. Dann machst du einfach:
ausblenden Delphi-Quelltext
1:
2:
If Pos ('Bestmove', aString) > 0 Then
  Memo1.Lines.Add (aString);



user profile iconLago hat folgendes geschrieben:
(Ich finde es sollte möglich sein, denn mit all dem andern Hashtable schrott kann man ja e nix anfangen... Ich habe diesen Befehl jedoch noch nirgend gefunden.. und schon sehr lange gesucht...)

Was haben Hashtabellen mit diesem Problem zu tun?

user profile iconLago hat folgendes geschrieben:
Was meinst du... ist es möglich mit repeat eine lösung zu finden?

Warum willst du Repeat verwenden?

Lg Martin

_________________
Ein Nutzer der Ecke ;-)
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 10:05 
So.. Erst einmal Danke Martin... du bist mir bereits das 2te mal eine Riiiiiiiiieeeeesssseeennn hilfe. ;-)
Habe auch noch ein 3tes Problem... aber das erzähle ich erst, wenn das andere funzt. hehe...

Ich habe einmal den Code ein wenig sauberer Dargestellt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
procedure TForm1.UCIinit;
begin
with DosCommand1 do
  begin
  CommandLine := 'engine/delphimax29.exe';  //Programm wird gestartet
  Execute;
  SendLine('uci \n',true);           //Befehl zum initialisieren des Protokolls
  SendLine('debug',true);
  SendLine('isready \n',true);       //Ab jetzt geht das Schachspiel los
  end;
end;

function TForm1.Compziehen (Zug: string) :string;
var letzteZeile: string;
begin
with DosCommand1 do
  begin
  SendLine('position moves' + Zug +  '\n',true);   //Befehl zum Ziehen wird erteilt
  SendLine('go', true);                      //Der Computer soll sein Zug berechnen
  end;
  {Als Result soll jetzt die letzte Zeile, resp der Zug zurückgegeben werden}
end;


Ich dachte mit einer Repeat-Schleife kann ich so lange abfragen bis die letzte Zeile des Memos mit 'bestmove' beginnt.
Das geht aber nicht. Mir ist eigentlich egal wie viele Zeilen der Computer zum berechnen des nächsten Zuges benötigt...
Wenn dieser einfach Fertig ist... und die letzte Zeile 'bestmove e4e6' heisst, dass will ich das e4e6 zurückgeben.

Um einmal einen kleinen Einblick zu bekommen... Hier siehst du was beim Start alles berechnet wird:
ausblenden volle Höhe 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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
id name DelphiMAX 2.9
id author Martin Bauer
option name Hash type spin default 12 min 1 max 100
option name Ponder type check default true
option name Selektiv type spin default 7 min 1 max 10
option name NullMoveExtension type check default true
option name NullMove type check default true
option name Hashing type check default true
option name Pawnhashing type check default true
option name Clear Hash type button
uciok
readyok
info depth 1 seldepth 1
info score cp 19 depth 1 seldepth 1 nodes 22 pv d2d4
info score cp 0 depth 2 seldepth 4 nodes 103 pv d2d4 d7d5
info score cp 16 depth 3 seldepth 8 nodes 373 pv d2d4 d7d5 b1c3
info score cp 0 depth 4 seldepth 8 nodes 1743 pv d2d4 d7d5 b1c3 b8c6
info score cp 16 depth 5 seldepth 12 nodes 6924 pv d2d4 d7d5 b1c3 b8c6
info score cp 4 depth 6 seldepth 13 nodes 28613 pv e2e4 e7e5 g1f3 b8c6
info score cp 16 depth 7 seldepth 15 nodes 95245 pv e2e4 b8c6 g1f3 d7d5 e4d5 d8d5 b1c3 d5d8
info depth 8 seldepth 15
info nodes 95245 currmove e2e4 currmovenumber 1
info nodes 213710 currmove d2d4 currmovenumber 2
info nodes 234958 currmove b1c3 currmovenumber 3
info nodes 260145 currmove b1a3 currmovenumber 4
info nodes 260893 currmove g1f3 currmovenumber 5
info nodes 264529 currmove g1h3 currmovenumber 6
info nodes 265392 currmove a2a3 currmovenumber 7
info nodes 265834 currmove a2a4 currmovenumber 8
info nodes 266303 currmove b2b3 currmovenumber 9
info nodes 266775 currmove b2b4 currmovenumber 10
info nodes 267197 currmove c2c3 currmovenumber 11
info nodes 269212 currmove c2c4 currmovenumber 12
info nodes 275136 currmove d2d3 currmovenumber 13
info nodes 280010 currmove e2e3 currmovenumber 14
info nodes 292833 currmove f2f3 currmovenumber 15
info nodes 294494 currmove f2f4 currmovenumber 16
info nodes 294832 currmove g2g3 currmovenumber 17
info nodes 295224 currmove g2g4 currmovenumber 18
info nodes 295550 currmove h2h3 currmovenumber 19
info nodes 295836 currmove h2h4 currmovenumber 20
info score cp 10 depth 8 seldepth 18 nodes 296128 pv e2e4 e7e5 g1f3 g8f6 f3e5 f6e4 d2d3 f7f6
info depth 9 seldepth 18
info nodes 296128 currmove e2e4 currmovenumber 1
info pv e2e4 e7e6 b1c3 d7d5 d2d4 f8b4 e4d5 e6d5 g1e2 g8f6 score cp 12 depth 9 seldepth 21 nodes 1270633
info nodes 1270633 currmove d2d4 currmovenumber 2
info pv d2d4 score cp 13 depth 9 seldepth 21 nodes 1538369
info pv d2d4 g8f6 nodes 1726466 score cp 13 depth 9 seldepth 21
info nodes 1726466 currmove b1c3 currmovenumber 3
info nodes 1755290 currmove b1a3 currmovenumber 4
info nodes 1767446 currmove g1f3 currmovenumber 5
info nodes 1783822 currmove g1h3 currmovenumber 6
info nodes 1805393 currmove a2a3 currmovenumber 7
info nodes 1814795 currmove a2a4 currmovenumber 8
info nodes 1819866 currmove b2b3 currmovenumber 9
info nodes 1831613 currmove b2b4 currmovenumber 10
info nodes 1835441 currmove c2c3 currmovenumber 11
info nodes 1843596 currmove c2c4 currmovenumber 12
info nodes 1870413 currmove d2d3 currmovenumber 13
info nodes 1889794 currmove e2e3 currmovenumber 14
info nodes 1965218 currmove f2f3 currmovenumber 15
info nodes 1971350 currmove f2f4 currmovenumber 16
info nodes 1972450 currmove g2g3 currmovenumber 17
info nodes 1980634 currmove g2g4 currmovenumber 18
info nodes 1981931 currmove h2h3 currmovenumber 19
info nodes 1983616 currmove h2h4 currmovenumber 20
info score cp 13 depth 9 seldepth 21 nodes 1984154 pv d2d4 g8f6
info depth 10 seldepth 21
info nodes 1984154 currmove d2d4 currmovenumber 1
bestmove d2d4 ponder g8f6


Ich werde das mit OnNewLine gleich probieren.... Melde mich in ein paar min wieder.

DANKE!
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 10:24 
hmm... Ich kapier den Syntax nicht. Filtert er die Ausgabe des Protokolls so lange bis 'Bestmove' da ist?

Mein Event sieht so aus... (keine ahnung ob er stimmt)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.DosCommand1NewLine(Sender: TObject; NewLine: String; OutputType: TOutputType);
begin
If Pos ('Bestmove', NewLine) > 0 Then   Memo1.Lines.Add (NewLine);
end;
Vera
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82

WinXP Home
Delphi 2005 Personal
BeitragVerfasst: Di 03.01.06 10:27 
user profile iconLago hat folgendes geschrieben:
Mein Event sieht so aus... (keine ahnung ob er stimmt)

Probier es doch einfach aus. ;-)

Die Syntax jedefalls sieht korrekt aus.

bye Vera.
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 10:31 
Hab ich ja. :-)

Es passier leider gar nichts im Memo. Es sieht zwar aus als ob gerechnet wird... Aber übertragen ins Memo wird nichts.
Ich muss vielleicht noch einmal erwähnen... Mir ist egal wie viel in dem Memo steht..
Ich brauche einfach die Zeile: 'bestmove d2d4 ponder g8f6'

Und weil man nie sagen kann wie lange die Rechenzeit dauert, brauche in eine Abfrage. :-/
Vera
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82

WinXP Home
Delphi 2005 Personal
BeitragVerfasst: Di 03.01.06 10:45 
Liegt es vielleicht daran, dass
Zitat:
bestmove d2d4 ponder g8f6

ausgegeben wird aber du prüfst ob der String
Zitat:
Bestmove

enthalten ist. Siehst du den Unterschied? ;-)

Bye Vera
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 10:48 
Ja ich seh den Unterschied. ;-)

Nur wie überprüfe ich jetzt, ob 'bestmove **** ponder ****' enthalten ist?

Dem Zug kenn ich ja gar nicht... nur die Worte 'bestmove' und 'ponder' sind immer enthalten...

Merkt ihr... Ich hab keine Ahnung... :-)
Vera
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 82

WinXP Home
Delphi 2005 Personal
BeitragVerfasst: Di 03.01.06 10:54 
user profile iconLago hat folgendes geschrieben:
Merkt ihr... Ich hab keine Ahnung... :-)

Ne, ich merke nur, dass Du Deine Frage nicht gleich zu Anfang korrekt gestellt hast. ;-)

Du hast am Anfang geschrieben, dass Du die Zeile haben willst die "bestmove" enthält. Die von Martin genannte Lösung sollte zum gewünschten Ergebnis führen. Jetzt versuche doch erstmal diese Lösung bei dir zum laufen zu bringen.

Bye Vera.
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 11:01 
Martin hat das Zeug zu meinem PR Delphi-Gott... :-)

Nur leider wird nichts im Memo angezeigt... und den Syntax in der Form wie ihn mir Martin vorgeschlagen hat, kenn ich
noch nicht... deshalb komm ich nicht weiter.

Es zeigt keine Fehlermeldung an, er Rechnet... Alles Tip Top. Nur eben nach einer bestimmten Zeit sollte ja das Resultat angezeit werden... Leider nein.
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Di 03.01.06 11:10 
Hast du den Hinweis von Vera (vier Postings weiter oben) gelesen? Du musst die Funktion Pos wie folgt aufrufen:

ausblenden Delphi-Quelltext
1:
Pos ('bestmove', NewLine)					


Lg Martin

_________________
Ein Nutzer der Ecke ;-)
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 11:13 
Falls du wegen der Gross/Kleinschreibung meinst... JA! ;-)

Wird bei dieser Abfrage geprüft ob nur 'bestmove' vorhanden ist, oder ob das WOrt 'bestmove' erhalten sit?
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Di 03.01.06 11:16 
Schau doch mal in die Delphi-Hilfe was diese zu der Funktion Pos schreibt:

Zitat:
Die Funktion gibt den Indexwert des ersten Zeichens innerhalb des angegebenen Teil-Strings zurück, der in einem String vorkommt.


Du kannst auch mal versuchen zu debuggen. Also einen Breakpoint auf die POS-Zeile setzen (F5) und dann mal schauen welcher String reinkommt, diesen vergleichen, schauen ob welchen Rückgabewert die Funktion Pos liefert, ...

Lg Martin

_________________
Ein Nutzer der Ecke ;-)
Lago Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 03.01.06 11:17 
Habe das Bestmove schon beim Einfügen korrigiert... nur geht leider immer noch nichts... :-(