private static void VoidAll(State s) { var commands = new Command[s.Bots.Count]; int r = s.Matrix.R; Delta down = Delta.LinearY(-1); while (s.Bots[0].Pos.Y > 0) { for (int i = 0; i < s.Bots.Count; i++) { int dx = (s.Bots[i].Pos.X % 31 == (r - 1) % 31) ? -30 : +30; if (s.Bots[i].Pos.X == 0) { dx = r - 63; } dx = Math.Max(dx, -s.Bots[i].Pos.X); int dz = (s.Bots[i].Pos.Z % 31 == (r - 1) % 31) ? -30 : +30; if (s.Bots[i].Pos.Z == 0) { dz = r - 63; } dz = Math.Max(dz, -s.Bots[i].Pos.Z); commands[i] = Commands.GVoid(down, Delta.Of(dx, 0, dz)); } s.DoTurn(commands); for (int i = 0; i < s.Bots.Count; i++) { commands[i] = Commands.SMove(down); } s.DoTurn(commands); } }
private static Command ReadGVoid(int b1, Stream stream) { int n = (b1 & 0b11111000) >> 3; int dx = stream.StrictReadByte(); int dy = stream.StrictReadByte(); int dz = stream.StrictReadByte(); Delta nd = DeltaDecoder.DecodeNd(n); Delta fd = DeltaDecoder.DecodeFd(dx, dy, dz); return(Commands.GVoid(nd, fd)); }
private void Execute() { Delta down = Delta.LinearY(-1); var gvoid = new Command[S.Bots.Count]; for (int i = 0; i < S.Bots.Count; i++) { int dx = (S.Bots[i].Pos.X % 31 == (R - 1) % 31) ? -30 : +30; if (S.Bots[i].Pos.X == 0) { dx = (R + 30) % 31; } dx = Math.Max(dx, -S.Bots[i].Pos.X); int dz = (S.Bots[i].Pos.Z % 31 == (R - 1) % 31) ? -30 : +30; if (S.Bots[i].Pos.Z == 0) { dz = (R + 30) % 31; } dz = Math.Max(dz, -S.Bots[i].Pos.Z); gvoid[i] = Commands.GVoid(down, Delta.Of(dx, 0, dz)); } var smove = new Command[S.Bots.Count]; for (int i = 0; i < S.Bots.Count; i++) { smove[i] = Commands.SMove(down); } var flipw = new Command[S.Bots.Count]; for (int i = 0; i < S.Bots.Count; i++) { flipw[i] = (i == 0) ? Commands.Flip() : Commands.Wait(); } while (S.Bots[0].Pos.Y > 0) { if (S.Harmonics == Low && mHarmonics[S.Bots[0].Pos.Y - 1] == High) { S.DoTurn(flipw); } S.DoTurn(gvoid); if (S.Harmonics == High && mHarmonics[S.Bots[0].Pos.Y - 1] == Low) { S.DoTurn(flipw); } S.DoTurn(smove); } }
private void Execute() { var commands = new Command[S.Bots.Count]; Delta down = Delta.LinearY(-1); while (true) { int z = 0; while (true) { for (int i = 0; i < S.Bots.Count; i++) { int dx = (S.Bots[i].Pos.X % 31 == (R - 1) % 31) ? -30 : +30; if (S.Bots[i].Pos.X == 0) { dx = (R + 30) % 31; } dx = Math.Max(dx, -S.Bots[i].Pos.X); int dz = (S.Bots[i].Pos.Z == z) ? +30 : -30; commands[i] = Commands.GVoid(down, Delta.Of(dx, 0, dz)); } S.DoTurn(commands); if (z + 30 == MaxZ) { break; } int dz0 = Math.Min(z + 30, MaxZ - 30) - z; z += dz0; for (int dz = dz0; dz > 0; dz -= 15) { for (int i = 0; i < S.Bots.Count; i++) { commands[i] = Commands.SMove(Delta.LinearZ(Math.Min(dz, 15))); } S.DoTurn(commands); } } for (int i = 0; i < S.Bots.Count; i++) { commands[i] = Commands.SMove(down); } S.DoTurn(commands); if (S.Bots[0].Pos.Y == 0) { for (; z > 0; z -= 15) { for (int i = 0; i < S.Bots.Count; i++) { commands[i] = Commands.SMove(Delta.LinearZ(-Math.Min(z, 15))); } S.DoTurn(commands); } break; } while (true) { for (int i = 0; i < S.Bots.Count; i++) { int dx = (S.Bots[i].Pos.X % 31 == (R - 1) % 31) ? -30 : +30; if (S.Bots[i].Pos.X == 0) { dx = (R + 30) % 31; } dx = Math.Max(dx, -S.Bots[i].Pos.X); int dz = (S.Bots[i].Pos.Z == z) ? +30 : -30; commands[i] = Commands.GVoid(down, Delta.Of(dx, 0, dz)); } S.DoTurn(commands); if (z == 0) { break; } int dz0 = z - Math.Max(z - 30, 0); z -= dz0; for (int dz = dz0; dz > 0; dz -= 15) { for (int i = 0; i < S.Bots.Count; i++) { commands[i] = Commands.SMove(Delta.LinearZ(-Math.Min(dz, 15))); } S.DoTurn(commands); } } for (int i = 0; i < S.Bots.Count; i++) { commands[i] = Commands.SMove(down); } S.DoTurn(commands); if (S.Bots[0].Pos.Y == 0) { break; } } }