HasOneBite() public method

public HasOneBite ( Point currentPoint ) : bool
currentPoint System.Drawing.Point
return bool
        public void BuildIsEmptyTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var creatures = new bool[2, 2];

            for (int i = 0; i < eatMatrix.Length; i++)
                for (int j = 0; j < eatMatrix.Height; j++)
                    creatures[i, j] = true;

            eatMatrix.Build(creatures);
            for (int i = 0; i < eatMatrix.Length; i++)
                for (int j = 0; j < eatMatrix.Height; j++)
                    Assert.IsFalse(eatMatrix.HasOneBite(new Point(i, j)));
        }
Esempio n. 2
0
 protected override DirectionEnum GetDirection(FoodMatrix eatMatrix, Membrane[,] creatures, Point position, Random random)
 {
     var points = CommonMethods.GetPoints(position);
     var directions = new List<DirectionEnum>();
     var directionsWithFood = new List<DirectionEnum>();
     foreach (var item in points)
     {
         if (!CommonMethods.IsValidAndFree(item, creatures)) continue;
         directions.Add(DirectionEx.DirectionByPoints(position, item));
         if(eatMatrix.HasOneBite(item))
             directionsWithFood.Add(DirectionEx.DirectionByPoints(position, item));
     }
     if (directions.Count == 0) return DirectionEnum.Stay;
     return directionsWithFood.Count == 0 ? directions.ElementAt(random.Next(directions.Count)) : directionsWithFood.ElementAt(random.Next(directionsWithFood.Count));
 }
Esempio n. 3
0
        protected override DirectionEnum GetDirection(FoodMatrix eatMatrix, 
            Membrane[,] creatures, Point position, Random random)
        {
            var points = CommonMethods.GetPoints(position);
            var state = new Dictionary<int, int>();

            foreach (var point in points)
            {
                var direction = DirectionEx.DirectionByPointsWithNumber(position, point);

                if (CommonMethods.IsValidAndFree(point, creatures))
                    state.Add(direction, eatMatrix.HasOneBite(point) ? 4 : 3);

                if (!CommonMethods.IsValid(point, eatMatrix.Length, eatMatrix.Height))
                    state.Add(direction, 1);
                else
                    if (!CommonMethods.IsFree(point, creatures))
                        state.Add(direction, 2);
            }

            var result = _executor.Execute(CommandsForGetDirection, new MyExecutorToolset(random, state));

            return DirectionEx.DirectionByNumber(int.Parse(result));
        }
Esempio n. 4
0
 private bool HasOneBite(FoodMatrix eatMatrix)
 {
     return eatMatrix.HasOneBite(Position);
 }