- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 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;
Мда, это как называть садовую тачку с деревянными колёсиками машиной.
Искуственный Идиот.