diff --git a/alouette.pas b/alouette.pas index ed9436c..8219643 100644 --- a/alouette.pas +++ b/alouette.pas @@ -54,7 +54,7 @@ procedure TSearchThread.Execute; if not Terminated then begin Send(Format('bestmove %s', [LMove])); - Log.Append(Format('Meilleur coup trouvé en %0.3f s.', [LTimeUsed / 1000])); + Log.Append(Format('Meilleur coup trouvé en %0.3f s.', [LTimeUsed / 1000]), TRUE); end; end; @@ -163,15 +163,16 @@ procedure TSearchThread.Execute; with LThread do begin FreeOnTerminate := TRUE; - Priority := tpHigher; + //Priority := tpHigher; + Priority := tpNormal; Start; end; end else if LCmd = 'stop' then begin - Send(Format('bestmove %s', [Player.InstantMove])); if Assigned(LThread) then LThread.Terminate; + Send(Format('bestmove %s', [Player.InstantMove])); end else if BeginsWith('setoption name UCI_Chess960 value ', LCmd) then SetVariant(WordPresent('true', LCmd)) diff --git a/best.pas b/best.pas index 580743c..6a69252 100644 --- a/best.pas +++ b/best.pas @@ -274,7 +274,9 @@ function GetBestMove(const APos: TPosition; const AVariant: boolean; const ATime for i := 0 to Pred(n) do LEval[i] := PositionalEval(APos, LListe[i]); SortMoves(LListe, LEval, n); - LMove := LListe[0]; + //LMove := LListe[0]; + n := CountBestMoves(LEval, n); + LMove := LListe[Random(n)]; if IsCastling(APos, LMove) and not AVariant then begin Assert(((LMove and $FF00) shr 8) mod 8 = CColE); diff --git a/castling.pas b/castling.pas index 2b3072e..f7bd561 100644 --- a/castling.pas +++ b/castling.pas @@ -46,7 +46,7 @@ procedure Search(const AKingTarget, ARookTarget: integer); { Colonnes d'arrivée k := ToIndex(AKingTarget, LRow); j := ToIndex(LRookStart, LRow); l := ToIndex(ARookTarget, LRow); - Log.Append(Format('Vérifications pour roi %s tour%s...', [MoveToStr(i, k), MoveToStr(j, l)])); + Log.Append(Format('Vérifications pour roi %s tour %s...', [MoveToStr(i, k), MoveToStr(j, l)])); if IsOn(APos.Pieces[APos.SideToMove] and APos.Rooks, CIndexToSquare[j]) then Log.Append('Position tour vérifiée (condition 1/3).') else diff --git a/player.pas b/player.pas index 0bc8f67..9caf86a 100644 --- a/player.pas +++ b/player.pas @@ -14,7 +14,7 @@ interface procedure Reset; procedure LoadStartPosition; procedure DoMove(const AMove: string); -function BestMove(const ATimeForMove: integer): string; +function BestMove(const ATimeAvailable: integer): string; function InstantMove: string; procedure SetVariant(const AValue: boolean); function CurrentVariant: boolean; @@ -32,38 +32,41 @@ implementation procedure Reset; begin + //Log.Append(Format('%s %s %s', [{$I %FILE%}, {$I %LINE%}, 'Reset'])); LPos := CZeroPosition; end; procedure LoadStartPosition; begin + //Log.Append(Format('%s %s %s', [{$I %FILE%}, {$I %LINE%}, 'LoadStartPosition'])); LPos := EncodePosition; NewHistory; end; procedure DoMove(const AMove: string); begin + //Log.Append(Format('%s %s %s(%s)', [{$I %FILE%}, {$I %LINE%}, 'DoMove', AMove])); if TryDoMove(LPos, AMove) then History.AppendMove(AMove) else - Log.Append(Format('ImIsMovePossible de jouer %s.', [AMove])); + Log.Append(Format('Impossible de jouer %s.', [AMove])); end; -function BestMove(const ATimeForMove: integer): string; +function BestMove(const ATimeAvailable: integer): string; begin - result := GetBestMove(LPos, LVariant, ATimeForMove); + //Log.Append(Format('%s %s %s(%d)', [{$I %FILE%}, {$I %LINE%}, 'BestMove', ATimeAvailable])); + result := GetBestMove(LPos, LVariant, ATimeAvailable); end; function InstantMove: string; begin + //Log.Append(Format('%s %s %s', [{$I %FILE%}, {$I %LINE%}, 'InstantMove'])); result := LTempMove; end; procedure SetVariant(const AValue: boolean); -const - CPrefix: array[boolean] of string = ('dés', ''); begin - Log.Append(Format('Option échecs 960 %sactivée.', [CPrefix[AValue]])); + Log.Append(Format('%s %s %s(%d)', [{$I %FILE%}, {$I %LINE%}, 'SetVariant', Ord(AValue)])); LVariant := AValue; end; @@ -74,6 +77,7 @@ function CurrentVariant: boolean; procedure SetPosition(const APos: string); begin + //Log.Append(Format('%s %s %s(%s)', [{$I %FILE%}, {$I %LINE%}, 'SetPosition', APos])); LPos := EncodePosition(APos, LVariant); NewHistory; end;