Ejemplo n.º 1
0
 public void InitializeBrains(IEnumerable <IBrain> brains, IBallSet ballSet)
 {
     foreach (var brain in brains)
     {
         brain.Initialize(ballSet.CueBalls.First());
     }
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public bool HasWin(IBallSet ballSet)
 {
     return(ballSet.CueBalls.All(b => b.InGame) && ballSet.Balls.Except(ballSet.CueBalls).All(b => !b.InGame));
 }
Ejemplo n.º 4
0
 public bool IsOver(IBallSet ballSet)
 {
     return(ballSet.CueBalls.All(b => !b.InGame) || HasWin(ballSet));
 }