Пример #1
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.
			}
		}
Пример #2
0
        public void TestDoAttack()
        {
            PlanetWars pw = new PlanetWars(
                "P 10.7527454812 11.8062363634 1 16 5\n" +
                "P 7.71825346006 19.2282675745 1 9 5\n" +
                "P 13.7872375024 4.3842051524 1 17 5\n" +
                "P 16.5885619084 4.19029815187 1 5 3\n" +
                "P 4.91692905402 19.422174575 1 14 3\n" +
                "P 17.1016331607 8.0105449784 1 3 3\n" +
                "P 4.40385780175 15.6019277485 1 17 3\n" +
                "P 4.79266235586 21.5213595465 1 2 2\n" +
                "P 16.7128286066 2.09111318038 1 2 2\n" +
                "P 18.0296511565 14.1785383486 1 6 4\n" +
                "P 3.47583980592 9.43393437829 1 6230 4\n" +
                "P 6.5168372747 3.38746940068 1 20 2\n" +
                "P 14.9886536877 20.2250033262 1 3 2\n" +
                "P 20.6147572889 14.2829339055 1 4 4\n" +
                "P 0.890733673483 9.32953882139 1 443 4\n" +
                "P 0 0 1 1 1\n" +
                "P 21.5054909624 23.6124727269 1 1 1\n" +
                "P 5.14922220606 9.48382106252 1 22 2\n" +
                "P 16.3562687564 14.1286516644 1 15 2\n" +
                "P 8.40774862412 22.1804224379 1 4 4\n" +
                "P 13.0977423383 1.43205028894 1 4 4\n" +
                "P 19.4279066762 13.2056512821 1 2 2\n" +
                "P 2.07758428622 10.4068214448 2 13 2\n" +
                "go\n");

            MyBot bot = new MyBot(pw);
            MyBot.DoCheckTime = false;

            bot.DoTurn();
            Assert.IsTrue(pw.MyFleetsGoingToPlanet(pw.EnemyPlanets()[0]).Count > 0);
        }