public static long Solve(IEnumerable <string> input, int stepsCount = 1000) { var moons = input.Select(Moon.Parse).ToArray(); var positionX = moons.Select(i => i.X).ToArray(); var positionY = moons.Select(i => i.Y).ToArray(); var positionZ = moons.Select(i => i.Z).ToArray(); var velocityX = new int[moons.Length]; var velocityY = new int[moons.Length]; var velocityZ = new int[moons.Length]; for (var i = 0; i < stepsCount; i++) { Moon.ApplyGravity(positionX, velocityX); Moon.ApplyGravity(positionY, velocityY); Moon.ApplyGravity(positionZ, velocityZ); Moon.ApplyVelocity(positionX, velocityX); Moon.ApplyVelocity(positionY, velocityY); Moon.ApplyVelocity(positionZ, velocityZ); } var result = 0L; for (var i = 0; i < positionX.Length; i++) { long potential = Math.Abs(positionX[i]) + Math.Abs(positionY[i]) + Math.Abs(positionZ[i]); long kinetic = Math.Abs(velocityX[i]) + Math.Abs(velocityY[i]) + Math.Abs(velocityZ[i]); result += (potential * kinetic); } return(result); }
private static int FindLoopLength(int[] positions) { var velocity = new int[positions.Length]; var originalPositions = positions.ToArray(); var stepsCount = 0; var finish = false; while (!finish) { stepsCount++; Moon.ApplyGravity(positions, velocity); Moon.ApplyVelocity(positions, velocity); finish = true; for (var i = 0; i < positions.Length; i++) { if (positions[i] != originalPositions[i] || velocity[i] != 0) { finish = false; break; } } } return(stepsCount); }
public void ChangeV(Moon other) { if (x < other.x) { ++vx; } if (x > other.x) { --vx; } if (y < other.y) { ++vy; } if (y > other.y) { --vy; } if (z < other.z) { ++vz; } if (z > other.z) { --vz; } }
//Should really just parse these. //Input //<x=-6, y=2, z=-9> //<x=12, y=-14, z=-4> //<x=9, y=5, z=-6> //<x=-1, y=-4, z=9> //Test1 //<x=-1, y=0, z=2> //<x=2, y=-10, z=-7> //<x=4, y=-8, z=8> //<x=3, y=5, z=-1> static void Main() { ////input Moon[] moons = new Moon[] { new Moon('I', new Vector3(-6, 2, -9)), new Moon('E', new Vector3(12, -14, -4)), new Moon('G', new Vector3(9, 5, -6)), new Moon('C', new Vector3(-1, -4, 9)) }; //test1 //Moon[] moons = new Moon[] //{ // new Moon('I', new Vector3(-1, 0, 2)), // new Moon('E', new Vector3(2, -10, -7)), // new Moon('G', new Vector3(4, -8, 8)), // new Moon('C', new Vector3(3, 5, -1)) //}; //int steps = 1000; // 2772 is the steps for the test moons = ProcessOrbit(moons); //Part1 //float enargy = 0; //foreach (Moon m in moons) //{ // enargy += m.GetEnargy(); //} //Console.WriteLine(String.Format("Enargy in system: {0}", enargy.ToString())); Console.ReadLine(); }
public void UpdateVel(Moon other) { if (other.x > x) { vx++; } else if (other.x < x) { vx--; } if (other.y > y) { vy++; } else if (other.y < y) { vy--; } if (other.z > z) { vz++; } else if (other.z < z) { vz--; } }
public MoonSystem(Moon _a, Moon _b, Moon _c, Moon _d) { a = _a; b = _b; c = _c; d = _d; }
public void ApplyGravity(Moon interactingMoon) { if (interactingMoon.Position.X > Position.X) { Velocity.X++; } else if (interactingMoon.Position.X < Position.X) { Velocity.X--; } if (interactingMoon.Position.Y > Position.Y) { Velocity.Y++; } else if (interactingMoon.Position.Y < Position.Y) { Velocity.Y--; } if (interactingMoon.Position.Z > Position.Z) { Velocity.Z++; } else if (interactingMoon.Position.Z < Position.Z) { Velocity.Z--; } }
static Moon[] createListOfMoons(List <List <int> > inputList) { Moon[] listOfMoons = new Moon[4]; for (int i = 0; i < 4; i++) { listOfMoons[i] = new Moon(inputList[i]); } return(listOfMoons); }
private void ApplyGravityInternal(Moon a, Moon b) { int diff = a.Position.X - b.Position.X; a.Velocity.X += (diff < 0) ? 1 : (diff > 0 ? -1 : 0); diff = a.Position.Y - b.Position.Y; a.Velocity.Y += (diff < 0) ? 1 : (diff > 0 ? -1 : 0); diff = a.Position.Z - b.Position.Z; a.Velocity.Z += (diff < 0) ? 1 : (diff > 0 ? -1 : 0); }
static void UpdateAllVelocities(Moon[] moons) { for (int i = 0; i < moons.Length; i++) { Moon a = moons[i]; for (int j = i + 1; j < moons.Length; j++) { Moon b = moons[j]; Moon.UpdateVelocities(a, b); } } }
public void ApplyGravity(Dimension dimension, Moon moon) { if (Position[dimension] < moon.Position[dimension]) { Velocity[dimension] += 1; moon.Velocity[dimension] -= 1; } if (Position[dimension] > moon.Position[dimension]) { Velocity[dimension] -= 1; moon.Velocity[dimension] += 1; } }
static void ComperMoonsZ(Moon moonA, Moon moonB) { //need three way logic here for ==s int vz = 0; vz = moonA.Postion.Z < moonB.Postion.Z ? 1 : -1; vz = moonA.Postion.Z == moonB.Postion.Z ? 0 : vz; Vector3 va = new Vector3(0, 0, vz); moonA.AddVelocity(va); Vector3 vb = new Vector3(0, 0, vz * -1); moonB.AddVelocity(vb); }
//Axises are indepent so we should split this out really //Just doing one for testing now static void ComperMoonsX(Moon moonA, Moon moonB) { //need three way logic here for ==s int vx = 0; vx = moonA.Postion.X < moonB.Postion.X ? 1 : -1; vx = moonA.Postion.X == moonB.Postion.X ? 0 : vx; Vector3 va = new Vector3(vx, 0, 0); moonA.AddVelocity(va); Vector3 vb = new Vector3(vx * -1, 0, 0); moonB.AddVelocity(vb); }
public override void First() { Moon[] moons = new Moon[] { new Moon(14, 2, 8), new Moon(7, 4, 10), new Moon(1, 17, 16), new Moon(-4, -1, 1) }; for (int i = 0; i < 1000; i++) { Step(moons); } var totalEnergy = moons.Sum(m => m.PotentialEnergy * m.KineticEnergy); Echo($"Total energy after 1000 steps: {totalEnergy}"); ValidateAnswer(totalEnergy, 9139); }
static void ComperMoonsY(Moon moonA, Moon moonB) { //need three way logic here for ==s int vy = 0; vy = moonA.Postion.Y < moonB.Postion.Y ? 1 : -1; vy = moonA.Postion.Y == moonB.Postion.Y ? 0 : vy; Vector3 va = new Vector3(0, vy, 0); moonA.AddVelocity(va); Vector3 vb = new Vector3(0, vy * -1, 0); moonB.AddVelocity(vb); }
static List <Moon> Parse(string[] lines) { var moons = new List <Moon>(); var regex = new Regex(@"<x=(?<x>(.+?)), y=(?<y>(.+?)), z=(?<z>(.+?))>"); foreach (var l in lines) { var match = regex.Match(l); var g = match.Groups; var m = new Moon(); m.Position = new Vec3( int.Parse(g["x"].Value), int.Parse(g["y"].Value), int.Parse(g["z"].Value)); moons.Add(m); } return(moons); }
static void updateVelocities(Moon moonOne, Moon moonTwo, int i) { Tuple <int, int>[] posn = new Tuple <int, int> [3]; posn[0] = new Tuple <int, int>(moonOne.Px, moonTwo.Px); posn[1] = new Tuple <int, int>(moonOne.Py, moonTwo.Py); posn[2] = new Tuple <int, int>(moonOne.Pz, moonTwo.Pz); if (posn[i].Item1 != posn[i].Item2) { if (posn[i].Item1 < posn[i].Item2) { moonOne.updateVelocity(i, 1); moonTwo.updateVelocity(i, -1); } else if (posn[i].Item1 > posn[i].Item2) { moonOne.updateVelocity(i, -1); moonTwo.updateVelocity(i, 1); } } }
// runs forever.. public void Second() { Moon[] moons = new Moon[] { new Moon(14, 2, 8), new Moon(7, 4, 10), new Moon(1, 17, 16), new Moon(-4, -1, 1) }; Step(moons); var step = 1L; while (!Repeat(moons)) //while (!moons.All(m => m.Repeat)) { Step(moons); step++; if (step % 1000000 == 0) { Console.Write('.'); } } Echo($"Number of steps {step}"); }
public void ApplyVelocity(Moon m) { m.X += m.vX; m.Y += m.vY; m.Z += m.vZ; }
public void part1test2() { var moons = new[] { Moon.Parse("<x=-8, y=-10, z=0>"), Moon.Parse("<x=5, y=5, z=10>"), Moon.Parse("<x=2, y=-7, z=3>"), Moon.Parse("<x=9, y=-8, z=-3>") }; //After 0 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-8, y=-10, z=0>, vel=<x=0, y=0, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=5, y=5, z=10>, vel=<x=0, y=0, z=0>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=2, y=-7, z=3>, vel=<x=0, y=0, z=0>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=9, y=-8, z=-3>, vel=<x=0, y=0, z=0>")); Repeat(10, () => Step(moons)); //After 10 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-9, y=-10, z=1>, vel=<x=-2, y=-2, z=-1>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=4, y=10, z=9>, vel=<x=-3, y=7, z=-2>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=8, y=-10, z=-3>, vel=<x=5, y=-1, z=-2>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=5, y=-10, z=3>, vel=<x=0, y=-4, z=5>")); Repeat(10, () => Step(moons)); //After 20 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-10, y=3, z=-4>, vel=<x=-5, y=2, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=5, y=-25, z=6>, vel=<x=1, y=1, z=-4>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=13, y=1, z=1>, vel=<x=5, y=-2, z=2>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=0, y=1, z=7>, vel=<x=-1, y=-1, z=2>")); Repeat(10, () => Step(moons)); //After 30 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=15, y=-6, z=-9>, vel=<x=-5, y=4, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=-4, y=-11, z=3>, vel=<x=-3, y=-10, z=0>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=0, y=-1, z=11>, vel=<x=7, y=4, z=3>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=-3, y=-2, z=5>, vel=<x=1, y=2, z=-3>")); Repeat(10, () => Step(moons)); //After 40 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=14, y=-12, z=-4>, vel=<x=11, y=3, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=-1, y=18, z=8>, vel=<x=-5, y=2, z=3>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=-5, y=-14, z=8>, vel=<x=1, y=-2, z=0>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=0, y=-12, z=-2>, vel=<x=-7, y=-3, z=-3>")); Repeat(10, () => Step(moons)); //After 50 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-23, y=4, z=1>, vel=<x=-7, y=-1, z=2>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=20, y=-31, z=13>, vel=<x=5, y=3, z=4>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=-4, y=6, z=1>, vel=<x=-1, y=1, z=-3>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=15, y=1, z=-5>, vel=<x=3, y=-3, z=-3>")); Repeat(10, () => Step(moons)); //After 60 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=36, y=-10, z=6>, vel=<x=5, y=0, z=3>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=-18, y=10, z=9>, vel=<x=-3, y=-7, z=5>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=8, y=-12, z=-3>, vel=<x=-2, y=1, z=-7>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=-18, y=-8, z=-2>, vel=<x=0, y=6, z=-1>")); Repeat(10, () => Step(moons)); //After 70 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-33, y=-6, z=5>, vel=<x=-5, y=-4, z=7>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=13, y=-9, z=2>, vel=<x=-2, y=11, z=3>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=11, y=-8, z=2>, vel=<x=8, y=-6, z=-7>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=17, y=3, z=1>, vel=<x=-1, y=-1, z=-3>")); Repeat(10, () => Step(moons)); //After 80 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=30, y=-8, z=3>, vel=<x=3, y=3, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=-2, y=-4, z=0>, vel=<x=4, y=-13, z=2>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=-18, y=-7, z=15>, vel=<x=-8, y=2, z=-2>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=-2, y=-1, z=-8>, vel=<x=1, y=8, z=0>")); Repeat(10, () => Step(moons)); //After 90 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-25, y=-1, z=4>, vel=<x=1, y=-3, z=4>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=2, y=-9, z=0>, vel=<x=-3, y=13, z=-1>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=32, y=-8, z=14>, vel=<x=5, y=-4, z=6>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=-1, y=-2, z=-8>, vel=<x=-3, y=-6, z=-9>")); Repeat(10, () => Step(moons)); //After 100 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=8, y=-12, z=-9>, vel=<x=-7, y=3, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=13, y=16, z=-3>, vel=<x=3, y=-11, z=-5>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=-29, y=-11, z=-1>, vel=<x=-3, y=7, z=4>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=16, y=-13, z=23>, vel=<x=7, y=1, z=1>")); Assert.That(GetTotalEnergy(moons), Is.EqualTo(1940)); }
public void part1test1() { var moons = new[] { Moon.Parse("<x=-1, y=0, z=2>"), Moon.Parse("<x=2, y=-10, z=-7>"), Moon.Parse("<x=4, y=-8, z=8>"), Moon.Parse("<x=3, y=5, z=-1>") }; Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-1, y=0, z=2>, vel=<x=0, y=0, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=2, y=-10, z=-7>, vel=<x=0, y=0, z=0>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=4, y=-8, z=8>, vel=<x=0, y=0, z=0>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=3, y=5, z=-1>, vel=<x=0, y=0, z=0>")); Step(moons); Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=2, y=-1, z=1>, vel=<x=3, y=-1, z=-1>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=3, y=-7, z=-4>, vel=<x=1, y=3, z=3>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=1, y=-7, z=5>, vel=<x=-3, y=1, z=-3>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=2, y=2, z=0>, vel=<x=-1, y=-3, z=1>")); Step(moons); //After 2 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=5, y=-3, z=-1>, vel=<x=3, y=-2, z=-2>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=1, y=-2, z=2>, vel=<x=-2, y=5, z=6>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=1, y=-4, z=-1>, vel=<x=0, y=3, z=-6>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=1, y=-4, z=2>, vel=<x=-1, y=-6, z=2>")); Step(moons); //After 3 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=5, y=-6, z=-1>, vel=<x=0, y=-3, z=0>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=0, y=0, z=6>, vel=<x=-1, y=2, z=4>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=2, y=1, z=-5>, vel=<x=1, y=5, z=-4>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=1, y=-8, z=2>, vel=<x=0, y=-4, z=0>")); Step(moons); //After 4 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=2, y=-8, z=0>, vel=<x=-3, y=-2, z=1>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=2, y=1, z=7>, vel=<x=2, y=1, z=1>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=2, y=3, z=-6>, vel=<x=0, y=2, z=-1>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=2, y=-9, z=1>, vel=<x=1, y=-1, z=-1>")); Step(moons); //After 5 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-1, y=-9, z=2>, vel=<x=-3, y=-1, z=2>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=4, y=1, z=5>, vel=<x=2, y=0, z=-2>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=2, y=2, z=-4>, vel=<x=0, y=-1, z=2>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=3, y=-7, z=-1>, vel=<x=1, y=2, z=-2>")); Step(moons); //After 6 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=-1, y=-7, z=3>, vel=<x=0, y=2, z=1>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=3, y=0, z=0>, vel=<x=-1, y=-1, z=-5>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=3, y=-2, z=1>, vel=<x=1, y=-4, z=5>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=3, y=-4, z=-2>, vel=<x=0, y=3, z=-1>")); Step(moons); //After 7 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=2, y=-2, z=1>, vel=<x=3, y=5, z=-2>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=1, y=-4, z=-4>, vel=<x=-2, y=-4, z=-4>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=3, y=-7, z=5>, vel=<x=0, y=-5, z=4>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=2, y=0, z=0>, vel=<x=-1, y=4, z=2>")); Step(moons); //After 8 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=5, y=2, z=-2>, vel=<x=3, y=4, z=-3>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=2, y=-7, z=-5>, vel=<x=1, y=-3, z=-1>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=0, y=-9, z=6>, vel=<x=-3, y=-2, z=1>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=1, y=1, z=3>, vel=<x=-1, y=1, z=3>")); Step(moons); //After 9 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=5, y=3, z=-4>, vel=<x=0, y=1, z=-2>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=2, y=-9, z=-3>, vel=<x=0, y=-2, z=2>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=0, y=-8, z=4>, vel=<x=0, y=1, z=-2>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=1, y=1, z=5>, vel=<x=0, y=0, z=2>")); Step(moons); //After 10 steps: Assert.That(moons[0].ToString(), Is.EqualTo("pos=<x=2, y=1, z=-3>, vel=<x=-3, y=-2, z=1>")); Assert.That(moons[1].ToString(), Is.EqualTo("pos=<x=1, y=-8, z=0>, vel=<x=-1, y=1, z=3>")); Assert.That(moons[2].ToString(), Is.EqualTo("pos=<x=3, y=-6, z=1>, vel=<x=3, y=2, z=-3>")); Assert.That(moons[3].ToString(), Is.EqualTo("pos=<x=2, y=0, z=4>, vel=<x=1, y=-1, z=-1>")); Assert.That(GetTotalEnergy(moons), Is.EqualTo(179)); int counter = 10; while (true) { if (GetTotalEnergy(moons) == 0 && moons[0].ToString() == "pos=<x=-1, y=0, z=2>, vel=<x=0, y=0, z=0>") { break; } Step(moons); counter++; } Assert.That(counter, Is.EqualTo(2772)); Console.WriteLine(counter); }
public void ApplyGravity(Moon other) { ApplyGravityInternal(this, other); ApplyGravityInternal(other, this); }
private bool MoonEqual(Moon a, Moon b) { return(a.x == b.x && a.y == b.y && a.z == b.z && a.vx == b.vx && a.vy == b.vy && a.vz == b.vz); }
public static void ApplyGravity(Moon m1, Moon m2) { ApplyGravity(m1.X, m2.X, ref m1.vX, ref m2.vX); ApplyGravity(m1.Y, m2.Y, ref m1.vY, ref m2.vY); ApplyGravity(m1.Z, m2.Z, ref m1.vZ, ref m2.vZ); }
static void ComperMoons(Moon moonA, Moon moonB) { ComperMoonsX(moonA, moonB); ComperMoonsY(moonA, moonB); ComperMoonsZ(moonA, moonB); }
public void AddMoon(Moon moon) { this.Moons.Add(moon); }
public void ApplyGravity(Moon moon) { ApplyGravity(Dimension.X, moon); ApplyGravity(Dimension.Y, moon); ApplyGravity(Dimension.Z, moon); }