Си диез / Говнокод #21108 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
class Program
	{
		public static Grid GameGrid = new Grid(30, 20);
		public static Players players;
		static void Main(string[] args)
		{
			string[] inputs;
			// game loop
			while (true)
			{
				
				inputs = Console.ReadLine().Split(' ');
				int N = int.Parse(inputs[0]); // total number of players (2 to 4).
				players = new Players(N);
				int P = int.Parse(inputs[1]); // your player number (0 to 3).
				for (int i = 0; i < N; i++)
				{
					inputs = Console.ReadLine().Split(' ');

					players.Update(
						new Player(i,
						new Point(int.Parse(inputs[0]), int.Parse(inputs[1])),
						new Point(int.Parse(inputs[2]), int.Parse(inputs[3]))));
				}

				Debug.WriteLine("Players [{0}]:", N);
				players.ForEach(player => Debug.WriteLine("Player {2} Initial XY : {0}, Final XY : {1}", 
					player.GetPreviousPos().ToString(), 
					player.GetCurrentPos().ToString(), 
					player.GetId()));

				players[P].MoveRandom();
			}
		}
	}

	class Players : List<Player>
	{
		public Players(int size)
		{
			if (size < 1) throw new IndexOutOfRangeException();
			Capacity = size;
		}
		public void Update(Player p)
		{
			if (Count < Capacity) Add(p);
			else this[p.GetId()].Update(p);
			Program.GameGrid.Update(p);
		}

		public bool IsFull()
		{
			return !(Count < Capacity);
		}
	}
	class Player
	{

		public void MoveRandom()
		{
			Console.Error.WriteLine("Move Random Entered");
			bool continueLoop = true;
			Random rand = new Random();
			while (continueLoop)
			{
				continueLoop = false;
				

				int randNum = rand.Next(4);
				Console.Error.WriteLine("Rand num = {0}", randNum);
				switch (randNum)
				{
					case 0:
						Debug.WriteLine("Case 0 Entered ...");
						if (!Program.GameGrid.IsValid(UpperPoint()))
						{
							Debug.WriteLine("Upper Point : {0} is not Valid !", UpperPoint());
							continueLoop = true;
							break;
						}
						Debug.WriteLine("Going UP !");
						Console.WriteLine("UP");
						break;
					case 1:
						Debug.WriteLine("Case 1 Entered ...");
						if (!Program.GameGrid.IsValid(RightPoint()))
						{
							Debug.WriteLine("Right Point Point : {0} is not Valid !", RightPoint());
							continueLoop = true;
							break;
						}
						Debug.WriteLine("Going RIGHT !");
						Console.WriteLine("RIGHT");
						break;
					case 2:
						Debug.WriteLine("Case 2 Entered ...");
						if (!Program.GameGrid.IsValid(DownPoint()))
						{
							Debug.WriteLine("Down Point : {0} is not Valid !", DownPoint());
							continueLoop = true;

чувак спрашивал, чё его код ИИ для игры не работает, а там вот что
чуть не поместилось

Запостил: the_user the_user, (Updated )

Комментарии (5) RSS

Добавить комментарий

Семь раз отмерь — один отрежь, guest!

    А не использовать ли нам bbcode?


    8