Example #1
0
 public static IntMove ApplyGravity(IntMove source, IntMove target)
 {
     if (source.X > target.X)
     {
         target.VX++;
     }
     if (source.X < target.X)
     {
         target.VX--;
     }
     if (source.Y > target.Y)
     {
         target.VY++;
     }
     if (source.Y < target.Y)
     {
         target.VY--;
     }
     if (source.Z > target.Z)
     {
         target.VZ++;
     }
     if (source.Z < target.Z)
     {
         target.VZ--;
     }
     return(target);
 }
Example #2
0
        public static IntMove ParseVector(string vectorInput)
        {
            var vectorArray = vectorInput.Split(',').Select(StripBraces).Select(StripName).ToArray();
            var a           = new IntMove {
                X = vectorArray[0], Y = vectorArray[1], Z = vectorArray[2]
            };

            return(a);
        }
Example #3
0
        public static IntMove UpdateWithGravity(IntMove a, IEnumerable <IntMove> l)
        {
            var influencers = l.Except(new[] { a }).ToArray();
            var target      = a;

            foreach (var source in influencers)
            {
                target = ApplyGravity(source, target);
            }

            return(target);
        }
Example #4
0
 public static int CalcPotOne(IntMove a)
 {
     return(Math.Abs(a.X) + Math.Abs(a.Y) + Math.Abs(a.Z));
 }
Example #5
0
 public static int CalcKinOne(IntMove a)
 {
     return(Math.Abs(a.VX) + Math.Abs(a.VY) + Math.Abs(a.VZ));
 }