public void InitializeBrains(IEnumerable <IBrain> brains, IBallSet ballSet) { foreach (var brain in brains) { brain.Initialize(ballSet.CueBalls.First()); } }
public double GetScore(ITable table, IBallSet ballSet) { if (ballSet.CueBalls.Any(b => !b.InGame)) { return(double.NegativeInfinity); } if (ballSet.CueBalls.Any(b => !b.HasHitSomething)) { return(0); } //normalize target discances and sum double score = ballSet.Balls.Select(b => table.TargetLocations.Max(t => 1 - GeometryUtils.Distance(b.Position, t) / s_MaximumMinimumTargetDistance)).Average(); //adjust score accordingly with the number of ball in game return(score + ballSet.Balls.Count(b => !b.InGame)); }
public bool HasWin(IBallSet ballSet) { return(ballSet.CueBalls.All(b => b.InGame) && ballSet.Balls.Except(ballSet.CueBalls).All(b => !b.InGame)); }
public bool IsOver(IBallSet ballSet) { return(ballSet.CueBalls.All(b => !b.InGame) || HasWin(ballSet)); }