0

There is a code implements function which assigned every status a value (both parts of min-max method)

Procedure TGraph.Rate(const AState: TState);
Var
i: integer;
Begin //hodnotí stav
if AState.Children.Count > 0 then begin //není list
    if AState.Owner = CComputerPlayer then begin
        // max level
        AState.Rating := AState.Children.Worst.Rating;
    end else begin
        // min level
        AState.Rating := AState.Children.Best.Rating;
    end;
end else begin
    AState.Rating := 0;
    for i := 0 to AState.Fields.Count - 1 do
    begin
        AState.Rating := AState.Rating +
        AState.Fields.FieldsI[i].Rating[AState.Owner];
    end;
    if (AState.Owner = CHumanPlayer) then begin
        AState.Rating := -AState.Rating;
    end;
end;
End;
Seda
  • 103
  • 2
  • 12
  • Is is a bit unclear what's being asked here; do you look for an algorithm which is better? Better in what sense? – Codor Mar 31 '14 at 10:58
  • I cringed at that artificial-intelligence tag. well, in an era where phones are "smart"... who am I to judge. – Karoly Horvath Mar 31 '14 at 11:04

1 Answers1

1

Tic Tac Toe has a finite and quite small space of possible positions. It is not worth it to apply alfa-beta pruning for it. A very simple min-max will work very fast. Also keep in mind if you need to run the algorithm multiple times you can run min-max only once and store the computed results.

Ivaylo Strandjev
  • 69,226
  • 18
  • 123
  • 176