Exemplo n.º 1
0
        public void TestGetClosestPlanetsToTargetBySectors3()
        {
            PlanetWars pw = new PlanetWars(
                "P 0 2 1 5 0#0\n" +
                "P 0 4 1 5 0#1\n" +
                "P 1 0 1 5 0#2\n" +
                "P 5 1 1 5 0#3\n" +
                "P 5 5 1 5 0#4\n" +
                "P 10 0 1 5 0#5\n" +
                "P 9 5 1 5 0#6\n" +
                "P 11 3 1 5 0#7\n" +
                "P 11 2 2 5 0#8\n" +
                "go\n");

            Planets closestPlanets = pw.GetClosestPlanetsToTargetBySectors(pw.GetPlanet(0), pw.MyPlanets());

            Assert.AreEqual(2, closestPlanets.Count);
        }
Exemplo n.º 2
0
		public static void Main()
		{
			CultureInfo myCulture = new CultureInfo("en-US");
			Thread.CurrentThread.CurrentCulture = myCulture;

			turn = 0;
			string line = "";
			string message = "";
			try
			{
				int c;
				while ((c = Console.Read()) >= 0)
				{
					switch (c)
					{
						case '\n':
							line = line.Trim();
							if (line.Equals("go"))
							{
								turn++;
								Config.CurrentTurn = turn;
								PlanetWars pw = new PlanetWars(message);
#if LOG
								Logger.Log("");
								Logger.Log(
									"Turn " + Convert.ToString(turn) +
									" (" +
									"ships " +
									Convert.ToString(pw.MyTotalShipCount) + "/" + Convert.ToString(pw.EnemyTotalShipCount) + " " +
									"planets " +
									Convert.ToString(pw.MyPlanets().Count) + "/" + Convert.ToString(pw.EnemyPlanets().Count) + " " +
									"prod " +
									Convert.ToString(pw.MyProduction) + "/" + Convert.ToString(pw.EnemyProduction) + " " +
									")");
#endif
								if (bot == null)
									bot = new MyBot(pw);
								else
									bot.Context = pw;
								bot.DoTurn();
#if LOG
								//Logger.Log("  Turn time: " + (DateTime.Now - startTime).TotalMilliseconds);
#endif
								message = "";
							}
							else
							{
								message += line + "\n";
							}
							line = "";
							break;
						default:
							if (line == "")
							{
								//start reading data
								startTime = DateTime.Now;
							}
							line += (char) c;
							break;
					}
				}
			}
// ReSharper disable EmptyGeneralCatchClause
			catch
// ReSharper restore EmptyGeneralCatchClause
			{
				// Owned.
			}
		}
Exemplo n.º 3
0
        public void TestGetClosestPlanetsToTargetBySectors()
        {
            PlanetWars pw = new PlanetWars(
                "P 10.946215 11.757139 0 15 4#0\n" +
                "P 18.033072 20.11299 1 5 5#1\n" +
                "P 28.033072 30.11299 1 5 5#1\n" +
                "go\n");

            Planets closestPlanets = pw.GetClosestPlanetsToTargetBySectors(pw.GetPlanet(0), pw.MyPlanets());

            Assert.AreEqual(1, closestPlanets.Count);
            Assert.AreEqual(1, closestPlanets[0].PlanetID());
        }