function PVSearch (alpha,beta:integer; prof:byte; var meilleur:coup) :integer; {Principal Variation Search, combinant AlphaBeta et Scout} var Resultat,Maximum: integer; Ci,Reponse:coup; Premier:boolean; begin Maximum:=-32000; {plus petit que tout résultat d'évaluation} [*** cherche et classe tous les coups ***] Ci:= PremierCoup; Premier:=true; repeat jouer(Ci); if (prof=1) then Resultat:=-evalue else if premier then begin {on évalue le premier coup} Resultat:=-PVSearch(-beta,-alpha,prof-1, reponse); Premier:=false; end else begin {les autres coups} Resultat:=-zeroWindow(-succ(alpha),prof-1); {on espionne} if (alpha2) then Resultat:=-PVSearch(-beta,-Resultat,prof-1, reponse); {si nécessaire on affine la mesure} end; dejoue(Ci); if (Resultat>Maximum) then begin Maximum:=Resultat; Meilleur:=Ci; end; {if} if (Resultat>alpha) then alpha:=resultat; Ci:=CoupSuivant; until PlusDeCoups or (alpha>=beta); PVSearch:=Maximum; end;