public virtual BlockPath GetMove(Field field, Field opponent, Block current, Block next, int round) { Logs.Clear(); Pars = new ApplyParameters(Rnd) { Garbage = field.Points / 3, Round = round, MaximumDuration = MaximumDuration, MaximumDepth = MaximumDepth, Evaluator = Evaluator, Generator = Generator, Current = current, Next = next, FirstFilled = field.FirstFilled, Parameters = DefaultEvaluation, }; var oppo = new OpponentEvaluator() { Generator = Pars.Generator }; Pars.Opponent = oppo.Evaluate(opponent, current, next); var move = BlockPath.None; Root = new BlockRootNode(field); // search at least two ply deep. while ((Pars.Depth < 2 || (Pars.Depth < Pars.MaximumDepth && Pars.Elapsed < MinimumDuration)) // Cut if we have a win in 1 or two. && Root.Score != Scores.Wins(Pars.Depth)) { Root.Apply(++Pars.Depth, Pars); Logs.Add(new PlyLog(Pars.Round, Root.BestMove, Root.Score, Pars.Depth, Pars.Elapsed, Pars.Evaluations)); } BestField = Root.BestField; return Root.BestMove; }
public virtual BlockPath GetMove(Field field, Field opponent, Block current, Block next, int round) { Logs.Clear(); Pars = new ApplyParameters(Rnd) { Garbage = field.Points / 3, Round = round, MaximumDuration = MaximumDuration, MaximumDepth = MaximumDepth, Evaluator = Evaluator, Generator = Generator, Current = current, Next = next, FirstFilled = field.FirstFilled, Parameters = DefaultEvaluation, }; var oppo = new OpponentEvaluator() { Generator = Pars.Generator }; Pars.Opponent = oppo.Evaluate(opponent, current, next); var move = BlockPath.None; Root = new BlockRootNode(field); // search at least two ply deep. while ((Pars.Depth < 2 || (Pars.Depth < Pars.MaximumDepth && Pars.Elapsed < MinimumDuration)) // Cut if we have a win in 1 or two. && Root.Score != Scores.Wins(Pars.Depth)) { Root.Apply(++Pars.Depth, Pars); Logs.Add(new PlyLog(Pars.Round, Root.BestMove, Root.Score, Pars.Depth, Pars.Elapsed, Pars.Evaluations)); } BestField = Root.BestField; return(Root.BestMove); }