- 001
- 002
- 003
- 004
- 005
- 006
- 007
- 008
- 009
- 010
- 011
- 012
- 013
- 014
- 015
- 016
- 017
- 018
- 019
- 020
- 021
- 022
- 023
- 024
- 025
- 026
- 027
- 028
- 029
- 030
- 031
- 032
- 033
- 034
- 035
- 036
- 037
- 038
- 039
- 040
- 041
- 042
- 043
- 044
- 045
- 046
- 047
- 048
- 049
- 050
- 051
- 052
- 053
- 054
- 055
- 056
- 057
- 058
- 059
- 060
- 061
- 062
- 063
- 064
- 065
- 066
- 067
- 068
- 069
- 070
- 071
- 072
- 073
- 074
- 075
- 076
- 077
- 078
- 079
- 080
- 081
- 082
- 083
- 084
- 085
- 086
- 087
- 088
- 089
- 090
- 091
- 092
- 093
- 094
- 095
- 096
- 097
- 098
- 099
- 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;
Мда, это как называть садовую тачку с деревянными колёсиками машиной.
Искуственный Идиот.